This change from Matt makes rsync invent a simple ACL list for an
authorWayne Davison <wayned@samba.org>
Thu, 9 Mar 2006 15:47:12 +0000 (15:47 +0000)
committerWayne Davison <wayned@samba.org>
Thu, 9 Mar 2006 15:47:12 +0000 (15:47 +0000)
item that doesn't support ACLs.

acls.diff

index ca5629a..46714c2 100644 (file)
--- a/acls.diff
+++ b/acls.diff
@@ -32,7 +32,7 @@ ACLs to a non-ACL-supporting disk should complain.
  popt_OBJS=popt/findme.o  popt/popt.o  popt/poptconfig.o \
 --- old/acls.c
 +++ new/acls.c
-@@ -0,0 +1,1201 @@
+@@ -0,0 +1,1224 @@
 +/* -*- c-file-style: "linux" -*-
 +   Copyright (C) Andrew Tridgell 1996
 +   Copyright (C) Paul Mackerras 1996
@@ -372,6 +372,23 @@ ACLs to a non-ACL-supporting disk should complain.
 +              "unknown SMB_ACL_TYPE_T";
 +}
 +
++/*
++ * Overwrite racl with a new three-entry ACL from the given permissions.
++ */
++static void perms_to_acl(int perms, rsync_acl *racl)
++{
++      racl->count = 0;
++      expand_rsync_acl(racl);
++      racl->races[racl->count].tag_type = SMB_ACL_USER_OBJ;
++      racl->races[racl->count++].access = (perms >> 6) & 7;
++      expand_rsync_acl(racl);
++      racl->races[racl->count].tag_type = SMB_ACL_GROUP_OBJ;
++      racl->races[racl->count++].access = (perms >> 3) & 7;
++      expand_rsync_acl(racl);
++      racl->races[racl->count].tag_type = SMB_ACL_OTHER;
++      racl->races[racl->count++].access = (perms >> 0) & 7;
++}
++
 +/* Generate the ACL(s) for this flist entry;
 + * ACL(s) are either sent or cleaned-up by send_acl() below. */
 +
@@ -389,15 +406,21 @@ ACLs to a non-ACL-supporting disk should complain.
 +              SMB_ACL_T sacl;
 +              BOOL ok;
 +              *curr_racl = rsync_acl_initializer;
-+              if (!(sacl = sys_acl_get_file(fname, *type))) {
++              if ((sacl = sys_acl_get_file(fname, *type)) != 0) {
++                      ok = unpack_smb_acl(curr_racl, sacl);
++                      sys_acl_free_acl(sacl);
++                      if (!ok)
++                              return -1;
++              } else if (errno == ENOTSUP) {
++                      /* ACLs are not supported.  Invent an access ACL from
++                       * permissions; let the default ACL default to empty. */
++                      if (*type == SMB_ACL_TYPE_ACCESS)
++                              perms_to_acl(file->mode & ACCESSPERMS, curr_racl);
++              } else {
 +                      rprintf(FERROR, "send_acl: sys_acl_get_file(%s, %s): %s\n",
 +                              fname, str_acl_type(*type), strerror(errno));
 +                      return -1;
 +              }
-+              ok = unpack_smb_acl(curr_racl, sacl);
-+              sys_acl_free_acl(sacl);
-+              if (!ok)
-+                      return -1;
 +      }
 +      return 0;
 +}