summaryrefslogtreecommitdiffstats
path: root/helper
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-04-20 11:35:19 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-04-20 11:40:05 +0100
commitb6cce31ec4d8232d6400fe4fe915f53d285a3b4f (patch)
tree9ed21f594be9a5920be0a7f0cd9f9b8565ea4a5d /helper
parent6720ad28eddbcd671032c151f7219a35ba615b1b (diff)
downloadfebootstrap-b6cce31ec4d8232d6400fe4fe915f53d285a3b4f.tar.gz
febootstrap-b6cce31ec4d8232d6400fe4fe915f53d285a3b4f.tar.xz
febootstrap-b6cce31ec4d8232d6400fe4fe915f53d285a3b4f.zip
helper: Don't fail if objects are created in a symlinked dir (RHBZ#698089).
Diffstat (limited to 'helper')
-rw-r--r--helper/ext2.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/helper/ext2.c b/helper/ext2.c
index 2fc8036..705facc 100644
--- a/helper/ext2.c
+++ b/helper/ext2.c
@@ -402,6 +402,20 @@ ext2_file_stat (const char *orig_filename, const struct stat *statbuf)
dirname = strndup (orig_filename, p-orig_filename);
basename = p+1;
+ /* If the parent directory is a symlink to another directory, then
+ * we want to look up the target directory. (RHBZ#698089).
+ */
+ struct stat stat1, stat2;
+ if (lstat (dirname, &stat1) == 0 && S_ISLNK (stat1.st_mode) &&
+ stat (dirname, &stat2) == 0 && S_ISDIR (stat2.st_mode)) {
+ char *new_dirname = malloc (PATH_MAX+1);
+ ssize_t r = readlink (dirname, new_dirname, PATH_MAX+1);
+ if (r == -1)
+ error (EXIT_FAILURE, errno, "readlink: %s", orig_filename);
+ new_dirname[r] = '\0';
+ dirname = new_dirname;
+ }
+
/* Look up the parent directory. */
err = ext2fs_namei (fs, EXT2_ROOT_INO, EXT2_ROOT_INO, dirname, &dir_ino);
if (err != 0)