r20875: Pass DCE/RPC server call arguments as a struct rather than as separate arguments.
[abartlet/samba.git/.git] / source3 / librpc / gen_ndr / srv_unixinfo.c
index 1c58e9440525994003e1a715bf087e1b173ffce5..3fbe8158707b48728c35d16be09152674a64d1ad 100644 (file)
@@ -21,8 +21,10 @@ static BOOL api_unixinfo_SidToUid(pipes_struct *p)
        }
        
        pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL)
+       if (pull == NULL) {
+               talloc_free(mem_ctx);
                return False;
+       }
        
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
        status = ndr_pull_unixinfo_SidToUid(pull, NDR_IN, &r);
@@ -31,7 +33,26 @@ static BOOL api_unixinfo_SidToUid(pipes_struct *p)
                return False;
        }
        
-       r.out.result = _unixinfo_SidToUid(p, r.in.sid, r.out.uid);
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_IN_DEBUG(unixinfo_SidToUid, &r);
+       
+       ZERO_STRUCT(r.out);
+       r.out.uid = talloc_zero(mem_ctx, uint64_t);
+       if (r.out.uid == NULL) {
+               talloc_free(mem_ctx);
+               return False;
+       }
+       
+       r.out.result = _unixinfo_SidToUid(p, &r);
+       
+       if (p->rng_fault_state) {
+               talloc_free(mem_ctx);
+               /* Return True here, srv_pipe_hnd.c will take care */
+               return True;
+       }
+       
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_OUT_DEBUG(unixinfo_SidToUid, &r);
        
        push = ndr_push_init_ctx(mem_ctx);
        if (push == NULL) {
@@ -46,7 +67,7 @@ static BOOL api_unixinfo_SidToUid(pipes_struct *p)
        }
        
        blob = ndr_push_blob(push);
-       if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
                talloc_free(mem_ctx);
                return False;
        }
@@ -71,8 +92,10 @@ static BOOL api_unixinfo_UidToSid(pipes_struct *p)
        }
        
        pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL)
+       if (pull == NULL) {
+               talloc_free(mem_ctx);
                return False;
+       }
        
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
        status = ndr_pull_unixinfo_UidToSid(pull, NDR_IN, &r);
@@ -81,7 +104,26 @@ static BOOL api_unixinfo_UidToSid(pipes_struct *p)
                return False;
        }
        
-       r.out.result = _unixinfo_UidToSid(p, r.in.uid, r.out.sid);
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_IN_DEBUG(unixinfo_UidToSid, &r);
+       
+       ZERO_STRUCT(r.out);
+       r.out.sid = talloc_zero(mem_ctx, struct dom_sid);
+       if (r.out.sid == NULL) {
+               talloc_free(mem_ctx);
+               return False;
+       }
+       
+       r.out.result = _unixinfo_UidToSid(p, &r);
+       
+       if (p->rng_fault_state) {
+               talloc_free(mem_ctx);
+               /* Return True here, srv_pipe_hnd.c will take care */
+               return True;
+       }
+       
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_OUT_DEBUG(unixinfo_UidToSid, &r);
        
        push = ndr_push_init_ctx(mem_ctx);
        if (push == NULL) {
@@ -96,7 +138,7 @@ static BOOL api_unixinfo_UidToSid(pipes_struct *p)
        }
        
        blob = ndr_push_blob(push);
-       if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
                talloc_free(mem_ctx);
                return False;
        }
@@ -121,8 +163,10 @@ static BOOL api_unixinfo_SidToGid(pipes_struct *p)
        }
        
        pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL)
+       if (pull == NULL) {
+               talloc_free(mem_ctx);
                return False;
+       }
        
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
        status = ndr_pull_unixinfo_SidToGid(pull, NDR_IN, &r);
@@ -131,7 +175,26 @@ static BOOL api_unixinfo_SidToGid(pipes_struct *p)
                return False;
        }
        
-       r.out.result = _unixinfo_SidToGid(p, r.in.sid, r.out.gid);
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_IN_DEBUG(unixinfo_SidToGid, &r);
+       
+       ZERO_STRUCT(r.out);
+       r.out.gid = talloc_zero(mem_ctx, uint64_t);
+       if (r.out.gid == NULL) {
+               talloc_free(mem_ctx);
+               return False;
+       }
+       
+       r.out.result = _unixinfo_SidToGid(p, &r);
+       
+       if (p->rng_fault_state) {
+               talloc_free(mem_ctx);
+               /* Return True here, srv_pipe_hnd.c will take care */
+               return True;
+       }
+       
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_OUT_DEBUG(unixinfo_SidToGid, &r);
        
        push = ndr_push_init_ctx(mem_ctx);
        if (push == NULL) {
@@ -146,7 +209,7 @@ static BOOL api_unixinfo_SidToGid(pipes_struct *p)
        }
        
        blob = ndr_push_blob(push);
-       if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
                talloc_free(mem_ctx);
                return False;
        }
@@ -171,8 +234,10 @@ static BOOL api_unixinfo_GidToSid(pipes_struct *p)
        }
        
        pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL)
+       if (pull == NULL) {
+               talloc_free(mem_ctx);
                return False;
+       }
        
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
        status = ndr_pull_unixinfo_GidToSid(pull, NDR_IN, &r);
@@ -181,7 +246,26 @@ static BOOL api_unixinfo_GidToSid(pipes_struct *p)
                return False;
        }
        
-       r.out.result = _unixinfo_GidToSid(p, r.in.gid, r.out.sid);
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_IN_DEBUG(unixinfo_GidToSid, &r);
+       
+       ZERO_STRUCT(r.out);
+       r.out.sid = talloc_zero(mem_ctx, struct dom_sid);
+       if (r.out.sid == NULL) {
+               talloc_free(mem_ctx);
+               return False;
+       }
+       
+       r.out.result = _unixinfo_GidToSid(p, &r);
+       
+       if (p->rng_fault_state) {
+               talloc_free(mem_ctx);
+               /* Return True here, srv_pipe_hnd.c will take care */
+               return True;
+       }
+       
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_OUT_DEBUG(unixinfo_GidToSid, &r);
        
        push = ndr_push_init_ctx(mem_ctx);
        if (push == NULL) {
@@ -196,7 +280,7 @@ static BOOL api_unixinfo_GidToSid(pipes_struct *p)
        }
        
        blob = ndr_push_blob(push);
-       if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
                talloc_free(mem_ctx);
                return False;
        }
@@ -221,8 +305,10 @@ static BOOL api_unixinfo_GetPWUid(pipes_struct *p)
        }
        
        pull = ndr_pull_init_blob(&blob, mem_ctx);
-       if (pull == NULL)
+       if (pull == NULL) {
+               talloc_free(mem_ctx);
                return False;
+       }
        
        pull->flags |= LIBNDR_FLAG_REF_ALLOC;
        status = ndr_pull_unixinfo_GetPWUid(pull, NDR_IN, &r);
@@ -231,8 +317,27 @@ static BOOL api_unixinfo_GetPWUid(pipes_struct *p)
                return False;
        }
        
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_IN_DEBUG(unixinfo_GetPWUid, &r);
+       
+       ZERO_STRUCT(r.out);
        r.out.count = r.in.count;
-       r.out.result = _unixinfo_GetPWUid(p, r.in.count, r.in.uids, r.out.infos);
+       r.out.infos = talloc_zero_array(mem_ctx, struct unixinfo_GetPWUidInfo, *r.in.count);
+       if (r.out.infos == NULL) {
+               talloc_free(mem_ctx);
+               return False;
+       }
+       
+       r.out.result = _unixinfo_GetPWUid(p, &r);
+       
+       if (p->rng_fault_state) {
+               talloc_free(mem_ctx);
+               /* Return True here, srv_pipe_hnd.c will take care */
+               return True;
+       }
+       
+       if (DEBUGLEVEL >= 10)
+               NDR_PRINT_OUT_DEBUG(unixinfo_GetPWUid, &r);
        
        push = ndr_push_init_ctx(mem_ctx);
        if (push == NULL) {
@@ -247,7 +352,7 @@ static BOOL api_unixinfo_GetPWUid(pipes_struct *p)
        }
        
        blob = ndr_push_blob(push);
-       if (!prs_init_data_blob(&p->out_data.rdata, &blob, p->mem_ctx)) {
+       if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32)blob.length)) {
                talloc_free(mem_ctx);
                return False;
        }
@@ -274,7 +379,7 @@ void unixinfo_get_pipe_fns(struct api_struct **fns, int *n_fns)
        *n_fns = sizeof(api_unixinfo_cmds) / sizeof(struct api_struct);
 }
 
-NTSTATUS rpc_netdfs_init(void)
+NTSTATUS rpc_unixinfo_init(void)
 {
        return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "unixinfo", "unixinfo", api_unixinfo_cmds, sizeof(api_unixinfo_cmds) / sizeof(struct api_struct));
 }