run this command:
git grep -l -w NEED_ROOT|xargs perl -pi -e \
's/(NEED_ROOT) \((.*?)\)/$1 (return $2)/'
32 files changed:
#ifdef HAVE_AUGEAS
char *buf;
#ifdef HAVE_AUGEAS
char *buf;
ABS_PATH (root, return -1);
if (aug) {
ABS_PATH (root, return -1);
if (aug) {
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
if (strcasecmp (csumtype, "crc") == 0)
ABS_PATH (path, return NULL);
if (strcasecmp (csumtype, "crc") == 0)
ABS_PATH (file1, return -1);
ABS_PATH (file2, return -1);
ABS_PATH (file1, return -1);
ABS_PATH (file2, return -1);
int dev_ok, dev_pts_ok, proc_ok, selinux_ok, sys_ok;
/* We need a root filesystem mounted to do this. */
int dev_ok, dev_pts_ok, proc_ok, selinux_ok, sys_ok;
/* We need a root filesystem mounted to do this. */
+ 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
/* Conveniently, argv is already a NULL-terminated argv-style array
* of parameters, so we can pass it straight in to our internal
ABS_PATH (src, return -1);
ABS_PATH (dest, return -1);
ABS_PATH (src, return -1);
ABS_PATH (dest, return -1);
if (strncmp ((path), "/dev/", 5) == 0) \
RESOLVE_DEVICE ((path), fail_stmt); \
else { \
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)
ABS_PATH ((path),fail_stmt); \
} \
} while (0)
+ NEED_ROOT (return NULL);
r = command (&out, &err, "df", NULL);
if (r == -1) {
r = command (&out, &err, "df", NULL);
if (r == -1) {
+ NEED_ROOT (return NULL);
r = command (&out, &err, "df", "-h", NULL);
if (r == -1) {
r = command (&out, &err, "df", "-h", NULL);
if (r == -1) {
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
if (strcmp (path, "/") == 0) {
ABS_PATH (path, return -1);
if (strcmp (path, "/") == 0) {
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
+ NEED_ROOT (return NULL);
ABS_PATH (template, return NULL);
CHROOT_IN;
ABS_PATH (template, return NULL);
CHROOT_IN;
char *out, *err;
char *buf;
char *out, *err;
char *buf;
ABS_PATH (path, return -1);
/* Make the path relative to /sysroot. */
ABS_PATH (path, return -1);
/* Make the path relative to /sysroot. */
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
int alloc, size, r, max;
char *buf, *buf2;
int alloc, size, r, max;
char *buf, *buf2;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
size_t len = 0;
ssize_t n;
size_t len = 0;
ssize_t n;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
if (size == 0)
ABS_PATH (path, return -1);
if (size == 0)
struct stat statbuf;
char *r;
struct stat statbuf;
char *r;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
FILE *fp;
char line[256];
FILE *fp;
char line[256];
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
if (strcmp (method, "gzip") == 0 || strcmp (method, "compress") == 0)
ABS_PATH (path, return NULL);
if (strcmp (method, "gzip") == 0 || strcmp (method, "compress") == 0)
char *sysrootdir;
char str[PATH_MAX];
char *sysrootdir;
char str[PATH_MAX];
+ NEED_ROOT (return NULL);
ABS_PATH (dir, return NULL);
sysrootdir = sysroot_path (dir);
ABS_PATH (dir, return NULL);
sysrootdir = sysroot_path (dir);
+ 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: */
ABS_PATH (pattern, return NULL); /* Required so chroot can be used. */
/* glob(3) in glibc never calls chdir, so this seems to be safe: */
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
/* Make the path relative to /sysroot. */
ABS_PATH (path, return NULL);
/* Make the path relative to /sysroot. */
ABS_PATH (root, return -1);
if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) {
ABS_PATH (root, return -1);
if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) {
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
/* Make the path relative to /sysroot. */
ABS_PATH (path, return NULL);
/* Make the path relative to /sysroot. */
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
buf = sysroot_path (path);
ABS_PATH (path, return NULL);
buf = sysroot_path (path);
int size = 0, alloc = 0;
size_t len;
int size = 0, alloc = 0;
size_t len;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
/* "zcat /sysroot/<path> | cpio --quiet -it", but path must be quoted. */
ABS_PATH (path, return NULL);
/* "zcat /sysroot/<path> | cpio --quiet -it", but path must be quoted. */
if (max_events < 0) {
reply_with_error ("inotify_init: max_events < 0");
if (max_events < 0) {
reply_with_error ("inotify_init: max_events < 0");
char *ret;
char link[PATH_MAX];
char *ret;
char link[PATH_MAX];
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
char *buf_linkname;
char *buf_target;
char *buf_linkname;
char *buf_target;
ABS_PATH (linkname, return -1);
/* but target does not need to be absolute */
ABS_PATH (linkname, return -1);
/* but target does not need to be absolute */
DIR *dir;
struct dirent *d;
DIR *dir;
struct dirent *d;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
char *buf, *mp;
char *error;
char *buf, *mp;
char *error;
ABS_PATH (file, return -1);
/* We have to prefix /sysroot on both the filename and the mountpoint. */
ABS_PATH (file, return -1);
/* We have to prefix /sysroot on both the filename and the mountpoint. */
- /* 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;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
ABS_PATH (path, return -1);
CHROOT_IN;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
ret = malloc (sizeof *ret);
ABS_PATH (path, return NULL);
ret = malloc (sizeof *ret);
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (file, return -1);
/* Make the path relative to /sysroot. */
ABS_PATH (file, return -1);
/* Make the path relative to /sysroot. */
ABS_PATH (dir, return -1);
/* Make the path relative to /sysroot. */
ABS_PATH (dir, return -1);
/* Make the path relative to /sysroot. */
guestfs_int_stat *ret;
struct stat statbuf;
guestfs_int_stat *ret;
struct stat statbuf;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
guestfs_int_stat *ret;
struct stat statbuf;
guestfs_int_stat *ret;
struct stat statbuf;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
guestfs_int_statvfs *ret;
struct statvfs statbuf;
guestfs_int_statvfs *ret;
struct statvfs statbuf;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;
char *out, *err;
char **lines;
char *out, *err;
char **lines;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
buf = sysroot_path (path);
ABS_PATH (path, return NULL);
buf = sysroot_path (path);
ABS_PATH (path, return -1);
buf = sysroot_path (path);
ABS_PATH (path, return -1);
buf = sysroot_path (path);
ABS_PATH (path, return -1);
buf = sysroot_path (path);
ABS_PATH (path, return -1);
buf = sysroot_path (path);
ABS_PATH (path, return -1);
buf = sysroot_path (path);
ABS_PATH (path, return -1);
buf = sysroot_path (path);
char *cmd;
char buf[GUESTFS_MAX_CHUNK_SIZE];
char *cmd;
char buf[GUESTFS_MAX_CHUNK_SIZE];
ABS_PATH (dir, return -1);
/* "tar -C /sysroot%s -cf - ." but we have to quote the dir. */
ABS_PATH (dir, return -1);
/* "tar -C /sysroot%s -cf - ." but we have to quote the dir. */
char *cmd;
char buf[GUESTFS_MAX_CHUNK_SIZE];
char *cmd;
char buf[GUESTFS_MAX_CHUNK_SIZE];
ABS_PATH (dir, return -1);
/* "tar -C /sysroot%s -zcf - ." but we have to quote the dir. */
ABS_PATH (dir, return -1);
/* "tar -C /sysroot%s -zcf - ." but we have to quote the dir. */
ABS_PATH (path, return -1);
/* Make the path relative to /sysroot. */
ABS_PATH (path, return -1);
/* Make the path relative to /sysroot. */
int i, j;
guestfs_int_xattr_list *r = NULL;
int i, j;
guestfs_int_xattr_list *r = NULL;
+ NEED_ROOT (return NULL);
ABS_PATH (path, return NULL);
CHROOT_IN;
ABS_PATH (path, return NULL);
CHROOT_IN;