r23792: convert Samba4 to GPLv3
[kai/samba-autobuild/.git] / source4 / ntvfs / unixuid / vfs_unixuid.c
index 9d8b058b7acd0bb94416a2d486e328b1289496ed..74bc6309c18380be137e598004ffbb61e2dd5b08 100644 (file)
@@ -8,7 +8,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,
@@ -17,8 +17,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/>.
 */
 
 #include "includes.h"
@@ -26,6 +25,7 @@
 #include "system/passwd.h"
 #include "auth/auth.h"
 #include "ntvfs/ntvfs.h"
+#include "dsdb/samdb/samdb.h"
 
 struct unixuid_private {
        struct sidmap_context *sidmap;
@@ -155,7 +155,7 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs,
 
        token = req->session_info->security_token;
 
-       *sec = save_unix_security(req);
+       *sec = save_unix_security(ntvfs);
        if (*sec == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -165,6 +165,7 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs,
        } else {
                status = nt_token_to_unix_security(ntvfs, req, token, &newsec);
                if (!NT_STATUS_IS_OK(status)) {
+                       talloc_free(*sec);
                        return status;
                }
                if (private->last_sec_ctx) {
@@ -177,6 +178,7 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs,
 
        status = set_unix_security(newsec);
        if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(*sec);
                return status;
        }
 
@@ -190,8 +192,10 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs,
        NTSTATUS status2; \
        struct unix_sec_ctx *sec; \
        status = unixuid_setup_security(ntvfs, req, &sec); \
-       if (NT_STATUS_IS_OK(status)) status = ntvfs_next_##op args; \
+       NT_STATUS_NOT_OK_RETURN(status); \
+       status = ntvfs_next_##op args; \
        status2 = set_unix_security(sec); \
+       talloc_free(sec); \
        if (!NT_STATUS_IS_OK(status2)) smb_panic("Unable to reset security context"); \
 } while (0)
 
@@ -518,7 +522,7 @@ static NTSTATUS unixuid_cancel(struct ntvfs_module_context *ntvfs,
   change notify
 */
 static NTSTATUS unixuid_notify(struct ntvfs_module_context *ntvfs,
-                              struct ntvfs_request *req, struct smb_notify *info)
+                              struct ntvfs_request *req, union smb_notify *info)
 {
        NTSTATUS status;
 
@@ -587,7 +591,7 @@ static NTSTATUS unixuid_lpq(struct ntvfs_module_context *ntvfs,
 static NTSTATUS unixuid_search_first(struct ntvfs_module_context *ntvfs,
                                    struct ntvfs_request *req, union smb_search_first *io, 
                                    void *search_private, 
-                                   BOOL (*callback)(void *, union smb_search_data *))
+                                   BOOL (*callback)(void *, const union smb_search_data *))
 {
        NTSTATUS status;
 
@@ -600,7 +604,7 @@ static NTSTATUS unixuid_search_first(struct ntvfs_module_context *ntvfs,
 static NTSTATUS unixuid_search_next(struct ntvfs_module_context *ntvfs,
                                   struct ntvfs_request *req, union smb_search_next *io, 
                                   void *search_private, 
-                                  BOOL (*callback)(void *, union smb_search_data *))
+                                  BOOL (*callback)(void *, const union smb_search_data *))
 {
        NTSTATUS status;
 
@@ -638,6 +642,7 @@ NTSTATUS ntvfs_unixuid_init(void)
 {
        NTSTATUS ret;
        struct ntvfs_ops ops;
+       NTVFS_CURRENT_CRITICAL_SIZES(vers);
 
        ZERO_STRUCT(ops);
 
@@ -678,15 +683,15 @@ NTSTATUS ntvfs_unixuid_init(void)
 
        /* we register under all 3 backend types, as we are not type specific */
        ops.type = NTVFS_DISK;  
-       ret = ntvfs_register(&ops);
+       ret = ntvfs_register(&ops, &vers);
        if (!NT_STATUS_IS_OK(ret)) goto failed;
 
        ops.type = NTVFS_PRINT; 
-       ret = ntvfs_register(&ops);
+       ret = ntvfs_register(&ops, &vers);
        if (!NT_STATUS_IS_OK(ret)) goto failed;
 
        ops.type = NTVFS_IPC;   
-       ret = ntvfs_register(&ops);
+       ret = ntvfs_register(&ops, &vers);
        if (!NT_STATUS_IS_OK(ret)) goto failed;
        
 failed: