r12608: Remove some unused #include lines.
[kamenim/samba.git] / source4 / torture / rpc / unixinfo.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for unixinfo rpc operations
4
5    Copyright (C) Volker Lendecke 2005
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_unixinfo.h"
24
25
26 /*
27   test the UidToSid interface
28 */
29 static BOOL test_uidtosid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
30 {
31         NTSTATUS status;
32         struct unixinfo_UidToSid r;
33
34         r.in.uid = 1000;
35
36         status = dcerpc_unixinfo_UidToSid(p, mem_ctx, &r);
37         if (!NT_STATUS_IS_OK(status)) {
38                 printf("UidToSid failed == %s\n", nt_errstr(status));
39                 return False;
40         }
41
42         return True;
43 }
44
45 static BOOL test_getpwuid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
46 {
47         uint64_t uids[512];
48         const int num_uids = sizeof(uids)/sizeof(uids[0]);
49         int i;
50         struct unixinfo_GetPWUid r;
51         NTSTATUS result;
52
53         for (i=0; i<num_uids; i++) {
54                 uids[i] = i;
55         }
56         
57         r.in.count = num_uids;
58         r.in.uids = uids;
59
60         result = dcerpc_unixinfo_GetPWUid(p, mem_ctx, &r);
61
62         return NT_STATUS_IS_OK(result);
63 }
64
65 BOOL torture_rpc_unixinfo(void)
66 {
67         NTSTATUS status;
68         struct dcerpc_pipe *p;
69         TALLOC_CTX *mem_ctx;
70         BOOL ret = True;
71
72         mem_ctx = talloc_init("torture_rpc_unixinfo");
73
74         status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_unixinfo);
75         if (!NT_STATUS_IS_OK(status)) {
76                 return False;
77         }
78
79         ret &= test_uidtosid(p, mem_ctx);
80         ret &= test_getpwuid(p, mem_ctx);
81
82         printf("\n");
83         
84         talloc_free(mem_ctx);
85
86         return ret;
87 }