Fix bug #5083 (and duplicate bug #5084).
[samba.git] / source / modules / vfs_solarisacl.c
index 5e5e5978f240a42f820069a92da92f01c8ef4ea0..673b6805afb5c7fa0fd7023b5870ecd94b4c12f2 100644 (file)
@@ -5,7 +5,7 @@
 
    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 2 of the License, or
+   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,
@@ -14,8 +14,7 @@
    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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 
@@ -40,22 +39,22 @@ typedef o_mode_t SOLARIS_PERM_T;
 /* prototypes for private functions */
 
 static SOLARIS_ACL_T solaris_acl_init(int count);
-static BOOL smb_acl_to_solaris_acl(SMB_ACL_T smb_acl, 
+static bool smb_acl_to_solaris_acl(SMB_ACL_T smb_acl, 
                SOLARIS_ACL_T *solariacl, int *count, 
                SMB_ACL_TYPE_T type);
 static SMB_ACL_T solaris_acl_to_smb_acl(SOLARIS_ACL_T solarisacl, int count,
                SMB_ACL_TYPE_T type);
 static SOLARIS_ACL_TAG_T smb_tag_to_solaris_tag(SMB_ACL_TAG_T smb_tag);
 static SMB_ACL_TAG_T solaris_tag_to_smb_tag(SOLARIS_ACL_TAG_T solaris_tag);
-static BOOL solaris_add_to_acl(SOLARIS_ACL_T *solaris_acl, int *count,
+static bool solaris_add_to_acl(SOLARIS_ACL_T *solaris_acl, int *count,
                SOLARIS_ACL_T add_acl, int add_count, SMB_ACL_TYPE_T type);
-static BOOL solaris_acl_get_file(const char *name, SOLARIS_ACL_T *solarisacl, 
+static bool solaris_acl_get_file(const char *name, SOLARIS_ACL_T *solarisacl, 
                int *count);
-static BOOL solaris_acl_get_fd(int fd, SOLARIS_ACL_T *solarisacl, int *count);
-static BOOL solaris_acl_sort(SOLARIS_ACL_T acl, int count);
+static bool solaris_acl_get_fd(int fd, SOLARIS_ACL_T *solarisacl, int *count);
+static bool solaris_acl_sort(SOLARIS_ACL_T acl, int count);
 static SMB_ACL_PERM_T solaris_perm_to_smb_perm(const SOLARIS_PERM_T perm);
 static SOLARIS_PERM_T smb_perm_to_solaris_perm(const SMB_ACL_PERM_T perm);
-static BOOL solaris_acl_check(SOLARIS_ACL_T solaris_acl, int count);
+static bool solaris_acl_check(SOLARIS_ACL_T solaris_acl, int count);
 
 
 /* public functions - the api */
@@ -66,7 +65,7 @@ SMB_ACL_T solarisacl_sys_acl_get_file(vfs_handle_struct *handle,
 {
        SMB_ACL_T result = NULL;
        int count;
-       SOLARIS_ACL_T solaris_acl;
+       SOLARIS_ACL_T solaris_acl = NULL;
        
        DEBUG(10, ("solarisacl_sys_acl_get_file called for file '%s'.\n", 
                   path_p));
@@ -106,7 +105,7 @@ SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle,
 {
        SMB_ACL_T result = NULL;
        int count;
-       SOLARIS_ACL_T solaris_acl;
+       SOLARIS_ACL_T solaris_acl = NULL;
 
        DEBUG(10, ("entering solarisacl_sys_acl_get_fd.\n"));
 
@@ -129,7 +128,7 @@ SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle,
        DEBUG(10, ("solarisacl_sys_acl_get_fd %s.\n", 
                   ((result == NULL) ? "failed" : "succeeded")));
        SAFE_FREE(solaris_acl);
-       return NULL;
+       return result;
 }
 
 int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
@@ -139,7 +138,7 @@ int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
 {
        int ret = -1;
        struct stat s;
-       SOLARIS_ACL_T solaris_acl;
+       SOLARIS_ACL_T solaris_acl = NULL;
        int count;
        
        DEBUG(10, ("solarisacl_sys_acl_set_file called for file '%s'\n",
@@ -222,8 +221,8 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle,
                              files_struct *fsp,
                              int fd, SMB_ACL_T theacl)
 {
-       SOLARIS_ACL_T solaris_acl;
-       SOLARIS_ACL_T default_acl;
+       SOLARIS_ACL_T solaris_acl = NULL;
+       SOLARIS_ACL_T default_acl = NULL;
        int count, default_count;
        int ret = -1;
 
@@ -293,7 +292,7 @@ int solarisacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
 {
        SMB_ACL_T smb_acl;
        int ret = -1;
-       SOLARIS_ACL_T solaris_acl;
+       SOLARIS_ACL_T solaris_acl = NULL;
        int count;
 
        DEBUG(10, ("entering solarisacl_sys_acl_delete_def_file.\n"));
@@ -343,11 +342,11 @@ static SOLARIS_ACL_T solaris_acl_init(int count)
  * Convert the SMB acl to the ACCESS or DEFAULT part of a 
  * solaris ACL, as desired.
  */
-static BOOL smb_acl_to_solaris_acl(SMB_ACL_T smb_acl, 
+static bool smb_acl_to_solaris_acl(SMB_ACL_T smb_acl, 
                                   SOLARIS_ACL_T *solaris_acl, int *count, 
                                   SMB_ACL_TYPE_T type)
 {
-       BOOL ret = False;
+       bool ret = False;
        int i;
        int check_which, check_rc;
 
@@ -574,10 +573,10 @@ static SOLARIS_PERM_T smb_perm_to_solaris_perm(const SMB_ACL_PERM_T perm)
 }
 
 
-static BOOL solaris_acl_get_file(const char *name, SOLARIS_ACL_T *solaris_acl, 
+static bool solaris_acl_get_file(const char *name, SOLARIS_ACL_T *solaris_acl, 
                                 int *count)
 {
-       BOOL result = False;
+       bool result = False;
 
        DEBUG(10, ("solaris_acl_get_file called for file '%s'\n", name));
        
@@ -611,9 +610,9 @@ static BOOL solaris_acl_get_file(const char *name, SOLARIS_ACL_T *solaris_acl,
 }
 
 
-static BOOL solaris_acl_get_fd(int fd, SOLARIS_ACL_T *solaris_acl, int *count)
+static bool solaris_acl_get_fd(int fd, SOLARIS_ACL_T *solaris_acl, int *count)
 {
-       BOOL ret = False;
+       bool ret = False;
 
        DEBUG(10, ("entering solaris_acl_get_fd\n"));
 
@@ -662,7 +661,7 @@ static BOOL solaris_acl_get_fd(int fd, SOLARIS_ACL_T *solaris_acl, int *count)
  * should become necessary to add all of an ACL, one would have
  * to replace this parameter by another type.
  */
-static BOOL solaris_add_to_acl(SOLARIS_ACL_T *solaris_acl, int *count,
+static bool solaris_add_to_acl(SOLARIS_ACL_T *solaris_acl, int *count,
                               SOLARIS_ACL_T add_acl, int add_count, 
                               SMB_ACL_TYPE_T type)
 {
@@ -708,7 +707,7 @@ static BOOL solaris_add_to_acl(SOLARIS_ACL_T *solaris_acl, int *count,
  * happen aclsort() will fail and return an error and someone will
  * have to fix it...)
  */
-static BOOL solaris_acl_sort(SOLARIS_ACL_T solaris_acl, int count)
+static bool solaris_acl_sort(SOLARIS_ACL_T solaris_acl, int count)
 {
        int fixmask = (count <= 4);
 
@@ -725,7 +724,7 @@ static BOOL solaris_acl_sort(SOLARIS_ACL_T solaris_acl, int count)
  *   concrete error messages for debugging...
  *   (acl sort just says that the acl is invalid...)
  */
-static BOOL solaris_acl_check(SOLARIS_ACL_T solaris_acl, int count)
+static bool solaris_acl_check(SOLARIS_ACL_T solaris_acl, int count)
 {
        int check_rc;
        int check_which;
@@ -779,6 +778,7 @@ static vfs_op_tuple solarisacl_op_tuples[] = {
         SMB_VFS_LAYER_NOOP}
 };
 
+NTSTATUS vfs_solarisacl_init(void);
 NTSTATUS vfs_solarisacl_init(void)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "solarisacl",