diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-04-27 10:39:24 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-04-27 10:39:24 +0100 |
commit | d638270b133f19ca7f9570e47a498381dc4cfe10 (patch) | |
tree | e68fe9edbdf2ffb97f348195503266829ca89207 /helper | |
parent | b6cce31ec4d8232d6400fe4fe915f53d285a3b4f (diff) | |
download | febootstrap-d638270b133f19ca7f9570e47a498381dc4cfe10.tar.gz febootstrap-d638270b133f19ca7f9570e47a498381dc4cfe10.tar.xz febootstrap-d638270b133f19ca7f9570e47a498381dc4cfe10.zip |
helper: Change to root directory before running find command.
Diffstat (limited to 'helper')
-rw-r--r-- | helper/ext2initrd.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/helper/ext2initrd.c b/helper/ext2initrd.c index f10aef2..3d765ca 100644 --- a/helper/ext2initrd.c +++ b/helper/ext2initrd.c @@ -26,6 +26,7 @@ #include <unistd.h> #include <dirent.h> #include <errno.h> +#include <assert.h> #include "error.h" #include "full-write.h" @@ -80,7 +81,18 @@ ext2_make_initrd (const char *modpath, const char *initrd) for (i = 0; kmods[i] != NULL; ++i) n += strlen (kmods[i]) + 16; cmd = malloc (n); - sprintf (cmd, "find '%s' ", modpath); + /* "cd /" here is for virt-v2v. It's cwd might not be accessible by + * the current user (because it sometimes sets its own uid) and the + * "find" command works by changing directory then changing back to + * the cwd. This results in a warning: + * + * find: failed to restore initial working directory: Permission denied + * + * Note this only works because "modpath" and temporary "dir" are + * currently guaranteed to be absolute paths, hence assertion. + */ + assert (modpath[0] == '/'); + sprintf (cmd, "cd / ; find '%s' ", modpath); for (i = 0; kmods[i] != NULL; ++i) { if (i > 0) strcat (cmd, "-o "); strcat (cmd, "-name '"); |