python/py_smb.c

ソースコードを見る。

関数

PyObject * new_cli_state_object (struct cli_state *cli)
static PyObject * py_smb_connect (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_session_request (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_negprot (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_session_setup (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_tconx (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_nt_create_andx (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_open (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_read (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_close (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_unlink (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_query_secdesc (PyObject *self, PyObject *args, PyObject *kw)
static PyObject * py_smb_set_secdesc (PyObject *self, PyObject *args, PyObject *kw)
static void py_cli_state_dealloc (PyObject *self)
static PyObject * py_cli_state_getattr (PyObject *self, char *attrname)
void initsmb (void)

変数

static PyMethodDef smb_hnd_methods []
static PyMethodDef smb_methods []
PyTypeObject cli_state_type


関数

PyObject* new_cli_state_object ( struct cli_state cli  ) 

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

参照先 clicli_state_object::clicli_state_type.

参照元 py_smb_connect().

00026 {
00027         cli_state_object *o;
00028 
00029         o = PyObject_New(cli_state_object, &cli_state_type);
00030 
00031         o->cli = cli;
00032 
00033         return (PyObject*)o;
00034 }

static PyObject* py_smb_connect ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c36 行で定義されています。

参照先 clicli_connect()cli_initialise()new_cli_state_object()server.

00037 {
00038         static char *kwlist[] = { "server", NULL };
00039         struct cli_state *cli;
00040         char *server;
00041         struct in_addr ip;
00042 
00043         if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &server))
00044                 return NULL;
00045 
00046         if (!(cli = cli_initialise()))
00047                 return NULL;
00048 
00049         ZERO_STRUCT(ip);
00050 
00051         if (!NT_STATUS_IS_OK(cli_connect(cli, server, &ip)))
00052                 return NULL;
00053 
00054         return new_cli_state_object(cli);
00055 }

static PyObject* py_smb_session_request ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c57 行で定義されています。

参照先 calling_nameclicli_session_request()global_mynamemake_nmb_name()result.

00059 {
00060         cli_state_object *cli = (cli_state_object *)self;
00061         static char *kwlist[] = { "called", "calling", NULL };
00062         char *calling_name = NULL, *called_name;
00063         struct nmb_name calling, called;
00064         BOOL result;
00065 
00066         if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s", kwlist, &called_name, 
00067                                          &calling_name))
00068                 return NULL;
00069 
00070         if (!calling_name)
00071                 calling_name = global_myname();
00072 
00073         make_nmb_name(&calling, calling_name, 0x00);
00074         make_nmb_name(&called, called_name, 0x20);
00075 
00076         result = cli_session_request(cli->cli, &calling, &called);
00077 
00078         return Py_BuildValue("i", result);
00079 }

static PyObject* py_smb_negprot ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c81 行で定義されています。

参照先 clicli_negprot()result.

00082 {
00083         cli_state_object *cli = (cli_state_object *)self;
00084         static char *kwlist[] = { NULL };
00085         BOOL result;
00086 
00087         if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
00088                 return NULL;
00089 
00090         result = cli_negprot(cli->cli);
00091 
00092         return Py_BuildValue("i", result);
00093 }

static PyObject* py_smb_session_setup ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c95 行で定義されています。

参照先 clicli_is_error()cli_session_setup()passwordpy_parse_creds()resultusername.

00097 {
00098         cli_state_object *cli = (cli_state_object *)self;
00099         static char *kwlist[] = { "creds", NULL };
00100         PyObject *creds;
00101         char *username, *domain, *password, *errstr;
00102         NTSTATUS result;
00103 
00104         if (!PyArg_ParseTupleAndKeywords(args, kw, "|O", kwlist, &creds))
00105                 return NULL;
00106 
00107         if (!py_parse_creds(creds, &username, &domain, &password, &errstr)) {
00108                 free(errstr);
00109                 return NULL;
00110         }
00111 
00112         result = cli_session_setup(
00113                 cli->cli, username, password, strlen(password) + 1,
00114                 password, strlen(password) + 1, domain);
00115 
00116         if (cli_is_error(cli->cli)) {
00117                 PyErr_SetString(PyExc_RuntimeError, "session setup failed");
00118                 return NULL;
00119         }
00120 
00121         return Py_BuildValue("i", NT_STATUS_IS_OK(result));
00122 }

static PyObject* py_smb_tconx ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c124 行で定義されています。

参照先 clicli_is_error()cli_send_tconX()resultstrequal().

00125 {
00126         cli_state_object *cli = (cli_state_object *)self;
00127         static char *kwlist[] = { "service", NULL };
00128         char *service;
00129         BOOL result;
00130 
00131         if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &service))
00132                 return NULL;
00133 
00134         result = cli_send_tconX(
00135                 cli->cli, service, strequal(service, "IPC$") ? "IPC" : 
00136                 "?????", "", 1);
00137 
00138         if (cli_is_error(cli->cli)) {
00139                 PyErr_SetString(PyExc_RuntimeError, "tconx failed");
00140                 return NULL;
00141         }
00142 
00143         return Py_BuildValue("i", result);
00144 }

static PyObject* py_smb_nt_create_andx ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c146 行で定義されています。

参照先 clicli_is_error()cli_nt_create_full()result.

00148 {
00149         cli_state_object *cli = (cli_state_object *)self;
00150         static char *kwlist[] = { "filename", "desired_access", 
00151                                   "file_attributes", "share_access",
00152                                   "create_disposition", "create_options",
00153                                   NULL };
00154         char *filename;
00155         uint32 desired_access, file_attributes = 0, 
00156                 share_access = FILE_SHARE_READ | FILE_SHARE_WRITE,
00157                 create_disposition = OPENX_FILE_EXISTS_OPEN, create_options = 0;
00158         int result;
00159 
00160         /* Parse parameters */
00161 
00162         if (!PyArg_ParseTupleAndKeywords(
00163                     args, kw, "si|iiii", kwlist, &filename, &desired_access,
00164                     &file_attributes, &share_access, &create_disposition,
00165                     &create_options))
00166                 return NULL;
00167 
00168         result = cli_nt_create_full(
00169                 cli->cli, filename, 0, desired_access, file_attributes,
00170                 share_access, create_disposition, create_options, 0);
00171 
00172         if (cli_is_error(cli->cli)) {
00173                 PyErr_SetString(PyExc_RuntimeError, "nt_create_andx failed");
00174                 return NULL;
00175         }
00176 
00177         /* Return FID */
00178 
00179         return PyInt_FromLong(result);
00180 }

static PyObject* py_smb_open ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c182 行で定義されています。

参照先 clicli_is_error()cli_open()flagsresult.

00183 {
00184         cli_state_object *cli = (cli_state_object *)self;
00185         static char *kwlist[] = { "filename", "flags", 
00186                                   "share_mode", NULL };
00187         char *filename;
00188         uint32 flags, share_mode = DENY_NONE;
00189         int result;
00190 
00191         /* Parse parameters */
00192 
00193         if (!PyArg_ParseTupleAndKeywords(
00194                     args, kw, "si|i", kwlist, &filename, &flags, &share_mode))
00195                 return NULL;
00196 
00197         result = cli_open(cli->cli, filename, flags, share_mode);
00198 
00199         if (cli_is_error(cli->cli)) {
00200                 PyErr_SetString(PyExc_RuntimeError, "open failed");
00201                 return NULL;
00202         }
00203 
00204         /* Return FID */
00205 
00206         return PyInt_FromLong(result);
00207 }

static PyObject* py_smb_read ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c209 行で定義されています。

参照先 clicli_getattrE()cli_is_error()cli_qfileinfo()cli_read()resultsize.

00210 {
00211         cli_state_object *cli = (cli_state_object *)self;
00212         static char *kwlist[] = { "fnum", "offset", "size", NULL };
00213         int fnum, offset=0, size=0;
00214         ssize_t result;
00215         SMB_OFF_T fsize;
00216         char *data;
00217         PyObject *ret;
00218 
00219         /* Parse parameters */
00220 
00221         if (!PyArg_ParseTupleAndKeywords(
00222                     args, kw, "i|ii", kwlist, &fnum, &offset, &size))
00223                 return NULL;
00224 
00225         if (!cli_qfileinfo(cli->cli, fnum, NULL, &fsize, NULL, NULL,
00226                     NULL, NULL, NULL) &&
00227             !cli_getattrE(cli->cli, fnum, NULL, &fsize, NULL, NULL, NULL)) {
00228                 PyErr_SetString(PyExc_RuntimeError, "getattrib failed");
00229                 return NULL;
00230         }
00231 
00232         if (offset < 0)
00233                 offset = 0;
00234 
00235         if (size < 1 || size > fsize - offset)
00236                 size = fsize - offset;
00237 
00238         if (!(data = SMB_XMALLOC_ARRAY(char, size))) {
00239                 PyErr_SetString(PyExc_RuntimeError, "malloc failed");
00240                 return NULL;
00241         }
00242 
00243         result = cli_read(cli->cli, fnum, data, (off_t) offset, (size_t) size);
00244 
00245         if (result==-1 || cli_is_error(cli->cli)) {
00246                 SAFE_FREE(data);
00247                 PyErr_SetString(PyExc_RuntimeError, "read failed");
00248                 return NULL;
00249         }
00250 
00251         /* Return a python string */
00252 
00253         ret = Py_BuildValue("s#", data, result);
00254         SAFE_FREE(data);
00255 
00256         return ret;
00257 }

static PyObject* py_smb_close ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c259 行で定義されています。

参照先 clicli_close()result.

00261 {
00262         cli_state_object *cli = (cli_state_object *)self;
00263         static char *kwlist[] = { "fnum", NULL };
00264         BOOL result;
00265         int fnum;
00266 
00267         /* Parse parameters */
00268 
00269         if (!PyArg_ParseTupleAndKeywords(
00270                     args, kw, "i", kwlist, &fnum))
00271                 return NULL;
00272 
00273         result = cli_close(cli->cli, fnum);
00274 
00275         return PyInt_FromLong(result);
00276 }

static PyObject* py_smb_unlink ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c278 行で定義されています。

参照先 clicli_unlink()result.

00280 {
00281         cli_state_object *cli = (cli_state_object *)self;
00282         static char *kwlist[] = { "filename", NULL };
00283         char *filename;
00284         BOOL result;
00285 
00286         /* Parse parameters */
00287 
00288         if (!PyArg_ParseTupleAndKeywords(
00289                     args, kw, "s", kwlist, &filename))
00290                 return NULL;
00291 
00292         result = cli_unlink(cli->cli, filename);
00293 
00294         return PyInt_FromLong(result);
00295 }

static PyObject* py_smb_query_secdesc ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c297 行で定義されています。

参照先 clicli_is_error()cli_query_secdesc()py_from_SECDESC()resulttalloc_init().

00299 {
00300         cli_state_object *cli = (cli_state_object *)self;
00301         static char *kwlist[] = { "fnum", NULL };
00302         PyObject *result = NULL;
00303         SEC_DESC *secdesc = NULL;
00304         int fnum;
00305         TALLOC_CTX *mem_ctx = NULL;
00306 
00307         /* Parse parameters */
00308 
00309         if (!PyArg_ParseTupleAndKeywords(
00310                     args, kw, "i", kwlist, &fnum))
00311                 return NULL;
00312 
00313         mem_ctx = talloc_init("py_smb_query_secdesc");
00314 
00315         secdesc = cli_query_secdesc(cli->cli, fnum, mem_ctx);
00316 
00317         if (cli_is_error(cli->cli)) {
00318                 PyErr_SetString(PyExc_RuntimeError, "query_secdesc failed");
00319                 goto done;
00320         }
00321 
00322         if (!secdesc) {
00323                 Py_INCREF(Py_None);
00324                 result = Py_None;
00325                 goto done;
00326         }
00327 
00328         if (!py_from_SECDESC(&result, secdesc)) {
00329                 PyErr_SetString(
00330                         PyExc_TypeError,
00331                         "Invalid security descriptor returned");
00332                 goto done;
00333         }
00334 
00335  done:
00336         talloc_destroy(mem_ctx);
00337 
00338         return result;
00339         
00340 }

static PyObject* py_smb_set_secdesc ( PyObject *  self,
PyObject *  args,
PyObject *  kw 
) [static]

py_smb.c342 行で定義されています。

参照先 clicli_is_error()cli_set_secdesc()errpy_to_SECDESC()resulttalloc_init().

00344 {
00345         cli_state_object *cli = (cli_state_object *)self;
00346         static char *kwlist[] = { "fnum", "security_descriptor", NULL };
00347         PyObject *result = NULL;
00348         PyObject *py_secdesc;
00349         SEC_DESC *secdesc;
00350         TALLOC_CTX *mem_ctx = NULL;
00351         int fnum;
00352         BOOL err;
00353 
00354         /* Parse parameters */
00355 
00356         if (!PyArg_ParseTupleAndKeywords(
00357                     args, kw, "iO", kwlist, &fnum, &py_secdesc))
00358                 return NULL;
00359 
00360         mem_ctx = talloc_init("py_smb_set_secdesc");
00361 
00362         if (!py_to_SECDESC(&secdesc, py_secdesc, mem_ctx)) {
00363                 PyErr_SetString(PyExc_TypeError, 
00364                                 "Invalid security descriptor");
00365                 goto done;
00366         }
00367 
00368         err = cli_set_secdesc(cli->cli, fnum, secdesc);
00369 
00370         if (cli_is_error(cli->cli)) {
00371                 PyErr_SetString(PyExc_RuntimeError, "set_secdesc failed");
00372                 goto done;
00373         }
00374 
00375         result =  PyInt_FromLong(err);
00376  done:
00377         talloc_destroy(mem_ctx);
00378 
00379         return result;
00380 }

static void py_cli_state_dealloc ( PyObject *  self  )  [static]

py_smb.c491 行で定義されています。

参照先 clicli_shutdown().

00492 {
00493         cli_state_object *cli = (cli_state_object *)self;
00494 
00495         if (cli->cli)
00496                 cli_shutdown(cli->cli);
00497 
00498         PyObject_Del(self);
00499 }

static PyObject* py_cli_state_getattr ( PyObject *  self,
char *  attrname 
) [static]

py_smb.c501 行で定義されています。

参照先 smb_hnd_methods.

00502 {
00503         return Py_FindMethod(smb_hnd_methods, self, attrname);
00504 }

void initsmb ( void   ) 

py_smb.c528 行で定義されています。

参照先 DEBUGLEVELpy_samba_init()setup_logging().

00529 {
00530         PyObject *module, *dict;
00531 
00532         /* Initialise module */
00533 
00534         module = Py_InitModule("smb", smb_methods);
00535         dict = PyModule_GetDict(module);
00536 
00537         /* Initialise policy handle object */
00538 
00539         cli_state_type.ob_type = &PyType_Type;
00540 
00541         /* Do samba initialisation */
00542 
00543         py_samba_init();
00544 
00545         setup_logging("smb", True);
00546         DEBUGLEVEL = 3;
00547 }


変数

PyMethodDef smb_hnd_methods[] [static]

py_smb.c382 行で定義されています。

参照元 py_cli_state_getattr().

PyMethodDef smb_methods[] [static]

py_smb.c451 行で定義されています。

PyTypeObject cli_state_type

初期値:

 {
        PyObject_HEAD_INIT(NULL)
        0,
        "SMB client connection",
        sizeof(cli_state_object),
        0,
        py_cli_state_dealloc, 
        0,          
        py_cli_state_getattr,          
        0,          
        0,          
        0,          
        0,          
        0,          
        0,          
        0,          
}

py_smb.c506 行で定義されています。

参照元 new_cli_state_object().


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