[Reproducible-commits] [dpkg] 04/06: Do not treat two symlinks to the same directory as a file conflict.

Holger Levsen holger at layer-acht.org
Tue May 3 08:42:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to annotated tag 1.13.26
in repository dpkg.

commit 4494c8f72c274818a5d2abcd4f366bda41ca8870
Author: Ian Jackson <iwj at ubuntu.com>
Date:   Sat Aug 11 06:53:55 2007 +0300

    Do not treat two symlinks to the same directory as a file conflict.
    
    If the package contains a symlink to a directory where the existing
    symlink on-disk points to the same place, do not consider it a file
    conflict.
---
 ChangeLog        |  6 ++++++
 debian/changelog |  6 ++++++
 src/archives.c   | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 2c49345..c83e998 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-01  Ian Jackson  <iwj at ubuntu.com>
+
+	* src/archives.c (linktosameexistingdir): New function.
+	(tarobject): Call linktosameexistingdir if the tarball and the on-disk
+	files are symlinks and ignore the symlink if it returns true.
+
 2008-12-01  Guillem Jover  <guillem at debian.org>
 
 	* configure.ac: Bump version to 1.13.26~.
diff --git a/debian/changelog b/debian/changelog
index 080c1ad..2eebf77 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,11 @@
 dpkg (1.13.26) UNRELEASED; urgency=low
 
+  [ Guillem Jover ]
+  * Do not consider it a file conflict if the package contains a symlink
+    to a directory where the existing symlink on-disk points to the
+    same place. Closes: #377682
+    Thanks to Ian Jackson.
+
   [ Updated dpkg translations ]
   * Romanian (Eddy Petrișor)
 
diff --git a/src/archives.c b/src/archives.c
index a0a5c35..f18b764 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -325,6 +325,46 @@ struct fileinlist *addfiletolist(struct tarcontext *tc,
   return nifd;
 }
 
+static int linktosameexistingdir(const struct TarInfo *ti,
+                                 const char *fname,
+                                 struct varbuf *symlinkfn) {
+  struct stat oldstab, newstab;
+  int statr;
+  const char *lastslash;
+
+  statr= stat(fname, &oldstab);
+  if (statr) {
+    if (!(errno == ENOENT || errno == ELOOP || errno == ENOTDIR))
+      ohshite("failed to stat (dereference) existing symlink `%.250s'", fname);
+    return 0;
+  }
+  if (!S_ISDIR(oldstab.st_mode)) return 0;
+
+  /* But is it to the same dir ? */
+  varbufreset(symlinkfn);
+  if (ti->LinkName[0] == '/') {
+    varbufaddstr(symlinkfn, instdir);
+  } else {
+    lastslash= strrchr(fname, '/');
+    assert(lastslash);
+    varbufaddbuf(symlinkfn, fname, (lastslash - fname) + 1);
+  }
+  varbufaddstr(symlinkfn, ti->LinkName);
+  varbufaddc(symlinkfn, 0);
+
+  statr= stat(symlinkfn->buf, &newstab);
+  if (statr) {
+    if (!(errno == ENOENT || errno == ELOOP || errno == ENOTDIR))
+      ohshite("failed to stat (dereference) proposed new symlink target"
+              " `%.250s' for symlink `%.250s'", symlinkfn->buf, fname);
+    return 0;
+  }
+  if (!S_ISDIR(newstab.st_mode)) return 0;
+  if (newstab.st_dev != oldstab.st_dev ||
+      newstab.st_ino != oldstab.st_ino) return 0;
+  return 1;
+}
+
 int tarobject(struct TarInfo *ti) {
   static struct varbuf conffderefn, hardlinkfn, symlinkfn;
   const char *usename;
@@ -422,6 +462,9 @@ int tarobject(struct TarInfo *ti) {
     if (!statr && S_ISDIR(stab.st_mode)) {
       debug(dbg_eachfiledetail,"tarobject SymbolicLink exists as directory");
       existingdirectory= 1;
+    } else if (!statr && S_ISLNK(stab.st_mode)) {
+      if (linktosameexistingdir(ti, fnamevb.buf, &symlinkfn))
+        existingdirectory= 1;
     }
     break;
   case Directory:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list