tags 561991 + patch thanks The attached patch should resolve debian bug 561991 by aligning the value stored by fakechrooted lstat() in buf.st_size with the length returned by the fakechroot'ed readlink().
This is the resolution option i numbered as "1" in my previous e-mail. hope this helps, --dkg
commit c4dda5ab637a9d9b38f1b9c09b5d23cb07a8a7f7 Author: Daniel Kahn Gillmor <d...@fifthhorseman.net> Date: Thu May 20 22:24:57 2010 -0400 aligning st_size in lstat() calls with size ultimately returned by fakechrooted readlink diff --git a/src/libfakechroot.c b/src/libfakechroot.c index 427dfde..1a6c93c 100644 --- a/src/libfakechroot.c +++ b/src/libfakechroot.c @@ -896,10 +896,19 @@ int __fxstatat64 (int ver, int dirfd, const char *pathname, struct stat64 *buf, /* #include <unistd.h> */ int __lxstat (int ver, const char *filename, struct stat *buf) { - char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH]; + char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH], tmp[FAKECHROOT_MAXPATH]; + int retval; + READLINK_TYPE_RETURN status; + const char* orig; + orig = filename; expand_chroot_path(filename, fakechroot_path, fakechroot_ptr, fakechroot_buf); if (next___lxstat == NULL) fakechroot_init(); - return next___lxstat(ver, filename, buf); + retval = next___lxstat(ver, filename, buf); + /* deal with http://bugs.debian.org/561991 */ + if ((buf->st_mode & S_IFMT) == S_IFLNK) + if ((status = readlink(orig, tmp, sizeof(tmp)-1)) != -1) + buf->st_size = status; + return retval; } #endif @@ -909,10 +918,19 @@ int __lxstat (int ver, const char *filename, struct stat *buf) /* #include <unistd.h> */ int __lxstat64 (int ver, const char *filename, struct stat64 *buf) { - char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH]; + char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH], tmp[FAKECHROOT_MAXPATH]; + int retval; + READLINK_TYPE_RETURN status; + const char* orig; + orig = filename; expand_chroot_path(filename, fakechroot_path, fakechroot_ptr, fakechroot_buf); if (next___lxstat64 == NULL) fakechroot_init(); - return next___lxstat64(ver, filename, buf); + retval = next___lxstat64(ver, filename, buf); + /* deal with http://bugs.debian.org/561991 */ + if ((buf->st_mode & S_IFMT) == S_IFLNK) + if ((status = readlink(orig, tmp, sizeof(tmp)-1)) != -1) + buf->st_size = status; + return retval; } #endif @@ -2203,10 +2221,19 @@ int lsetxattr (const char *path, const char *name, const void *value, size_t siz /* #include <unistd.h> */ int lstat (const char *file_name, struct stat *buf) { - char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH]; + char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH], tmp[FAKECHROOT_MAXPATH]; + int retval; + READLINK_TYPE_RETURN status; + const char* orig; + orig = file_name; expand_chroot_path(file_name, fakechroot_path, fakechroot_ptr, fakechroot_buf); if (next_lstat == NULL) fakechroot_init(); - return next_lstat(file_name, buf); + retval = next_lstat(file_name, buf); + /* deal with http://bugs.debian.org/561991 */ + if ((buf->st_mode & S_IFMT) == S_IFLNK) + if ((status = readlink(orig, tmp, sizeof(tmp)-1)) != -1) + buf->st_size = status; + return retval; } #endif @@ -2217,10 +2244,19 @@ int lstat (const char *file_name, struct stat *buf) /* #include <unistd.h> */ int lstat64 (const char *file_name, struct stat64 *buf) { - char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH]; + char *fakechroot_path, *fakechroot_ptr, fakechroot_buf[FAKECHROOT_MAXPATH], tmp[FAKECHROOT_MAXPATH]; + int retval; + READLINK_TYPE_RETURN status; + const char* orig; + orig = file_name; expand_chroot_path(file_name, fakechroot_path, fakechroot_ptr, fakechroot_buf); if (next_lstat64 == NULL) fakechroot_init(); - return next_lstat64(file_name, buf); + retval = next_lstat64(file_name, buf); + /* deal with http://bugs.debian.org/561991 */ + if ((buf->st_mode & S_IFMT) == S_IFLNK) + if ((status = readlink(orig, tmp, sizeof(tmp)-1)) != -1) + buf->st_size = status; + return retval; } #endif #endif
signature.asc
Description: OpenPGP digital signature