Fix system regression
This commit is contained in:
parent
681323267d
commit
2fa1fba5ee
|
@ -9,7 +9,7 @@ static int r_main_r2pm_sh(int argc, const char **argv) {
|
||||||
r_strbuf_appendf (sb, " %s", argv[i]);
|
r_strbuf_appendf (sb, " %s", argv[i]);
|
||||||
}
|
}
|
||||||
char *cmd = r_strbuf_drain (sb);
|
char *cmd = r_strbuf_drain (sb);
|
||||||
int res = r_sandbox_system (cmd, 0);
|
int res = r_sandbox_system (cmd, 1);
|
||||||
free (cmd);
|
free (cmd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,14 @@ typedef struct r_r2pm_t {
|
||||||
|
|
||||||
static int git_pull(const char *dir) {
|
static int git_pull(const char *dir) {
|
||||||
char *s = r_str_newf ("cd %s\ngit pull", dir);
|
char *s = r_str_newf ("cd %s\ngit pull", dir);
|
||||||
int rc = r_sandbox_system (s, 0);
|
int rc = r_sandbox_system (s, 1);
|
||||||
free (s);
|
free (s);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int git_clone(const char *dir, const char *url) {
|
static int git_clone(const char *dir, const char *url) {
|
||||||
char *cmd = r_str_newf ("git clone --depth=3 --recursive %s %s", url, dir);
|
char *cmd = r_str_newf ("git clone --depth=3 --recursive %s %s", url, dir);
|
||||||
int rc = r_sandbox_system (cmd, 0);
|
int rc = r_sandbox_system (cmd, 1);
|
||||||
free (cmd);
|
free (cmd);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ static int r2pm_install_pkg(const char *pkg) {
|
||||||
r2pm_setenv ();
|
r2pm_setenv ();
|
||||||
char *srcdir = r2pm_gitdir ();
|
char *srcdir = r2pm_gitdir ();
|
||||||
char *s = r_str_newf ("cd '%s/%s'\nexport MAKE=make\nR2PM_FAIL(){\n echo $@\n}\n%s", srcdir, pkg, script);
|
char *s = r_str_newf ("cd '%s/%s'\nexport MAKE=make\nR2PM_FAIL(){\n echo $@\n}\n%s", srcdir, pkg, script);
|
||||||
int res = r_sandbox_system (s, 0);
|
int res = r_sandbox_system (s, 1);
|
||||||
free (s);
|
free (s);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ static int r2pm_uninstall_pkg(const char *pkg) {
|
||||||
char *srcdir = r2pm_gitdir ();
|
char *srcdir = r2pm_gitdir ();
|
||||||
char *s = r_str_newf ("cd %s/%s\nexport MAKE=make\nR2PM_FAIL(){\n echo $@\n}\n%s",
|
char *s = r_str_newf ("cd %s/%s\nexport MAKE=make\nR2PM_FAIL(){\n echo $@\n}\n%s",
|
||||||
srcdir, pkg, script);
|
srcdir, pkg, script);
|
||||||
int res = r_sandbox_system (s, 0);
|
int res = r_sandbox_system (s, 1);
|
||||||
free (s);
|
free (s);
|
||||||
free (srcdir);
|
free (srcdir);
|
||||||
return res;
|
return res;
|
||||||
|
@ -512,7 +512,7 @@ static int r_main_r2pm_c(int argc, const char **argv) {
|
||||||
r_strbuf_appendf (sb, " %s", argv[i]);
|
r_strbuf_appendf (sb, " %s", argv[i]);
|
||||||
}
|
}
|
||||||
char *cmd = r_strbuf_drain (sb);
|
char *cmd = r_strbuf_drain (sb);
|
||||||
int res = r_sandbox_system (cmd, 0);
|
int res = r_sandbox_system (cmd, 1);
|
||||||
free (cmd);
|
free (cmd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,13 @@ R_API int r_sandbox_system(const char *x, int n) {
|
||||||
int s = waitpid (pid, &status, 0);
|
int s = waitpid (pid, &status, 0);
|
||||||
return WEXITSTATUS (s);
|
return WEXITSTATUS (s);
|
||||||
}
|
}
|
||||||
|
int child = fork ();
|
||||||
|
if (child == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (child) {
|
||||||
|
return waitpid (child, NULL, 0);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
return system (x);
|
return system (x);
|
||||||
#endif
|
#endif
|
||||||
|
@ -268,13 +275,6 @@ R_API int r_sandbox_system(const char *x, int n) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
int child = fork ();
|
|
||||||
if (child == -1) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (child) {
|
|
||||||
return waitpid (child, NULL, 0);
|
|
||||||
}
|
|
||||||
char *bin_sh = r_file_binsh ();
|
char *bin_sh = r_file_binsh ();
|
||||||
if (execl (bin_sh, "sh", "-c", x, (const char*)NULL) == -1) {
|
if (execl (bin_sh, "sh", "-c", x, (const char*)NULL) == -1) {
|
||||||
perror ("execl");
|
perror ("execl");
|
||||||
|
|
Loading…
Reference in New Issue