2 Unix SMB/CIFS implementation.
3 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
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.
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.
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/>.
19 %module(docstring="Security-related classes.",package="samba.security") security
23 #include "libcli/security/security.h"
25 typedef struct dom_sid dom_sid;
26 typedef struct security_token security_token;
27 typedef struct security_descriptor security_descriptor;
30 %import "../lib/talloc/talloc.i"
32 #include "libcli/util/pyerrors.h"
35 %typemap(out,noblock=1) NTSTATUS {
36 if (NT_STATUS_IS_ERR($1)) {
37 PyErr_SetNTSTATUS($1);
39 } else if ($result == NULL) {
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));
50 PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
61 SEC_PRIV_SYSTEMTIME=4,
63 SEC_PRIV_REMOTE_SHUTDOWN=6,
64 SEC_PRIV_TAKE_OWNERSHIP=7,
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,
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
84 %feature("docstring") random_sid "random_sid() -> sid\n" \
85 "Generate a random SID";
88 static struct dom_sid *random_sid(TALLOC_CTX *mem_ctx)
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());
95 return dom_sid_parse_talloc(mem_ctx, str);
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);