From 6bda071b5cd8393b37653687027c4ae6c6cf3804 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 10 Aug 2009 23:11:01 +0200 Subject: [PATCH] update all NEED_ROOT uses run this command: git grep -l -w NEED_ROOT|xargs perl -pi -e \ 's/(NEED_ROOT) \((.*?)\)/$1 (return $2)/' --- daemon/augeas.c | 2 +- daemon/checksum.c | 2 +- daemon/cmp.c | 2 +- daemon/command.c | 2 +- daemon/cpmv.c | 2 +- daemon/daemon.h | 2 +- daemon/df.c | 4 ++-- daemon/dir.c | 12 ++++++------ daemon/du.c | 2 +- daemon/fallocate.c | 2 +- daemon/file.c | 22 +++++++++++----------- daemon/find.c | 2 +- daemon/glob.c | 2 +- daemon/grep.c | 2 +- daemon/grub.c | 2 +- daemon/headtail.c | 2 +- daemon/hexdump.c | 2 +- daemon/initrd.c | 2 +- daemon/inotify.c | 2 +- daemon/link.c | 4 ++-- daemon/ls.c | 2 +- daemon/mknod.c | 2 +- daemon/mount.c | 6 +++--- daemon/readdir.c | 2 +- daemon/realpath.c | 2 +- daemon/scrub.c | 4 ++-- daemon/stat.c | 6 +++--- daemon/strings.c | 2 +- daemon/swap.c | 6 +++--- daemon/tar.c | 4 ++-- daemon/wc.c | 2 +- daemon/xattr.c | 2 +- 32 files changed, 57 insertions(+), 57 deletions(-) diff --git a/daemon/augeas.c b/daemon/augeas.c index 45f86cf..b6cc8f0 100644 --- a/daemon/augeas.c +++ b/daemon/augeas.c @@ -54,7 +54,7 @@ do_aug_init (char *root, int flags) #ifdef HAVE_AUGEAS char *buf; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (root, return -1); if (aug) { diff --git a/daemon/checksum.c b/daemon/checksum.c index d12413f..c06a697 100644 --- a/daemon/checksum.c +++ b/daemon/checksum.c @@ -36,7 +36,7 @@ do_checksum (char *csumtype, char *path) int r; int len; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); if (strcasecmp (csumtype, "crc") == 0) diff --git a/daemon/cmp.c b/daemon/cmp.c index 30574e2..a48e924 100644 --- a/daemon/cmp.c +++ b/daemon/cmp.c @@ -34,7 +34,7 @@ do_equal (char *file1, char *file2) char *err; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (file1, return -1); ABS_PATH (file2, return -1); diff --git a/daemon/command.c b/daemon/command.c index 4420cba..f7a6dcf 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 diff --git a/daemon/cpmv.c b/daemon/cpmv.c index 37f1219..4fdee6b 100644 --- a/daemon/cpmv.c +++ b/daemon/cpmv.c @@ -52,7 +52,7 @@ cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest) char *err; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (src, return -1); ABS_PATH (dest, return -1); diff --git a/daemon/daemon.h b/daemon/daemon.h index cbcab63..ee71fb6 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -176,7 +176,7 @@ extern void reply (xdrproc_t xdrp, char *ret); if (strncmp ((path), "/dev/", 5) == 0) \ RESOLVE_DEVICE ((path), fail_stmt); \ else { \ - NEED_ROOT (fail_stmt); \ + NEED_ROOT (return fail_stmt); \ ABS_PATH ((path),fail_stmt); \ } \ } while (0) diff --git a/daemon/df.c b/daemon/df.c index 73604b4..ad662fa 100644 --- a/daemon/df.c +++ b/daemon/df.c @@ -33,7 +33,7 @@ do_df () int r; char *out, *err; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); r = command (&out, &err, "df", NULL); if (r == -1) { @@ -54,7 +54,7 @@ do_df_h () int r; char *out, *err; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); r = command (&out, &err, "df", "-h", NULL); if (r == -1) { diff --git a/daemon/dir.c b/daemon/dir.c index 20cbd24..ec072dd 100644 --- a/daemon/dir.c +++ b/daemon/dir.c @@ -34,7 +34,7 @@ do_rmdir (char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -59,7 +59,7 @@ do_rm_rf (char *path) int r; char *buf, *err; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); if (strcmp (path, "/") == 0) { @@ -93,7 +93,7 @@ do_mkdir (char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -159,7 +159,7 @@ do_mkdir_p (char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -180,7 +180,7 @@ do_is_dir (char *path) int r; struct stat buf; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -204,7 +204,7 @@ do_mkdtemp (char *template) { char *r; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (template, return NULL); CHROOT_IN; diff --git a/daemon/du.c b/daemon/du.c index 7d9c663..f5f083d 100644 --- a/daemon/du.c +++ b/daemon/du.c @@ -36,7 +36,7 @@ do_du (char *path) char *out, *err; char *buf; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); /* Make the path relative to /sysroot. */ diff --git a/daemon/fallocate.c b/daemon/fallocate.c index f61c496..9c5a3dd 100644 --- a/daemon/fallocate.c +++ b/daemon/fallocate.c @@ -32,7 +32,7 @@ do_fallocate (char *path, int len) { int fd, r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; diff --git a/daemon/file.c b/daemon/file.c index 2ba2aab..d8425e9 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -35,7 +35,7 @@ do_touch (char *path) int fd; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -73,7 +73,7 @@ do_cat (char *path) int alloc, size, r, max; char *buf, *buf2; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; @@ -147,7 +147,7 @@ do_read_lines (char *path) size_t len = 0; ssize_t n; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; @@ -194,7 +194,7 @@ do_rm (char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -214,7 +214,7 @@ do_chmod (int mode, char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -234,7 +234,7 @@ do_chown (int owner, int group, char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -254,7 +254,7 @@ do_exists (char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -270,7 +270,7 @@ do_is_file (char *path) int r; struct stat buf; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; @@ -294,7 +294,7 @@ do_write_file (char *path, char *content, int size) { int fd; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); if (size == 0) @@ -330,7 +330,7 @@ do_read_file (char *path, size_t *size_r) struct stat statbuf; char *r; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; @@ -444,7 +444,7 @@ do_zfile (char *method, char *path) FILE *fp; char line[256]; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); if (strcmp (method, "gzip") == 0 || strcmp (method, "compress") == 0) diff --git a/daemon/find.c b/daemon/find.c index c514177..950a0fc 100644 --- a/daemon/find.c +++ b/daemon/find.c @@ -59,7 +59,7 @@ do_find (char *dir) char *sysrootdir; char str[PATH_MAX]; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (dir, return NULL); sysrootdir = sysroot_path (dir); diff --git a/daemon/glob.c b/daemon/glob.c index 1c47ba5..40b7c50 100644 --- a/daemon/glob.c +++ b/daemon/glob.c @@ -31,7 +31,7 @@ do_glob_expand (char *pattern) int r; glob_t buf; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (pattern, return NULL); /* Required so chroot can be used. */ /* glob(3) in glibc never calls chdir, so this seems to be safe: */ diff --git a/daemon/grep.c b/daemon/grep.c index 19e4683..f0dbefd 100644 --- a/daemon/grep.c +++ b/daemon/grep.c @@ -35,7 +35,7 @@ grep (const char *prog, const char *flag, char *regex, char *path) int r; char **lines; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); /* Make the path relative to /sysroot. */ diff --git a/daemon/grub.c b/daemon/grub.c index 0a49c45..8476619 100644 --- a/daemon/grub.c +++ b/daemon/grub.c @@ -32,7 +32,7 @@ do_grub_install (char *root, char *device) char *err; char *buf; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (root, return -1); if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) { diff --git a/daemon/headtail.c b/daemon/headtail.c index bdd0f49..79dcfbb 100644 --- a/daemon/headtail.c +++ b/daemon/headtail.c @@ -35,7 +35,7 @@ headtail (const char *prog, const char *flag, const char *n, char *path) int r; char **lines; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); /* Make the path relative to /sysroot. */ diff --git a/daemon/hexdump.c b/daemon/hexdump.c index 27ea108..faf3dc5 100644 --- a/daemon/hexdump.c +++ b/daemon/hexdump.c @@ -32,7 +32,7 @@ do_hexdump (char *path) int r; char *out, *err; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); buf = sysroot_path (path); diff --git a/daemon/initrd.c b/daemon/initrd.c index e703481..c1c7ce0 100644 --- a/daemon/initrd.c +++ b/daemon/initrd.c @@ -37,7 +37,7 @@ do_initrd_list (char *path) int size = 0, alloc = 0; size_t len; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); /* "zcat /sysroot/ | cpio --quiet -it", but path must be quoted. */ diff --git a/daemon/inotify.c b/daemon/inotify.c index 2f22f52..96b9681 100644 --- a/daemon/inotify.c +++ b/daemon/inotify.c @@ -51,7 +51,7 @@ do_inotify_init (int max_events) { FILE *fp; - NEED_ROOT (-1); + NEED_ROOT (return -1); if (max_events < 0) { reply_with_error ("inotify_init: max_events < 0"); diff --git a/daemon/link.c b/daemon/link.c index bf616ed..9129b5c 100644 --- a/daemon/link.c +++ b/daemon/link.c @@ -34,7 +34,7 @@ do_readlink (char *path) char *ret; char link[PATH_MAX]; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; @@ -62,7 +62,7 @@ _link (const char *flag, int symbolic, const char *target, const char *linkname) char *buf_linkname; char *buf_target; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (linkname, return -1); /* but target does not need to be absolute */ diff --git a/daemon/ls.c b/daemon/ls.c index 8ae150b..8dba1bf 100644 --- a/daemon/ls.c +++ b/daemon/ls.c @@ -37,7 +37,7 @@ do_ls (char *path) DIR *dir; struct dirent *d; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; diff --git a/daemon/mknod.c b/daemon/mknod.c index ab799cd..a6e6eca 100644 --- a/daemon/mknod.c +++ b/daemon/mknod.c @@ -35,7 +35,7 @@ do_mknod (int mode, int devmajor, int devminor, char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; diff --git a/daemon/mount.c b/daemon/mount.c index 14e683a..4f60682 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -317,7 +317,7 @@ do_mount_loop (char *file, char *mountpoint) char *buf, *mp; char *error; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (file, return -1); /* We have to prefix /sysroot on both the filename and the mountpoint. */ @@ -355,7 +355,7 @@ do_mkmountpoint (char *path) { int r; - /* NEED_ROOT (-1); - we don't want this test for this call. */ + /* NEED_ROOT (return -1); - we don't want this test for this call. */ ABS_PATH (path, return -1); CHROOT_IN; @@ -380,7 +380,7 @@ do_rmmountpoint (char *path) { int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); CHROOT_IN; diff --git a/daemon/readdir.c b/daemon/readdir.c index f8f95d2..45256b2 100644 --- a/daemon/readdir.c +++ b/daemon/readdir.c @@ -36,7 +36,7 @@ do_readdir (char *path) struct dirent *d; int i; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); ret = malloc (sizeof *ret); diff --git a/daemon/realpath.c b/daemon/realpath.c index 18adc85..c081a45 100644 --- a/daemon/realpath.c +++ b/daemon/realpath.c @@ -32,7 +32,7 @@ do_realpath (char *path) { char *ret; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; diff --git a/daemon/scrub.c b/daemon/scrub.c index 2beaea3..5530c69 100644 --- a/daemon/scrub.c +++ b/daemon/scrub.c @@ -52,7 +52,7 @@ do_scrub_file (char *file) char *err; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (file, return -1); /* Make the path relative to /sysroot. */ @@ -82,7 +82,7 @@ do_scrub_freespace (char *dir) char *err; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (dir, return -1); /* Make the path relative to /sysroot. */ diff --git a/daemon/stat.c b/daemon/stat.c index da2d274..4845851 100644 --- a/daemon/stat.c +++ b/daemon/stat.c @@ -37,7 +37,7 @@ do_stat (char *path) guestfs_int_stat *ret; struct stat statbuf; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; @@ -79,7 +79,7 @@ do_lstat (char *path) guestfs_int_stat *ret; struct stat statbuf; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; @@ -121,7 +121,7 @@ do_statvfs (char *path) guestfs_int_statvfs *ret; struct statvfs statbuf; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; diff --git a/daemon/strings.c b/daemon/strings.c index 89e04a8..e5aefca 100644 --- a/daemon/strings.c +++ b/daemon/strings.c @@ -33,7 +33,7 @@ do_strings_e (char *encoding, char *path) char *out, *err; char **lines; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); buf = sysroot_path (path); diff --git a/daemon/swap.c b/daemon/swap.c index f7270f8..580482f 100644 --- a/daemon/swap.c +++ b/daemon/swap.c @@ -73,7 +73,7 @@ do_mkswap_file (char *path) char *buf; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); buf = sysroot_path (path); @@ -127,7 +127,7 @@ do_swapon_file (char *path) char *buf; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); buf = sysroot_path (path); @@ -147,7 +147,7 @@ do_swapoff_file (char *path) char *buf; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); buf = sysroot_path (path); diff --git a/daemon/tar.c b/daemon/tar.c index e1ff9b6..9d21e79 100644 --- a/daemon/tar.c +++ b/daemon/tar.c @@ -106,7 +106,7 @@ do_tar_out (char *dir) char *cmd; char buf[GUESTFS_MAX_CHUNK_SIZE]; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (dir, return -1); /* "tar -C /sysroot%s -cf - ." but we have to quote the dir. */ @@ -228,7 +228,7 @@ do_tgz_out (char *dir) char *cmd; char buf[GUESTFS_MAX_CHUNK_SIZE]; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (dir, return -1); /* "tar -C /sysroot%s -zcf - ." but we have to quote the dir. */ diff --git a/daemon/wc.c b/daemon/wc.c index 0917eb9..9720443 100644 --- a/daemon/wc.c +++ b/daemon/wc.c @@ -34,7 +34,7 @@ wc (char *flag, char *path) char *out, *err; int r; - NEED_ROOT (-1); + NEED_ROOT (return -1); ABS_PATH (path, return -1); /* Make the path relative to /sysroot. */ diff --git a/daemon/xattr.c b/daemon/xattr.c index 88947b2..d521321 100644 --- a/daemon/xattr.c +++ b/daemon/xattr.c @@ -116,7 +116,7 @@ getxattrs (char *path, int i, j; guestfs_int_xattr_list *r = NULL; - NEED_ROOT (NULL); + NEED_ROOT (return NULL); ABS_PATH (path, return NULL); CHROOT_IN; -- 1.8.3.1