summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorRichard Sharpe <realrichardsharpe@gmail.com>2012-04-01 13:14:49 -0700
committerRichard Sharpe <sharpe@samba.org>2012-04-02 01:43:44 +0200
commit2c322ca95a7dc4fb8396b475d115f31837316267 (patch)
treea2a7969fdcddd68158fd88f0436a2c153b1ac86c /source4
parent36101d3fa45c0b583628862794054f60eb4e6ed3 (diff)
downloadsamba-2c322ca95a7dc4fb8396b475d115f31837316267.tar.gz
samba-2c322ca95a7dc4fb8396b475d115f31837316267.tar.bz2
samba-2c322ca95a7dc4fb8396b475d115f31837316267.zip
Fix some of the issues that Jelmer identified in my first patch. This might be
changed again, especially when I figure out how to return the file as an object. Autobuild-User: Richard Sharpe <sharpe@samba.org> Autobuild-Date: Mon Apr 2 01:43:44 CEST 2012 on sn-devel-104
Diffstat (limited to 'source4')
-rw-r--r--source4/libcli/pysmb.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/source4/libcli/pysmb.c b/source4/libcli/pysmb.c
index a0021b9982..3f2efe9c87 100644
--- a/source4/libcli/pysmb.c
+++ b/source4/libcli/pysmb.c
@@ -437,13 +437,15 @@ static PyObject *py_open_file(pytalloc_Object *self, PyObject *args, PyObject *k
union smb_open io;
struct smb_private_data *spdata;
const char *filename;
- uint32_t access_mask = 0;
- uint32_t share_access = 0;
- uint32_t open_disposition = 0;
+ uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ uint32_t share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ uint32_t open_disposition = NTCREATEX_DISP_OPEN;
uint32_t create_options = 0;
+ TALLOC_CTX *mem_ctx;
int fnum;
- if (!PyArg_ParseTuple(args, "si|iii:open_file",
+ if (!PyArg_ParseTuple(args, "s|iiii:open_file",
&filename,
&access_mask,
&share_access,
@@ -452,20 +454,12 @@ static PyObject *py_open_file(pytalloc_Object *self, PyObject *args, PyObject *k
return NULL;
}
- if (!access_mask)
- access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-
- if (!share_access)
- share_access = NTCREATEX_SHARE_ACCESS_READ |
- NTCREATEX_SHARE_ACCESS_WRITE;
-
- if (!open_disposition)
- open_disposition = NTCREATEX_DISP_OPEN;
-
ZERO_STRUCT(io);
spdata = self->ptr;
+ mem_ctx = talloc_new(NULL);
+
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid.fnum = 0;
io.ntcreatex.in.flags = 0;
@@ -479,7 +473,9 @@ static PyObject *py_open_file(pytalloc_Object *self, PyObject *args, PyObject *k
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = filename;
- status = smb_raw_open(spdata->tree, self->talloc_ctx, &io);
+ status = smb_raw_open(spdata->tree, mem_ctx, &io);
+ talloc_free(mem_ctx);
+
PyErr_NTSTATUS_IS_ERR_RAISE(status);
fnum = io.ntcreatex.out.file.fnum;
@@ -541,7 +537,7 @@ static PyMethodDef py_smb_methods[] = {
Set security descriptor for file." },
{ "open_file", (PyCFunction)py_open_file, METH_VARARGS,
"open_file(path, access_mask[, share_access[, open_disposition[, create_options]]] -> fnum\n\n \
- Open a file. Throws exceptions on errors." },
+ Open a file. Throws NTSTATUS exceptions on errors." },
{ "close_file", (PyCFunction)py_close_file, METH_VARARGS,
"close_file(fnum) -> None\n\n \
Close the file based on fnum."},