Skip to content

Commit

Permalink
fix sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Oct 4, 2023
1 parent 145f205 commit 5c9b9c5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/ccode.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ private extern void no_stderr ();
private extern void reset_std ();

//DOC: ### sandbox.c
//DOC: `void sandbox (string[] args):`
//DOC: `void sandbox (string type, string[] args):`
//DOC: run command in sandboxed area
public extern int sandbox (string[] args);
public extern int sandbox (string type, string[] args);
//DOC: `boot sandbox_network:`
//DOC: enable/disable sandbox network access (default: false)
public extern bool sandbox_network;
Expand Down
6 changes: 4 additions & 2 deletions src/ccode/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ char* sandbox_tmpfs;

char* sandbox_rootfs;

int sandbox(char** args){
int sandbox(char* type, char** args){
int flag = CLONE_NEWCGROUP | CLONE_NEWNS | CLONE_NEWUSER;
if(isfile("/.sandbox")){
exit(31);
Expand Down Expand Up @@ -118,7 +118,9 @@ int sandbox(char** args){
unshare(CLONE_VM);
unshare(CLONE_NEWPID| CLONE_VFORK | SIGCHLD);
char *envp[] = {"TERM=linux", "PATH=/usr/bin:/bin:/usr/sbin:/sbin", NULL};
exit(operation_main_raw("exec",args));
ymp_init();
//puts(args[0]);
exit(operation_main_raw(type,args));
}
}
exit(127);
Expand Down
4 changes: 2 additions & 2 deletions src/operations/shell/exec.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ public int exec_main (string[] args) {
if (get_destdir () != "/") {
status = run_args ( {"chroot", get_destdir (), cmd}) / 256;
}else if (get_bool ("silent")) {
status = run_args_silent ( { "sh", "-c" , cmd}) / 256;
status = run_args_silent (args) / 256;
}else {
status = run_args ( { "sh", "-c" , cmd}) / 256;
status = run_args (args) / 256;
}
if (status != 0) {
error_add (_ ("Failed to run command: %s").printf (cmd));
Expand Down
2 changes: 1 addition & 1 deletion src/operations/utility/run-sandbox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public int run_sandbox_main (string[] args) {
sandbox_uid = int.parse (get_value ("uid"));
sandbox_gid = int.parse (get_value ("gid"));
info (_ ("Execute sandbox :%s").printf (join (" ", args)));
int status = sandbox (args);
int status = sandbox ("exec", args);
return status / 256;
}

Expand Down
6 changes: 2 additions & 4 deletions src/util/string.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ public string join (string f, string[] array) {
return "";
}
foreach (string item in array) {
if (item.length > 0 && item != null) {
tmp += item + f;
}
tmp += item + f;
}
if (f.length >= tmp.length) {
return tmp;
}
return tmp[0:tmp.length - f.length];
return tmp[0:-f.length];
}
//DOC: `public int[] sindex (string f, string[] array)`:
//DOC: Get item index number array in string array.
Expand Down

0 comments on commit 5c9b9c5

Please sign in to comment.