Fixed a thinko and a typo in the --append option.
[rsync.git] / acls.c
diff --git a/acls.c b/acls.c
index 04cff88adfc084c535f4ce6e88dd6b6c6706f5a9..d9023e2f4bf68bbad1915ae0d0fb2ccc73f80d56 100644 (file)
--- a/acls.c
+++ b/acls.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 1996 Andrew Tridgell
  * Copyright (C) 1996 Paul Mackerras
- * Copyright (C) 2006 Wayne Davison
+ * Copyright (C) 2006-2008 Wayne Davison
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -92,9 +92,19 @@ static item_list default_acl_list = EMPTY_ITEM_LIST;
 
 static const char *str_acl_type(SMB_ACL_TYPE_T type)
 {
-       return type == SMB_ACL_TYPE_ACCESS ? "SMB_ACL_TYPE_ACCESS"
-            : type == SMB_ACL_TYPE_DEFAULT ? "SMB_ACL_TYPE_DEFAULT"
-            : "unknown SMB_ACL_TYPE_T";
+       switch (type) {
+       case SMB_ACL_TYPE_ACCESS:
+#ifdef HAVE_OSX_ACLS
+               return "ACL_TYPE_EXTENDED";
+#else
+               return "ACL_TYPE_ACCESS";
+#endif
+       case SMB_ACL_TYPE_DEFAULT:
+               return "ACL_TYPE_DEFAULT";
+       default:
+               break;
+       }
+       return "unknown ACL type!";
 }
 
 static int calc_sacl_entries(const rsync_acl *racl)
@@ -300,7 +310,7 @@ static BOOL unpack_smb_acl(SMB_ACL_T sacl, rsync_acl *racl)
                ida->access = access;
        }
        if (rc) {
-               rsyserr(FERROR, errno, "unpack_smb_acl: %s()", errfun);
+               rsyserr(FERROR_XFER, errno, "unpack_smb_acl: %s()", errfun);
                rsync_acl_free(racl);
                return False;
        }
@@ -356,7 +366,7 @@ static BOOL unpack_smb_acl(SMB_ACL_T sacl, rsync_acl *racl)
 static int store_access_in_entry(uint32 access, SMB_ACL_ENTRY_T entry)
 {
        if (sys_acl_set_access_bits(entry, access)) {
-               rsyserr(FERROR, errno, "store_access_in_entry sys_acl_set_access_bits()");
+               rsyserr(FERROR_XFER, errno, "store_access_in_entry sys_acl_set_access_bits()");
                return -1;
        }
        return 0;
@@ -375,7 +385,7 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_acl, const rsync_acl *racl)
        SMB_ACL_ENTRY_T entry;
 
        if (!(*smb_acl = sys_acl_init(calc_sacl_entries(racl)))) {
-               rsyserr(FERROR, errno, "pack_smb_acl: sys_acl_init()");
+               rsyserr(FERROR_XFER, errno, "pack_smb_acl: sys_acl_init()");
                return False;
        }
 
@@ -424,14 +434,14 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_acl, const rsync_acl *racl)
 
 #ifdef DEBUG
        if (sys_acl_valid(*smb_acl) < 0)
-               rprintf(FERROR, "pack_smb_acl: warning: system says the ACL I packed is invalid\n");
+               rprintf(FERROR_XFER, "pack_smb_acl: warning: system says the ACL I packed is invalid\n");
 #endif
 
        return True;
 
   error_exit:
        if (errfun) {
-               rsyserr(FERROR, errno, "pack_smb_acl %s()", errfun);
+               rsyserr(FERROR_XFER, errno, "pack_smb_acl %s()", errfun);
        }
        sys_acl_free_acl(*smb_acl);
        return False;
@@ -514,7 +524,7 @@ static int get_rsync_acl(const char *fname, rsync_acl *racl,
                if (type == SMB_ACL_TYPE_ACCESS)
                        rsync_acl_fake_perms(racl, mode);
        } else {
-               rsyserr(FERROR, errno, "get_acl: sys_acl_get_file(%s, %s)",
+               rsyserr(FERROR_XFER, errno, "get_acl: sys_acl_get_file(%s, %s)",
                        fname, str_acl_type(type));
                return -1;
        }
@@ -556,7 +566,7 @@ static void send_ida_entries(const ida_entries *idal, int f)
 
        for (ida = idal->idas; count--; ida++) {
                uint32 xbits = ida->access << 2;
-               char *name;
+               const char *name;
                if (ida->access & NAME_IS_USER) {
                        xbits |= XFLAG_NAME_IS_USER;
                        name = add_uid(ida->id);
@@ -655,7 +665,7 @@ static uint32 recv_acl_access(uchar *name_follows_ptr, int f)
                        access |= NAME_IS_USER;
        } else if (am_root >= 0 && access & ~SMB_ACL_VALID_OBJ_BITS) {
          value_error:
-               rprintf(FERROR, "recv_acl_access: value out of range: %x\n",
+               rprintf(FERROR_XFER, "recv_acl_access: value out of range: %x\n",
                        access);
                exit_cleanup(RERR_STREAMIO);
        }
@@ -710,7 +720,7 @@ static int recv_rsync_acl(item_list *racl_list, SMB_ACL_TYPE_T type, int f)
        int ndx = read_varint(f);
 
        if (ndx < 0 || (size_t)ndx > racl_list->count) {
-               rprintf(FERROR, "recv_acl_index: %s ACL index %d > %d\n",
+               rprintf(FERROR_XFER, "recv_acl_index: %s ACL index %d > %d\n",
                        str_acl_type(type), ndx, (int)racl_list->count);
                exit_cleanup(RERR_STREAMIO);
        }
@@ -855,7 +865,7 @@ static mode_t change_sacl_perms(SMB_ACL_T sacl, rsync_acl *racl, mode_t old_mode
        if (rc) {
          error_exit:
                if (errfun) {
-                       rsyserr(FERROR, errno, "change_sacl_perms: %s()",
+                       rsyserr(FERROR_XFER, errno, "change_sacl_perms: %s()",
                                errfun);
                }
                return (mode_t)~0;
@@ -887,7 +897,7 @@ static int set_rsync_acl(const char *fname, acl_duo *duo_item,
 #endif
                        rc = sys_acl_delete_def_file(fname);
                if (rc < 0) {
-                       rsyserr(FERROR, errno, "set_acl: sys_acl_delete_def_file(%s)",
+                       rsyserr(FERROR_XFER, errno, "set_acl: sys_acl_delete_def_file(%s)",
                                fname);
                        return -1;
                }
@@ -932,8 +942,8 @@ static int set_rsync_acl(const char *fname, acl_duo *duo_item,
                }
 #endif
                if (sys_acl_set_file(fname, type, duo_item->sacl) < 0) {
-                       rsyserr(FERROR, errno, "set_acl: sys_acl_set_file(%s, %s)",
-                       fname, str_acl_type(type));
+                       rsyserr(FERROR_XFER, errno, "set_acl: sys_acl_set_file(%s, %s)",
+                               fname, str_acl_type(type));
                        return -1;
                }
                if (type == SMB_ACL_TYPE_ACCESS)
@@ -1052,7 +1062,8 @@ int default_perms_for_dir(const char *dir)
                        }
                        /* Otherwise fall through. */
                default:
-                       rprintf(FERROR, "default_perms_for_dir: sys_acl_get_file(%s, %s): %s, falling back on umask\n",
+                       rprintf(FWARNING,
+                               "default_perms_for_dir: sys_acl_get_file(%s, %s): %s, falling back on umask\n",
                                dir, str_acl_type(SMB_ACL_TYPE_DEFAULT), strerror(errno));
                }
                return perms;
@@ -1063,7 +1074,7 @@ int default_perms_for_dir(const char *dir)
        ok = unpack_smb_acl(sacl, &racl);
        sys_acl_free_acl(sacl);
        if (!ok) {
-               rprintf(FERROR, "default_perms_for_dir: unpack_smb_acl failed, falling back on umask\n");
+               rprintf(FWARNING, "default_perms_for_dir: unpack_smb_acl failed, falling back on umask\n");
                return perms;
        }