Commit 18d91708 authored by Pavel Emelyanov's avatar Pavel Emelyanov

util: Add flags to cr_system

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e5a91658
...@@ -172,9 +172,9 @@ extern int is_anon_link_type(char *link, char *type); ...@@ -172,9 +172,9 @@ extern int is_anon_link_type(char *link, char *type);
extern void *shmalloc(size_t bytes); extern void *shmalloc(size_t bytes);
extern void shfree_last(void *ptr); extern void shfree_last(void *ptr);
extern int cr_system(int in, int out, int err, char *cmd, char *const argv[]); extern int cr_system(int in, int out, int err, char *cmd, char *const argv[], unsigned flags);
extern int cr_system_userns(int in, int out, int err, char *cmd, extern int cr_system_userns(int in, int out, int err, char *cmd,
char *const argv[], int userns_pid); char *const argv[], unsigned flags, int userns_pid);
extern int cr_daemon(int nochdir, int noclose, int *keep_fd, int close_fd); extern int cr_daemon(int nochdir, int noclose, int *keep_fd, int close_fd);
extern int is_root_user(void); extern int is_root_user(void);
......
...@@ -1203,7 +1203,7 @@ static int tmpfs_dump(struct mount_info *pm) ...@@ -1203,7 +1203,7 @@ static int tmpfs_dump(struct mount_info *pm)
"--preserve-permissions", "--preserve-permissions",
"--sparse", "--sparse",
"--numeric-owner", "--numeric-owner",
"--directory", tmpfs_path, ".", NULL }, userns_pid); "--directory", tmpfs_path, ".", NULL }, 0, userns_pid);
if (ret) if (ret)
pr_err("Can't dump tmpfs content\n"); pr_err("Can't dump tmpfs content\n");
...@@ -1256,7 +1256,7 @@ static int tmpfs_restore(struct mount_info *pm) ...@@ -1256,7 +1256,7 @@ static int tmpfs_restore(struct mount_info *pm)
ret = cr_system(img_raw_fd(img), -1, -1, "tar", ret = cr_system(img_raw_fd(img), -1, -1, "tar",
(char *[]) {"tar", "--extract", "--gzip", (char *[]) {"tar", "--extract", "--gzip",
"--no-unquote", "--no-wildcards", "--no-unquote", "--no-wildcards",
"--directory", pm->mountpoint, NULL}); "--directory", pm->mountpoint, NULL}, 0);
close_image(img); close_image(img);
if (ret) { if (ret) {
......
...@@ -600,7 +600,7 @@ static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout) ...@@ -600,7 +600,7 @@ static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout)
ip_tool_cmd = "ip"; ip_tool_cmd = "ip";
ret = cr_system(fdin, fdout, -1, ip_tool_cmd, ret = cr_system(fdin, fdout, -1, ip_tool_cmd,
(char *[]) { "ip", arg1, arg2, arg3, NULL }); (char *[]) { "ip", arg1, arg2, arg3, NULL }, 0);
if (ret) { if (ret) {
pr_err("IP tool failed on %s %s\n", arg1, arg2); pr_err("IP tool failed on %s %s\n", arg1, arg2);
return -1; return -1;
...@@ -618,7 +618,7 @@ static int run_iptables_tool(char *def_cmd, int fdin, int fdout) ...@@ -618,7 +618,7 @@ static int run_iptables_tool(char *def_cmd, int fdin, int fdout)
if (!cmd) if (!cmd)
cmd = def_cmd; cmd = def_cmd;
pr_debug("\tRunning %s for %s\n", cmd, def_cmd); pr_debug("\tRunning %s for %s\n", cmd, def_cmd);
ret = cr_system(fdin, fdout, -1, "sh", (char *[]) { "sh", "-c", cmd, NULL }); ret = cr_system(fdin, fdout, -1, "sh", (char *[]) { "sh", "-c", cmd, NULL }, 0);
if (ret) if (ret)
pr_err("%s failed\n", def_cmd); pr_err("%s failed\n", def_cmd);
......
...@@ -64,7 +64,7 @@ static int nf_connection_switch_raw(int family, u32 *src_addr, u16 src_port, ...@@ -64,7 +64,7 @@ static int nf_connection_switch_raw(int family, u32 *src_addr, u16 src_port,
* cr_system is used here, because it blocks SIGCHLD before waiting * cr_system is used here, because it blocks SIGCHLD before waiting
* a child and the child can't be waited from SIGCHLD handler. * a child and the child can't be waited from SIGCHLD handler.
*/ */
ret = cr_system(-1, -1, -1, "sh", argv); ret = cr_system(-1, -1, -1, "sh", argv, 0);
if (ret < 0 || !WIFEXITED(ret) || WEXITSTATUS(ret)) { if (ret < 0 || !WIFEXITED(ret) || WEXITSTATUS(ret)) {
pr_perror("Iptables configuration failed"); pr_perror("Iptables configuration failed");
return -1; return -1;
......
...@@ -509,13 +509,13 @@ void shfree_last(void *ptr) ...@@ -509,13 +509,13 @@ void shfree_last(void *ptr)
* If "in" is negative, stdin will be closed. * If "in" is negative, stdin will be closed.
* If "out" or "err" are negative, a log file descriptor will be used. * If "out" or "err" are negative, a log file descriptor will be used.
*/ */
int cr_system(int in, int out, int err, char *cmd, char *const argv[]) int cr_system(int in, int out, int err, char *cmd, char *const argv[], unsigned flags)
{ {
return cr_system_userns(in, out, err, cmd, argv, -1); return cr_system_userns(in, out, err, cmd, argv, flags, -1);
} }
int cr_system_userns(int in, int out, int err, char *cmd, int cr_system_userns(int in, int out, int err, char *cmd,
char *const argv[], int userns_pid) char *const argv[], unsigned flags, int userns_pid)
{ {
sigset_t blockmask, oldmask; sigset_t blockmask, oldmask;
int ret = -1, status; int ret = -1, status;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment