Prechádzať zdrojové kódy

libcompat: Define lchown as chown if the former is not available

Instead of duplicating the code with chown calls when lchown is not
available, just map it with a macros.
Guillem Jover 16 rokov pred
rodič
commit
491b70bd37
2 zmenil súbory, kde vykonal 4 pridanie a 12 odobranie
  1. 4 0
      lib/compat/compat.h
  2. 0 12
      src/archives.c

+ 4 - 0
lib/compat/compat.h

@@ -42,6 +42,10 @@ extern "C" {
 #define strtoul strtol
 #define strtoul strtol
 #endif
 #endif
 
 
+#ifndef HAVE_LCHOWN
+#define lchown chown
+#endif
+
 #ifndef HAVE_VA_COPY
 #ifndef HAVE_VA_COPY
 #include <string.h>
 #include <string.h>
 #define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
 #define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))

+ 0 - 12
src/archives.c

@@ -694,17 +694,10 @@ int tarobject(struct TarInfo *ti) {
     if (symlink(ti->LinkName,fnamenewvb.buf))
     if (symlink(ti->LinkName,fnamenewvb.buf))
       ohshite(_("error creating symbolic link `%.255s'"),ti->Name);
       ohshite(_("error creating symbolic link `%.255s'"),ti->Name);
     debug(dbg_eachfiledetail,"tarobject SymbolicLink creating");
     debug(dbg_eachfiledetail,"tarobject SymbolicLink creating");
-#ifdef HAVE_LCHOWN
     if (lchown(fnamenewvb.buf,
     if (lchown(fnamenewvb.buf,
 	    nifd->namenode->statoverride ? nifd->namenode->statoverride->uid : ti->UserID,
 	    nifd->namenode->statoverride ? nifd->namenode->statoverride->uid : ti->UserID,
 	    nifd->namenode->statoverride ? nifd->namenode->statoverride->gid : ti->GroupID))
 	    nifd->namenode->statoverride ? nifd->namenode->statoverride->gid : ti->GroupID))
       ohshite(_("error setting ownership of symlink `%.255s'"),ti->Name);
       ohshite(_("error setting ownership of symlink `%.255s'"),ti->Name);
-#else
-    if (chown(fnamenewvb.buf,
-	    nifd->namenode->statoverride ? nifd->namenode->statoverride->uid : ti->UserID,
-	    nifd->namenode->statoverride ? nifd->namenode->statoverride->gid : ti->GroupID))
-      ohshite(_("error setting ownership of symlink `%.255s'"),ti->Name);
-#endif
     break;
     break;
   case Directory:
   case Directory:
     /* We've already checked for an existing directory. */
     /* We've already checked for an existing directory. */
@@ -758,13 +751,8 @@ int tarobject(struct TarInfo *ti) {
       symlinkfn.used= r; varbufaddc(&symlinkfn,0);
       symlinkfn.used= r; varbufaddc(&symlinkfn,0);
       if (symlink(symlinkfn.buf,fnametmpvb.buf))
       if (symlink(symlinkfn.buf,fnametmpvb.buf))
         ohshite(_("unable to make backup symlink for `%.255s'"),ti->Name);
         ohshite(_("unable to make backup symlink for `%.255s'"),ti->Name);
-#ifdef HAVE_LCHOWN
       if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
       if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
         ohshite(_("unable to chown backup symlink for `%.255s'"),ti->Name);
         ohshite(_("unable to chown backup symlink for `%.255s'"),ti->Name);
-#else
-      if (chown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
-        ohshite(_("unable to chown backup symlink for `%.255s'"),ti->Name);
-#endif
     } else {
     } else {
       debug(dbg_eachfiledetail,"tarobject nondirectory, `link' backup");
       debug(dbg_eachfiledetail,"tarobject nondirectory, `link' backup");
       if (link(fnamevb.buf,fnametmpvb.buf))
       if (link(fnamevb.buf,fnametmpvb.buf))