1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00

Merge the rest of security.i into samba.dcerpc.security.

This commit is contained in:
Jelmer Vernooij 2008-12-21 18:25:59 +01:00
parent a925e22d7a
commit f2b4aa82e0
5 changed files with 35 additions and 3701 deletions

View File

@ -6,13 +6,3 @@ LIBSECURITY_OBJ_FILES = $(addprefix $(libclisrcdir)/security/, \
dom_sid.o access_check.o privilege.o sddl.o)
$(eval $(call proto_header_template,$(libclisrcdir)/security/proto.h,$(LIBSECURITY_OBJ_FILES:.o=.c)))
[PYTHON::swig_security]
LIBRARY_REALNAME = samba/_security.$(SHLIBEXT)
PRIVATE_DEPENDENCIES = LIBSECURITY
swig_security_OBJ_FILES = $(libclisrcdir)/security/security_wrap.o
$(eval $(call python_py_module_template,samba/security.py,$(libclisrcdir)/security/security.py))
$(swig_security_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)

View File

@ -1,102 +0,0 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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, see <http://www.gnu.org/licenses/>.
*/
%module(docstring="Security-related classes.",package="samba.security") security
%{
#include "includes.h"
#include "libcli/security/security.h"
typedef struct dom_sid dom_sid;
typedef struct security_token security_token;
typedef struct security_descriptor security_descriptor;
%}
%import "../lib/talloc/talloc.i"
%{
#include "libcli/util/pyerrors.h"
%}
%typemap(out,noblock=1) NTSTATUS {
if (NT_STATUS_IS_ERR($1)) {
PyErr_SetNTSTATUS($1);
SWIG_fail;
} else if ($result == NULL) {
$result = Py_None;
}
};
%typemap(in,noblock=1) NTSTATUS {
if (PyLong_Check($input))
$1 = NT_STATUS(PyLong_AsUnsignedLong($input));
else if (PyInt_Check($input))
$1 = NT_STATUS(PyInt_AsLong($input));
else {
PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
return NULL;
}
}
%import "stdint.i"
enum sec_privilege {
SEC_PRIV_SECURITY=1,
SEC_PRIV_BACKUP=2,
SEC_PRIV_RESTORE=3,
SEC_PRIV_SYSTEMTIME=4,
SEC_PRIV_SHUTDOWN=5,
SEC_PRIV_REMOTE_SHUTDOWN=6,
SEC_PRIV_TAKE_OWNERSHIP=7,
SEC_PRIV_DEBUG=8,
SEC_PRIV_SYSTEM_ENVIRONMENT=9,
SEC_PRIV_SYSTEM_PROFILE=10,
SEC_PRIV_PROFILE_SINGLE_PROCESS=11,
SEC_PRIV_INCREASE_BASE_PRIORITY=12,
SEC_PRIV_LOAD_DRIVER=13,
SEC_PRIV_CREATE_PAGEFILE=14,
SEC_PRIV_INCREASE_QUOTA=15,
SEC_PRIV_CHANGE_NOTIFY=16,
SEC_PRIV_UNDOCK=17,
SEC_PRIV_MANAGE_VOLUME=18,
SEC_PRIV_IMPERSONATE=19,
SEC_PRIV_CREATE_GLOBAL=20,
SEC_PRIV_ENABLE_DELEGATION=21,
SEC_PRIV_INTERACTIVE_LOGON=22,
SEC_PRIV_NETWORK_LOGON=23,
SEC_PRIV_REMOTE_INTERACTIVE_LOGON=24
};
%feature("docstring") random_sid "random_sid() -> sid\n" \
"Generate a random SID";
%inline %{
static struct dom_sid *random_sid(TALLOC_CTX *mem_ctx)
{
char *str = talloc_asprintf(mem_ctx, "S-1-5-21-%u-%u-%u",
(unsigned)generate_random(),
(unsigned)generate_random(),
(unsigned)generate_random());
return dom_sid_parse_talloc(mem_ctx, str);
}
%}
%rename(privilege_name) sec_privilege_name;
const char *sec_privilege_name(enum sec_privilege privilege);
%rename(privilege_id) sec_privilege_id;
enum sec_privilege sec_privilege_id(const char *name);

View File

@ -1,98 +0,0 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.36
#
# Don't modify this file, modify the SWIG interface instead.
"""
Security-related classes.
"""
import _security
import new
new_instancemethod = new.instancemethod
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'PySwigObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static) or hasattr(self,name):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError,name
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
import types
try:
_object = types.ObjectType
_newclass = 1
except AttributeError:
class _object : pass
_newclass = 0
del types
def _swig_setattr_nondynamic_method(set):
def set_attr(self,name,value):
if (name == "thisown"): return self.this.own(value)
if hasattr(self,name) or (name == "this"):
set(self,name,value)
else:
raise AttributeError("You cannot add attributes to %s" % self)
return set_attr
SEC_PRIV_SECURITY = _security.SEC_PRIV_SECURITY
SEC_PRIV_BACKUP = _security.SEC_PRIV_BACKUP
SEC_PRIV_RESTORE = _security.SEC_PRIV_RESTORE
SEC_PRIV_SYSTEMTIME = _security.SEC_PRIV_SYSTEMTIME
SEC_PRIV_SHUTDOWN = _security.SEC_PRIV_SHUTDOWN
SEC_PRIV_REMOTE_SHUTDOWN = _security.SEC_PRIV_REMOTE_SHUTDOWN
SEC_PRIV_TAKE_OWNERSHIP = _security.SEC_PRIV_TAKE_OWNERSHIP
SEC_PRIV_DEBUG = _security.SEC_PRIV_DEBUG
SEC_PRIV_SYSTEM_ENVIRONMENT = _security.SEC_PRIV_SYSTEM_ENVIRONMENT
SEC_PRIV_SYSTEM_PROFILE = _security.SEC_PRIV_SYSTEM_PROFILE
SEC_PRIV_PROFILE_SINGLE_PROCESS = _security.SEC_PRIV_PROFILE_SINGLE_PROCESS
SEC_PRIV_INCREASE_BASE_PRIORITY = _security.SEC_PRIV_INCREASE_BASE_PRIORITY
SEC_PRIV_LOAD_DRIVER = _security.SEC_PRIV_LOAD_DRIVER
SEC_PRIV_CREATE_PAGEFILE = _security.SEC_PRIV_CREATE_PAGEFILE
SEC_PRIV_INCREASE_QUOTA = _security.SEC_PRIV_INCREASE_QUOTA
SEC_PRIV_CHANGE_NOTIFY = _security.SEC_PRIV_CHANGE_NOTIFY
SEC_PRIV_UNDOCK = _security.SEC_PRIV_UNDOCK
SEC_PRIV_MANAGE_VOLUME = _security.SEC_PRIV_MANAGE_VOLUME
SEC_PRIV_IMPERSONATE = _security.SEC_PRIV_IMPERSONATE
SEC_PRIV_CREATE_GLOBAL = _security.SEC_PRIV_CREATE_GLOBAL
SEC_PRIV_ENABLE_DELEGATION = _security.SEC_PRIV_ENABLE_DELEGATION
SEC_PRIV_INTERACTIVE_LOGON = _security.SEC_PRIV_INTERACTIVE_LOGON
SEC_PRIV_NETWORK_LOGON = _security.SEC_PRIV_NETWORK_LOGON
SEC_PRIV_REMOTE_INTERACTIVE_LOGON = _security.SEC_PRIV_REMOTE_INTERACTIVE_LOGON
def random_sid(*args):
"""
random_sid() -> sid
Generate a random SID
"""
return _security.random_sid(*args)
privilege_name = _security.privilege_name
privilege_id = _security.privilege_id

File diff suppressed because it is too large Load Diff

View File

@ -270,3 +270,38 @@ static PyObject *py_token_new(PyTypeObject *self, PyObject *args, PyObject *kwar
NULL }, \
{ "set_privilege", (PyCFunction)py_token_set_privilege, METH_VARARGS, \
NULL },
static PyObject *py_privilege_name(PyObject *self, PyObject *args)
{
int priv;
if (!PyArg_ParseTuple(args, "i", &priv))
return NULL;
return PyString_FromString(sec_privilege_name(priv));
}
static PyObject *py_privilege_id(PyObject *self, PyObject *args)
{
char *name;
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
return PyInt_FromLong(sec_privilege_id(name));
}
static PyObject *py_random_sid(PyObject *self)
{
struct dom_sid *sid;
PyObject *ret;
char *str = talloc_asprintf(NULL, "S-1-5-21-%u-%u-%u",
(unsigned)generate_random(),
(unsigned)generate_random(),
(unsigned)generate_random());
sid = dom_sid_parse_talloc(NULL, str);
talloc_free(str);
ret = py_talloc_import(&PyDomSidType, sid);
talloc_free(sid);
return ret;
}