소스 검색

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 년 전
부모
커밋
491b70bd37
2개의 변경된 파일4개의 추가작업 그리고 12개의 파일을 삭제
  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
 #endif
 
+#ifndef HAVE_LCHOWN
+#define lchown chown
+#endif
+
 #ifndef HAVE_VA_COPY
 #include <string.h>
 #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))
       ohshite(_("error creating symbolic link `%.255s'"),ti->Name);
     debug(dbg_eachfiledetail,"tarobject SymbolicLink creating");
-#ifdef HAVE_LCHOWN
     if (lchown(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);
-#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;
   case Directory:
     /* We've already checked for an existing directory. */
@@ -758,13 +751,8 @@ int tarobject(struct TarInfo *ti) {
       symlinkfn.used= r; varbufaddc(&symlinkfn,0);
       if (symlink(symlinkfn.buf,fnametmpvb.buf))
         ohshite(_("unable to make backup symlink for `%.255s'"),ti->Name);
-#ifdef HAVE_LCHOWN
       if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
         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 {
       debug(dbg_eachfiledetail,"tarobject nondirectory, `link' backup");
       if (link(fnamevb.buf,fnametmpvb.buf))