Hi, just as an exercise what might be done to fix this: It would seem that the options are - not fix it (for now), - find something in current tar that works (I didn't), - switch off tar, - try to do something with tar (new upstream - vs. release: ugh - has a "apply to symlink target" --transform flag, but that also might need post-processing of symlinks at end of bootstrapping), - try to do some ld-preload(?) trickery for changing the way symlinks are read, - try to find some way to chroot before calling tar, one possibility would be copying required files to some temp CWD, make tar look there for the libraries, chrooting to the target and calling tar from (the unchanged) CWD, - add chroot option to tar (see patch).
It would seem that in terms of total invasiveness, the last option is minimal, but it might be unwise to add options without consulting upstream (however, it once upstream agrees to have an option with a given spec, one could implement that locally). Of course, the patch introduces new strings (translator-:( ), but they only shown with the new option. But then, this is just an idea, I'm sure you'll come up with a good, and probably better solution. Kind regards T. -- Thomas Viehmann, http://thomas.viehmann.net/
reverted: diff -u tar-1.20/src/list.c tar-1.20/src/list.c --- tar-1.20/src/list.c +++ tar-1.20/src/list.c @@ -72,6 +72,11 @@ name_gather (); open_archive (ACCESS_READ); + if (chroot_option) + { + sys_chroot(chroot_option); + } + do { prev_status = status; diff -u tar-1.20/debian/changelog tar-1.20/debian/changelog --- tar-1.20/debian/changelog +++ tar-1.20/debian/changelog @@ -1,3 +1,10 @@ +tar (1.20-1.1) unstable; urgency=low + + * Non-maintainer upload. + * Implement --chroot option for extraction. + + -- Thomas Viehmann <t...@beamnet.de> Thu, 05 Feb 2009 17:32:49 +0100 + tar (1.20-1) unstable; urgency=low * new upstream version only in patch2: unchanged: --- tar-1.20.orig/src/system.c +++ tar-1.20/src/system.c @@ -24,6 +24,11 @@ #if MSDOS +void +sys_chroot (char* dir) +{ +} + bool sys_get_archive_stat (void) { @@ -120,6 +125,21 @@ static struct stat archive_stat; /* stat block for archive file */ +void +sys_chroot (char* dir) +{ + if (chroot(dir) < 0) + { + int e = errno; + FATAL_ERROR ((0, e, _("Cannot chroot to %s"), dir)); + } + if (chdir("/") < 0) + { + int e = errno; + FATAL_ERROR ((0, e, _("Cannot chdir to '/' after chroot to %s"), dir)); + } +} + bool sys_get_archive_stat (void) { only in patch2: unchanged: --- tar-1.20.orig/src/tar.c +++ tar-1.20/src/tar.c @@ -252,6 +252,7 @@ CHECK_DEVICE_OPTION, CHECKPOINT_OPTION, CHECKPOINT_ACTION_OPTION, + CHROOT_OPTION, DELAY_DIRECTORY_RESTORE_OPTION, HARD_DEREFERENCE_OPTION, DELETE_OPTION, @@ -613,6 +614,8 @@ {"add-file", ARGP_KEY_ARG, N_("FILE"), 0, N_("add given FILE to the archive (useful if its name starts with a dash)"), GRID+1 }, + {"chroot", CHROOT_OPTION, N_("DIR"), 0, + N_("chroot to directory DIR for extraction"), GRID+1 }, {"directory", 'C', N_("DIR"), 0, N_("change to directory DIR"), GRID+1 }, {"files-from", 'T', N_("FILE"), 0, @@ -1590,6 +1593,10 @@ args->version_control_string = arg; break; + case CHROOT_OPTION: + chroot_option = arg; + break; + case DELAY_DIRECTORY_RESTORE_OPTION: delay_directory_restore_option = true; break; only in patch2: unchanged: --- tar-1.20.orig/src/common.h +++ tar-1.20/src/common.h @@ -141,6 +141,9 @@ /* Print a message if not all links are dumped */ GLOBAL int check_links_option; +/* Chroot option value. */ +GLOBAL char const *chroot_option; + /* Patterns that match file names to be excluded. */ GLOBAL struct exclude *excluded; @@ -293,6 +296,7 @@ /* Specified value or pattern. */ GLOBAL const char *volume_label_option; + /* Other global variables. */ @@ -700,6 +704,7 @@ /* Module system.c */ +void sys_chroot (char* dir); void sys_detect_dev_null_output (void); void sys_save_archive_dev_ino (void); void sys_drain_input_pipe (void); only in patch2: unchanged: