Remove duplicate Python bindings for dom_sid, security_descriptor and
[ira/wip.git] / source4 / libcli / security / security.i
1 /* 
2    Unix SMB/CIFS implementation.
3    Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
4    
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9    
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14    
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 %module(docstring="Security-related classes.",package="samba.security") security
20
21 %{
22 #include "includes.h"
23 #include "libcli/security/security.h"
24
25 typedef struct dom_sid dom_sid;
26 typedef struct security_token security_token;
27 typedef struct security_descriptor security_descriptor;
28 %}
29
30 %import "../lib/talloc/talloc.i"
31 %{
32 #include "libcli/util/pyerrors.h"
33 %}
34
35 %typemap(out,noblock=1) NTSTATUS {
36     if (NT_STATUS_IS_ERR($1)) {
37         PyErr_SetNTSTATUS($1);
38         SWIG_fail;
39     } else if ($result == NULL) {
40         $result = Py_None;
41     }
42 };
43
44 %typemap(in,noblock=1) NTSTATUS {
45         if (PyLong_Check($input))
46                 $1 = NT_STATUS(PyLong_AsUnsignedLong($input));
47         else if (PyInt_Check($input))
48                 $1 = NT_STATUS(PyInt_AsLong($input));
49         else {
50                 PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
51                 return NULL;
52         }
53 }
54
55 %import "stdint.i"
56
57 enum sec_privilege {
58         SEC_PRIV_SECURITY=1,
59         SEC_PRIV_BACKUP=2,
60         SEC_PRIV_RESTORE=3,
61         SEC_PRIV_SYSTEMTIME=4,
62         SEC_PRIV_SHUTDOWN=5,
63         SEC_PRIV_REMOTE_SHUTDOWN=6,
64         SEC_PRIV_TAKE_OWNERSHIP=7,
65         SEC_PRIV_DEBUG=8,
66         SEC_PRIV_SYSTEM_ENVIRONMENT=9,
67         SEC_PRIV_SYSTEM_PROFILE=10,
68         SEC_PRIV_PROFILE_SINGLE_PROCESS=11,
69         SEC_PRIV_INCREASE_BASE_PRIORITY=12,
70         SEC_PRIV_LOAD_DRIVER=13,
71         SEC_PRIV_CREATE_PAGEFILE=14,
72         SEC_PRIV_INCREASE_QUOTA=15,
73         SEC_PRIV_CHANGE_NOTIFY=16,
74         SEC_PRIV_UNDOCK=17,
75         SEC_PRIV_MANAGE_VOLUME=18,
76         SEC_PRIV_IMPERSONATE=19,
77         SEC_PRIV_CREATE_GLOBAL=20,
78         SEC_PRIV_ENABLE_DELEGATION=21,
79         SEC_PRIV_INTERACTIVE_LOGON=22,
80         SEC_PRIV_NETWORK_LOGON=23,
81         SEC_PRIV_REMOTE_INTERACTIVE_LOGON=24
82 };
83
84 %feature("docstring") random_sid "random_sid() -> sid\n" \
85          "Generate a random SID";
86
87 %inline %{
88 static struct dom_sid *random_sid(TALLOC_CTX *mem_ctx)
89 {
90     char *str = talloc_asprintf(mem_ctx, "S-1-5-21-%u-%u-%u", 
91                                 (unsigned)generate_random(), 
92                                 (unsigned)generate_random(), 
93                                 (unsigned)generate_random());
94
95         return dom_sid_parse_talloc(mem_ctx, str);
96 }
97 %}
98
99 %rename(privilege_name) sec_privilege_name;
100 const char *sec_privilege_name(enum sec_privilege privilege);
101 %rename(privilege_id) sec_privilege_id;
102 enum sec_privilege sec_privilege_id(const char *name);