python/py_common.h

ソースコードを見る。

関数

PyObject * py_werror_tuple (WERROR werror)
PyObject * py_ntstatus_tuple (NTSTATUS ntstatus)
void py_samba_init (void)
PyObject * get_debuglevel (PyObject *self, PyObject *args)
PyObject * set_debuglevel (PyObject *self, PyObject *args)
PyObject * py_setup_logging (PyObject *self, PyObject *args, PyObject *kw)
BOOL py_parse_creds (PyObject *creds, char **username, char **domain, char **password, char **errstr)
cli_stateopen_pipe_creds (char *server, PyObject *creds, int pipe_idx, char **errstr)
BOOL get_level_value (PyObject *dict, uint32 *level)
BOOL py_from_SID (PyObject **obj, DOM_SID *sid)
BOOL py_to_SID (DOM_SID *sid, PyObject *obj)
BOOL py_from_ACE (PyObject **dict, SEC_ACE *ace)
BOOL py_to_ACE (SEC_ACE *ace, PyObject *dict)
BOOL py_from_ACL (PyObject **dict, SEC_ACL *acl)
BOOL py_to_ACL (SEC_ACL *acl, PyObject *dict, TALLOC_CTX *mem_ctx)
BOOL py_from_SECDESC (PyObject **dict, SEC_DESC *sd)
BOOL py_to_SECDESC (SEC_DESC **sd, PyObject *dict, TALLOC_CTX *mem_ctx)


関数

PyObject* py_werror_tuple ( WERROR  werror  ) 

py_common.c25 行で定義されています。

参照先 dos_errstr()werror.

参照元 spoolss_addprinterdriver()spoolss_enumports()spoolss_enumprinterdrivers()spoolss_enumprinters()spoolss_getprinterdriverdir()spoolss_hnd_addform()spoolss_hnd_deleteform()spoolss_hnd_deleteprinterdata()spoolss_hnd_deleteprinterdataex()spoolss_hnd_enddocprinter()spoolss_hnd_endpageprinter()spoolss_hnd_enumforms()spoolss_hnd_enumjobs()spoolss_hnd_enumprinterdata()spoolss_hnd_enumprinterdataex()spoolss_hnd_enumprinterkey()spoolss_hnd_getform()spoolss_hnd_getjob()spoolss_hnd_getprinter()spoolss_hnd_getprinterdata()spoolss_hnd_getprinterdataex()spoolss_hnd_getprinterdriver()spoolss_hnd_setform()spoolss_hnd_setjob()spoolss_hnd_setprinter()spoolss_hnd_setprinterdata()spoolss_hnd_setprinterdataex()spoolss_hnd_startdocprinter()spoolss_hnd_startpageprinter()spoolss_hnd_writeprinter()spoolss_openprinter()srvsvc_netservergetinfo().

00026 {
00027         return Py_BuildValue("[is]", W_ERROR_V(werror), 
00028                              dos_errstr(werror));
00029 }

PyObject* py_ntstatus_tuple ( NTSTATUS  ntstatus  ) 

py_common.c33 行で定義されています。

参照先 nt_errstr()ntstatus.

参照元 lsa_enum_trust_dom()lsa_lookup_names()lsa_lookup_sids()lsa_open_policy()samr_connect()samr_create_dom_user()samr_delete_dom_user()samr_open_domain()samr_set_user_info2().

00034 {
00035         return Py_BuildValue("[is]", NT_STATUS_V(ntstatus), 
00036                              nt_errstr(ntstatus));
00037 }

void py_samba_init ( void   ) 

py_common.c43 行で定義されています。

参照先 dyn_CONFIGFILEfprintf()init_names()initialisedload_case_tables()load_interfaces().

参照元 initlsa()initsamr()initsmb()initspoolss()initsrvsvc()initwinbind()initwinreg().

00044 {
00045         if (initialised)
00046                 return;
00047 
00048         load_case_tables();
00049 
00050         /* Load configuration file */
00051 
00052         if (!lp_load(dyn_CONFIGFILE, True, False, False, True))
00053                 fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
00054 
00055         /* Misc other stuff */
00056 
00057         load_interfaces();
00058         init_names();
00059 
00060         initialised = True;
00061 }

PyObject* get_debuglevel ( PyObject *  self,
PyObject *  args 
)

py_common.c65 行で定義されています。

参照先 DEBUGLEVELdebuglevel.

00066 {
00067         PyObject *debuglevel;
00068 
00069         if (!PyArg_ParseTuple(args, ""))
00070                 return NULL;
00071 
00072         debuglevel = PyInt_FromLong(DEBUGLEVEL);
00073 
00074         return debuglevel;
00075 }

PyObject* set_debuglevel ( PyObject *  self,
PyObject *  args 
)

py_common.c77 行で定義されています。

参照先 DEBUGLEVELdebuglevel.

00078 {
00079         int debuglevel;
00080 
00081         if (!PyArg_ParseTuple(args, "i", &debuglevel))
00082                 return NULL;
00083 
00084         DEBUGLEVEL = debuglevel;
00085 
00086         Py_INCREF(Py_None);
00087         return Py_None;
00088 }

PyObject* py_setup_logging ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
)

py_common.c92 行で定義されています。

参照先 interactivereopen_logs()setup_logging().

00093 {
00094         BOOL interactive = False;
00095         char *logfilename = NULL;
00096         static char *kwlist[] = {"interactive", "logfilename", NULL};
00097 
00098         if (!PyArg_ParseTupleAndKeywords(
00099                     args, kw, "|is", kwlist, &interactive, &logfilename))
00100                 return NULL;
00101         
00102         if (interactive && logfilename) {
00103                 PyErr_SetString(PyExc_RuntimeError,
00104                                 "can't be interactive and set log file name");
00105                 return NULL;
00106         }
00107 
00108         if (interactive)
00109                 setup_logging("spoolss", True);
00110 
00111         if (logfilename) {
00112                 lp_set_logfile(logfilename);
00113                 setup_logging(logfilename, False);
00114                 reopen_logs();
00115         }
00116 
00117         Py_INCREF(Py_None);
00118         return Py_None;
00119 }

BOOL py_parse_creds ( PyObject *  creds,
char **  username,
char **  domain,
char **  password,
char **  errstr 
)

py_common.c128 行で定義されています。

参照先 asprintf().

参照元 open_pipe_creds()py_smb_session_setup().

00130 {
00131         /* Initialise anonymous credentials */
00132 
00133         *username = "";
00134         *domain = "";
00135         *password = "";
00136 
00137         if (creds && PyDict_Size(creds) > 0) {
00138                 PyObject *username_obj, *password_obj, *domain_obj;
00139                 PyObject *key, *value;
00140                 int i;
00141 
00142                 /* Check for presence of required fields */
00143 
00144                 username_obj = PyDict_GetItemString(creds, "username");
00145                 domain_obj = PyDict_GetItemString(creds, "domain");
00146                 password_obj = PyDict_GetItemString(creds, "password");
00147 
00148                 if (!username_obj) {
00149                         *errstr = SMB_STRDUP("no username field in credential");
00150                         return False;
00151                 }
00152 
00153                 if (!domain_obj) {
00154                         *errstr = SMB_STRDUP("no domain field in credential");
00155                         return False;
00156                 }
00157 
00158                 if (!password_obj) {
00159                         *errstr = SMB_STRDUP("no password field in credential");
00160                         return False;
00161                 }
00162 
00163                 /* Check type of required fields */
00164 
00165                 if (!PyString_Check(username_obj)) {
00166                         *errstr = SMB_STRDUP("username field is not string type");
00167                         return False;
00168                 }
00169 
00170                 if (!PyString_Check(domain_obj)) {
00171                         *errstr = SMB_STRDUP("domain field is not string type");
00172                         return False;
00173                 }
00174 
00175                 if (!PyString_Check(password_obj)) {
00176                         *errstr = SMB_STRDUP("password field is not string type");
00177                         return False;
00178                 }
00179 
00180                 /* Look for any extra fields */
00181 
00182                 i = 0;
00183 
00184                 while (PyDict_Next(creds, &i, &key, &value)) {
00185                         if (strcmp(PyString_AsString(key), "domain") != 0 &&
00186                             strcmp(PyString_AsString(key), "username") != 0 &&
00187                             strcmp(PyString_AsString(key), "password") != 0) {
00188                                 asprintf(errstr,
00189                                          "creds contain extra field '%s'",
00190                                          PyString_AsString(key));
00191                                 return False;
00192                         }
00193                 }
00194 
00195                 /* Assign values */
00196 
00197                 *username = PyString_AsString(username_obj);
00198                 *domain = PyString_AsString(domain_obj);
00199                 *password = PyString_AsString(password_obj);
00200         }
00201 
00202         *errstr = NULL;
00203 
00204         return True;
00205 }

struct cli_state* open_pipe_creds ( char *  server,
PyObject *  creds,
int  pipe_idx,
char **  errstr 
)

py_common.c212 行で定義されています。

参照先 asprintf()clicli_full_connection()cli_rpc_pipe_open_noauth()cli_shutdown()cli_state::domainpasswordpy_parse_creds()resultusername.

参照元 lsa_open_policy()samr_connect()spoolss_addprinterdriver()spoolss_addprinterex()spoolss_enumports()spoolss_enumprinterdrivers()spoolss_enumprinters()spoolss_getprinterdriverdir()spoolss_openprinter()srvsvc_netservergetinfo().

00214 {
00215         char *username, *password, *domain;
00216         struct cli_state *cli;
00217         struct rpc_pipe_client *pipe_hnd;
00218         NTSTATUS result;
00219         
00220         /* Extract credentials from the python dictionary */
00221 
00222         if (!py_parse_creds(creds, &username, &domain, &password, errstr))
00223                 return NULL;
00224 
00225         /* Now try to connect */
00226 
00227         result = cli_full_connection(
00228                 &cli, NULL, server, NULL, 0, "IPC$", "IPC",
00229                 username, domain, password, 0, Undefined, NULL);
00230         
00231         if (!NT_STATUS_IS_OK(result)) {
00232                 *errstr = SMB_STRDUP("error connecting to IPC$ pipe");
00233                 return NULL;
00234         }
00235 
00236         pipe_hnd = cli_rpc_pipe_open_noauth(cli, pipe_idx, &result);
00237         if (!pipe_hnd) {
00238                 cli_shutdown(cli);
00239                 asprintf(errstr, "error opening pipe index %d", pipe_idx);
00240                 return NULL;
00241         }
00242 
00243         *errstr = NULL;
00244 
00245         return cli;
00246 }

BOOL get_level_value ( PyObject *  dict,
uint32 *  level 
)

py_common.c251 行で定義されています。

参照元 samr_set_user_info2()spoolss_addprinterdriver()spoolss_hnd_addform()spoolss_hnd_setform()spoolss_hnd_setprinter()spoolss_hnd_startdocprinter().

00252 {
00253         PyObject *obj;
00254 
00255         if (!(obj = PyDict_GetItemString(dict, "level")) ||
00256             !PyInt_Check(obj))
00257                 return False;
00258 
00259         if (level)
00260                 *level = PyInt_AsLong(obj);
00261 
00262         return True;
00263 }

BOOL py_from_SID ( PyObject **  obj,
DOM_SID sid 
)

py_ntsec.c25 行で定義されています。

参照先 sid_to_string().

参照元 lsa_lookup_names()py_from_ACE()py_from_SECDESC().

00026 {
00027         fstring sidstr;
00028 
00029         if (!sid) {
00030                 Py_INCREF(Py_None);
00031                 *obj = Py_None;
00032                 return True;
00033         }
00034 
00035         if (!sid_to_string(sidstr, sid))
00036                 return False;
00037 
00038         *obj = PyString_FromString(sidstr);
00039 
00040         return True;
00041 }

BOOL py_to_SID ( DOM_SID sid,
PyObject *  obj 
)

py_ntsec.c43 行で定義されています。

参照先 string_to_sid().

参照元 py_to_ACE()py_to_SECDESC().

00044 {
00045         if (!PyString_Check(obj))
00046                 return False;
00047 
00048         return string_to_sid(sid, PyString_AsString(obj));
00049 }

BOOL py_from_ACE ( PyObject **  dict,
SEC_ACE ace 
)

py_ntsec.c51 行で定義されています。

参照先 security_ace_info::access_masksecurity_ace_info::flagspy_from_SID()security_ace_info::trusteesecurity_ace_info::type.

参照元 py_from_ACL().

00052 {
00053         PyObject *obj;
00054 
00055         if (!ace) {
00056                 Py_INCREF(Py_None);
00057                 *dict = Py_None;
00058                 return True;
00059         }
00060 
00061         *dict = Py_BuildValue("{sisisi}", "type", ace->type,
00062                                 "flags", ace->flags,
00063                                 "mask", ace->access_mask);
00064 
00065         if (py_from_SID(&obj, &ace->trustee)) {
00066                 PyDict_SetItemString(*dict, "trustee", obj);
00067                 Py_DECREF(obj);
00068         }
00069 
00070         return True;
00071 }

BOOL py_to_ACE ( SEC_ACE ace,
PyObject *  dict 
)

py_ntsec.c73 行で定義されています。

参照先 init_sec_ace()py_to_SID()sid_size()security_ace_info::size.

参照元 py_to_ACL().

00074 {
00075         PyObject *obj;
00076         uint8 ace_type, ace_flags;
00077         DOM_SID trustee;
00078         SEC_ACCESS sec_access;
00079 
00080         if (!PyDict_Check(dict))
00081                 return False;
00082 
00083         if (!(obj = PyDict_GetItemString(dict, "type")) ||
00084             !PyInt_Check(obj))
00085                 return False;
00086 
00087         ace_type = PyInt_AsLong(obj);
00088 
00089         if (!(obj = PyDict_GetItemString(dict, "flags")) ||
00090             !PyInt_Check(obj))
00091                 return False;
00092 
00093         ace_flags = PyInt_AsLong(obj);
00094 
00095         if (!(obj = PyDict_GetItemString(dict, "trustee")) ||
00096             !PyString_Check(obj))
00097                 return False;
00098 
00099         if (!py_to_SID(&trustee, obj))
00100                 return False;
00101 
00102         if (!(obj = PyDict_GetItemString(dict, "mask")) ||
00103             !PyInt_Check(obj))
00104                 return False;
00105 
00106         sec_access = PyInt_AsLong(obj);
00107 
00108         init_sec_ace(ace, &trustee, ace_type, sec_access, ace_flags);
00109 
00110         /* Fill in size field */
00111 
00112         ace->size = SEC_ACE_HEADER_SIZE + sid_size(&trustee);
00113 
00114         return True;
00115 }

BOOL py_from_ACL ( PyObject **  dict,
SEC_ACL acl 
)

py_ntsec.c117 行で定義されています。

参照先 security_acl_info::acessecurity_acl_info::num_acespy_from_ACE()security_acl_info::revision.

参照元 py_from_SECDESC().

00118 {
00119         PyObject *ace_list;
00120         int i;
00121 
00122         if (!acl) {
00123                 Py_INCREF(Py_None);
00124                 *dict = Py_None;
00125                 return True;
00126         }
00127 
00128         ace_list = PyList_New(acl->num_aces);
00129 
00130         for (i = 0; i < acl->num_aces; i++) {
00131                 PyObject *obj;
00132 
00133                 if (py_from_ACE(&obj, &acl->aces[i]))
00134                         PyList_SetItem(ace_list, i, obj);
00135         }
00136 
00137         *dict = Py_BuildValue("{sisN}", "revision", acl->revision,
00138                         "ace_list", ace_list);
00139 
00140         return True;
00141 }

BOOL py_to_ACL ( SEC_ACL acl,
PyObject *  dict,
TALLOC_CTX mem_ctx 
)

py_ntsec.c143 行で定義されています。

参照先 _talloc()security_acl_info::acessecurity_acl_info::num_acespy_to_ACE()security_acl_info::revisionsecurity_acl_info::sizesecurity_ace_info::size.

参照元 py_to_SECDESC().

00144 {
00145         PyObject *obj;
00146         uint32 i;
00147 
00148         if (!(obj = PyDict_GetItemString(dict, "revision")) ||
00149             !PyInt_Check(obj))
00150                 return False;
00151 
00152         acl->revision = PyInt_AsLong(obj);
00153 
00154         if (!(obj = PyDict_GetItemString(dict, "ace_list")) ||
00155             !PyList_Check(obj)) 
00156                 return False;
00157         
00158         acl->num_aces = PyList_Size(obj);
00159 
00160         acl->aces = _talloc(mem_ctx, acl->num_aces * sizeof(SEC_ACE));
00161         acl->size = SEC_ACL_HEADER_SIZE;
00162 
00163         for (i = 0; i < acl->num_aces; i++) {
00164                 PyObject *py_ace = PyList_GetItem(obj, i);
00165 
00166                 if (!py_to_ACE(&acl->aces[i], py_ace))
00167                         return False;
00168 
00169                 acl->size += acl->aces[i].size;
00170         }
00171 
00172         return True;
00173 }

BOOL py_from_SECDESC ( PyObject **  dict,
SEC_DESC sd 
)

py_ntsec.c175 行で定義されています。

参照先 security_descriptor_info::daclsecurity_descriptor_info::group_sidsecurity_descriptor_info::owner_sidpy_from_ACL()py_from_SID()security_descriptor_info::revisionsecurity_descriptor_info::saclsecurity_descriptor_info::type.

参照元 py_from_PRINTER_INFO_2()py_from_PRINTER_INFO_3()py_smb_query_secdesc().

00176 {
00177         PyObject *obj;
00178 
00179         *dict = PyDict_New();
00180 
00181         obj = PyInt_FromLong(sd->revision);
00182         PyDict_SetItemString(*dict, "revision", obj);
00183         Py_DECREF(obj);
00184 
00185         obj = PyInt_FromLong(sd->type);
00186         PyDict_SetItemString(*dict, "type", obj);
00187         Py_DECREF(obj);
00188 
00189         if (py_from_SID(&obj, sd->owner_sid)) {
00190                 PyDict_SetItemString(*dict, "owner_sid", obj);
00191                 Py_DECREF(obj);
00192         }
00193 
00194         if (py_from_SID(&obj, sd->group_sid)) {
00195                 PyDict_SetItemString(*dict, "group_sid", obj);
00196                 Py_DECREF(obj);
00197         }
00198 
00199         if (py_from_ACL(&obj, sd->dacl)) {
00200                 PyDict_SetItemString(*dict, "dacl", obj);
00201                 Py_DECREF(obj);
00202         }
00203 
00204         if (py_from_ACL(&obj, sd->sacl)) {
00205                 PyDict_SetItemString(*dict, "sacl", obj);
00206                 Py_DECREF(obj);
00207         }
00208 
00209         return True;
00210 }

BOOL py_to_SECDESC ( SEC_DESC **  sd,
PyObject *  dict,
TALLOC_CTX mem_ctx 
)

py_ntsec.c212 行で定義されています。

参照先 make_sec_desc()py_to_ACL()py_to_SID()type.

参照元 py_smb_set_secdesc()py_to_PRINTER_INFO_2()py_to_PRINTER_INFO_3().

00213 {
00214         PyObject *obj;
00215         uint16 revision;
00216         uint16 type = SEC_DESC_SELF_RELATIVE;
00217         DOM_SID owner_sid, group_sid;
00218         SEC_ACL sacl, dacl;
00219         BOOL got_dacl = False, got_sacl = False;
00220         BOOL got_owner_sid = False, got_group_sid = False;
00221 
00222         ZERO_STRUCT(dacl); ZERO_STRUCT(sacl);
00223         ZERO_STRUCT(owner_sid); ZERO_STRUCT(group_sid);
00224 
00225         if (!(obj = PyDict_GetItemString(dict, "revision")))
00226                 return False;
00227 
00228         revision = PyInt_AsLong(obj);
00229 
00230         if ((obj = PyDict_GetItemString(dict, "type"))) {
00231                 if (obj != Py_None) {
00232                         type = PyInt_AsLong(obj);
00233                 }
00234         }
00235 
00236         if ((obj = PyDict_GetItemString(dict, "owner_sid"))) {
00237 
00238                 if (obj != Py_None) {
00239 
00240                         if (!py_to_SID(&owner_sid, obj))
00241                                 return False;
00242 
00243                         got_owner_sid = True;
00244                 }
00245         }
00246 
00247         if ((obj = PyDict_GetItemString(dict, "group_sid"))) {
00248 
00249                 if (obj != Py_None) {
00250 
00251                         if (!py_to_SID(&group_sid, obj))
00252                                 return False;
00253                         
00254                         got_group_sid = True;
00255                 }
00256         }
00257 
00258         if ((obj = PyDict_GetItemString(dict, "dacl"))) {
00259 
00260                 if (obj != Py_None) {
00261 
00262                         if (!py_to_ACL(&dacl, obj, mem_ctx))
00263                                 return False;
00264                         
00265                         got_dacl = True;
00266                 }
00267         }
00268 
00269         if ((obj = PyDict_GetItemString(dict, "sacl"))) {
00270 
00271                 if (obj != Py_None) {
00272 
00273                         if (!py_to_ACL(&sacl, obj, mem_ctx))
00274                                 return False;
00275 
00276                         got_sacl = True;
00277                 }
00278         }
00279 
00280 #if 0                           /* For new secdesc code */
00281         *sd = make_sec_desc(mem_ctx, revision, 
00282                             got_owner_sid ? &owner_sid : NULL, 
00283                             got_group_sid ? &group_sid : NULL,
00284                             got_sacl ? &sacl : NULL, 
00285                             got_dacl ? &dacl : NULL);
00286 #else
00287         {
00288                 size_t sd_size;
00289 
00290                 *sd = make_sec_desc(mem_ctx, revision, type,
00291                             got_owner_sid ? &owner_sid : NULL, 
00292                             got_group_sid ? &group_sid : NULL,
00293                             got_sacl ? &sacl : NULL, 
00294                             got_dacl ? &dacl : NULL, &sd_size);
00295         }
00296 #endif
00297 
00298         return True;
00299 }


Sambaに対してSat Aug 29 21:24:04 2009に生成されました。  doxygen 1.4.7