torture3: Fix CID 1435119 Error handling issues (CHECKED_RETURN)
[samba.git] / source3 / lib / sysacls.c
index 2ec3d68a85b13093ba5c20df30dd9daae2125f6e..c80f8f30c904a88422994c37c4246e23d24ee453 100644 (file)
@@ -1,20 +1,20 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Samba system utilities for ACL support.
    Copyright (C) Jeremy Allison 2000.
    Copyright (C) Volker Lendecke 2006
    Copyright (C) Michael Adam 2006,2008
-   
+
    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
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -104,14 +104,14 @@ void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d)
 {
        if (entry_d->a_type == SMB_ACL_USER) {
                return &entry_d->info.user.uid;
-               }
+       }
 
        if (entry_d->a_type == SMB_ACL_GROUP) {
                return &entry_d->info.group.gid;
        }
 
        errno = EINVAL;
-               return NULL;
+       return NULL;
 }
 
 int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d)
@@ -127,15 +127,15 @@ int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm)
            && perm != SMB_ACL_EXECUTE) {
                errno = EINVAL;
                return -1;
-               }
+       }
+
        if (permset_d == NULL) {
                errno = EINVAL;
                return -1;
        }
 
        *permset_d |= perm;
+
        return 0;
 }
 
@@ -183,10 +183,11 @@ char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p)
                                         ap->a_type);
                                tag = tagbuf;
                                break;
+
                        case SMB_ACL_USER:
                                id = uidtoname(ap->info.user.uid);
-                               /* FALL TROUGH */
+
+                               FALL_THROUGH;
                        case SMB_ACL_USER_OBJ:
                                tag = "user";
                                break;
@@ -199,7 +200,8 @@ char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p)
                                } else {
                                        id = gr->gr_name;
                                }
-                               /* FALL TROUGH */
+
+                               FALL_THROUGH;
                        case SMB_ACL_GROUP_OBJ:
                                tag = "group";
                                break;
@@ -255,7 +257,7 @@ SMB_ACL_T sys_acl_init(TALLOC_CTX *mem_ctx)
                errno = ENOMEM;
                return NULL;
        }
+
        a->count = 0;
        a->next = -1;
 
@@ -319,7 +321,7 @@ int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p)
        if (entry_d->a_type == SMB_ACL_USER) {
                entry_d->info.user.uid = *((uid_t *)qual_p);
                return 0;
-               }
+       }
        if (entry_d->a_type == SMB_ACL_GROUP) {
                entry_d->info.group.gid = *((gid_t *)qual_p);
                return 0;
@@ -337,7 +339,7 @@ int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d)
        }
 
        entry_d->a_perm = *permset_d;
+
        return 0;
 }
 
@@ -358,26 +360,30 @@ int sys_acl_valid(SMB_ACL_T acl_d)
  * sys_acl_delete_def_file are to be redirected to the default
  * statically-bound acl vfs module, but they are replacable.
  */
+
 #if defined(HAVE_POSIX_ACLS)
-SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, 
-                          const char *path_p, SMB_ACL_TYPE_T type, TALLOC_CTX *mem_ctx)
+
+SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       TALLOC_CTX *mem_ctx)
 {
-       return posixacl_sys_acl_get_file(handle, path_p, type, mem_ctx);
+       return posixacl_sys_acl_get_file(handle, smb_fname, type, mem_ctx);
 }
+
 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, TALLOC_CTX *mem_ctx)
 {
        return posixacl_sys_acl_get_fd(handle, fsp, mem_ctx);
 }
+
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return posixacl_sys_acl_set_file(handle, name, type, acl_d);
+       return posixacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
+
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
                   SMB_ACL_T acl_d)
 {
@@ -385,18 +391,19 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_delete_def_file(vfs_handle_struct *handle,
-                           const char *path)
+                       const struct smb_filename *smb_fname)
 {
-       return posixacl_sys_acl_delete_def_file(handle, path);
+       return posixacl_sys_acl_delete_def_file(handle, smb_fname);
 }
 
 #elif defined(HAVE_AIX_ACLS)
 
 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
-                          const char *path_p, SMB_ACL_TYPE_T type,
-                          TALLOC_CTX *mem_ctx)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       TALLOC_CTX *mem_ctx)
 {
-       return aixacl_sys_acl_get_file(handle, path_p, type, mem_ctx);
+       return aixacl_sys_acl_get_file(handle, smb_fname, type, mem_ctx);
 }
 
 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -406,9 +413,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return aixacl_sys_acl_set_file(handle, name, type, acl_d);
+       return aixacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -418,18 +427,19 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_delete_def_file(vfs_handle_struct *handle,
-                           const char *path)
+                               const struct smb_filename *smb_fname)
 {
-       return aixacl_sys_acl_delete_def_file(handle, path);
+       return aixacl_sys_acl_delete_def_file(handle, smb_fname);
 }
 
 #elif defined(HAVE_TRU64_ACLS)
+
 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
-                          const char *path_p, SMB_ACL_TYPE_T type,
-                          TALLOC_CTX *mem_ctx)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       TALLOC_CTX *mem_ctx)
 {
-       return tru64acl_sys_acl_get_file(handle, path_p, type,
+       return tru64acl_sys_acl_get_file(handle, smb_fname, type,
                                         mem_ctx);
 }
 
@@ -440,9 +450,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return tru64acl_sys_acl_set_file(handle, name, type, acl_d);
+       return tru64acl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -452,18 +464,19 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_delete_def_file(vfs_handle_struct *handle,
-                           const char *path)
+                               const struct smb_filename *smb_fname)
 {
-       return tru64acl_sys_acl_delete_def_file(handle, path);
+       return tru64acl_sys_acl_delete_def_file(handle, smb_fname);
 }
 
 #elif defined(HAVE_SOLARIS_UNIXWARE_ACLS)
 
 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
-                          const char *path_p, SMB_ACL_TYPE_T type,
-                          TALLOC_CTX *mem_ctx)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       TALLOC_CTX *mem_ctx)
 {
-       return solarisacl_sys_acl_get_file(handle, path_p, type,
+       return solarisacl_sys_acl_get_file(handle, smb_fname, type,
                                           mem_ctx);
 }
 
@@ -475,9 +488,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return solarisacl_sys_acl_set_file(handle, name, type, acl_d);
+       return solarisacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -487,18 +502,19 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_delete_def_file(vfs_handle_struct *handle,
-                           const char *path)
+                               const struct smb_filename *smb_fname)
 {
-       return solarisacl_sys_acl_delete_def_file(handle, path);
+       return solarisacl_sys_acl_delete_def_file(handle, smb_fname);
 }
 
 #elif defined(HAVE_HPUX_ACLS)
 
 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
-                          const char *path_p, SMB_ACL_TYPE_T type,
-                          TALLOC_CTX *mem_ctx)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       TALLOC_CTX *mem_ctx)
 {
-       return hpuxacl_sys_acl_get_file(handle, path_p, type, mem_ctx);
+       return hpuxacl_sys_acl_get_file(handle, smb_fname, type, mem_ctx);
 }
 
 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -508,9 +524,11 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
-       return hpuxacl_sys_acl_set_file(handle, name, type, acl_d);
+       return hpuxacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
 }
 
 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
@@ -520,16 +538,17 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_delete_def_file(vfs_handle_struct *handle,
-                           const char *path)
+                               const struct smb_filename *smb_fname)
 {
-       return hpuxacl_sys_acl_delete_def_file(handle, path);
+       return hpuxacl_sys_acl_delete_def_file(handle, smb_fname);
 }
 
 #else /* No ACLs. */
 
 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
-                          const char *path_p, SMB_ACL_TYPE_T type,
-                          TALLOC_CTX *mem_ctx)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       TALLOC_CTX *mem_ctx)
 {
 #ifdef ENOTSUP
        errno = ENOTSUP;
@@ -551,7 +570,9 @@ SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_set_file(vfs_handle_struct *handle,
-                    const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
+                       const struct smb_filename *smb_fname,
+                       SMB_ACL_TYPE_T type,
+                       SMB_ACL_T acl_d)
 {
 #ifdef ENOTSUP
        errno = ENOTSUP;
@@ -573,7 +594,7 @@ int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 int sys_acl_delete_def_file(vfs_handle_struct *handle,
-                           const char *path)
+                               const struct smb_filename *smb_fname)
 {
 #ifdef ENOTSUP
        errno = ENOTSUP;