X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fcommand.c;h=9e23e5723b04463bf57f32166c35a29fbcc6e69e;hb=84fc760439e82e6b3616abd0d1f9bd7d7eb01ec0;hp=32615137fada79f99e0087380209e3f4b76cbb7d;hpb=2361905686c62b4163232139c3d390acd2c07916;p=libguestfs.git diff --git a/daemon/command.c b/daemon/command.c index 3261513..9e23e57 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -36,7 +36,7 @@ do_command (char **argv) int dev_ok, dev_pts_ok, proc_ok, selinux_ok, sys_ok; /* We need a root filesystem mounted to do this. */ - NEED_ROOT (NULL); + NEED_ROOT (return NULL); /* Conveniently, argv is already a NULL-terminated argv-style array * of parameters, so we can pass it straight in to our internal @@ -61,6 +61,18 @@ do_command (char **argv) sysroot_selinux = sysroot_path ("/selinux"); sysroot_sys = sysroot_path ("/sys"); + if (sysroot_dev == NULL || sysroot_dev_pts == NULL || + sysroot_proc == NULL || sysroot_selinux == NULL || + sysroot_sys == NULL) { + reply_with_perror ("malloc"); + free (sysroot_dev); + free (sysroot_dev_pts); + free (sysroot_proc); + free (sysroot_selinux); + free (sysroot_sys); + return NULL; + } + r = command (NULL, NULL, "mount", "--bind", "/dev", sysroot_dev, NULL); dev_ok = r != -1; r = command (NULL, NULL, "mount", "--bind", "/dev/pts", sysroot_dev_pts, NULL); @@ -120,7 +132,7 @@ do_command_lines (char **argv) } char * -do_sh (char *command) +do_sh (const char *command) { char *argv[] = { "/bin/sh", "-c", command, NULL }; @@ -128,7 +140,7 @@ do_sh (char *command) } char ** -do_sh_lines (char *command) +do_sh_lines (const char *command) { char *argv[] = { "/bin/sh", "-c", command, NULL };