summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clientgen.c2
-rw-r--r--source3/libsmb/clifile.c63
-rw-r--r--source3/libsmb/clioplock.c7
-rw-r--r--source3/libsmb/cliprint.c2
-rw-r--r--source3/libsmb/cliquota.c12
-rw-r--r--source3/libsmb/clirap.c6
-rw-r--r--source3/libsmb/clireadwrite.c12
-rw-r--r--source3/libsmb/clisecdesc.c4
-rw-r--r--source3/libsmb/libsmb_file.c16
-rw-r--r--source3/libsmb/libsmb_xattr.c21
10 files changed, 72 insertions, 73 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 45addc2163..b06a6fa187 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -234,7 +234,7 @@ bool cli_receive_smb(struct cli_state *cli)
if (cli->oplock_handler) {
int fnum = SVAL(cli->inbuf,smb_vwv2);
unsigned char level = CVAL(cli->inbuf,smb_vwv3+1);
- if (!cli->oplock_handler(cli, fnum, level)) {
+ if (!NT_STATUS_IS_OK(cli->oplock_handler(cli, fnum, level))) {
return false;
}
}
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 54c59473e6..05730413b0 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1083,7 +1083,7 @@ NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname)
Set or clear the delete on close flag.
****************************************************************************/
-int cli_nt_delete_on_close(struct cli_state *cli, int fnum, bool flag)
+int cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag)
{
unsigned int data_len = 1;
unsigned int param_len = 6;
@@ -1125,6 +1125,7 @@ int cli_nt_delete_on_close(struct cli_state *cli, int fnum, bool flag)
Used in smbtorture.
****************************************************************************/
+#if 0
int cli_nt_create_full(struct cli_state *cli, const char *fname,
uint32_t CreatFlags, uint32_t DesiredAccess,
uint32_t FileAttributes, uint32_t ShareAccess,
@@ -1181,6 +1182,7 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
return SVAL(cli->inbuf,smb_vwv2 + 1);
}
+#endif
struct cli_ntcreate_state {
uint16_t vwv[24];
@@ -1344,6 +1346,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
return status;
}
+#if 0
/****************************************************************************
Open a file.
****************************************************************************/
@@ -1353,6 +1356,7 @@ int cli_nt_create(struct cli_state *cli, const char *fname, uint32_t DesiredAcce
return cli_nt_create_full(cli, fname, 0, DesiredAccess, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0);
}
+#endif
uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2,
const char *str, size_t str_len,
@@ -1411,7 +1415,7 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2,
struct cli_open_state {
uint16_t vwv[15];
- int fnum;
+ uint16_t fnum;
struct iovec bytes;
};
@@ -1544,7 +1548,7 @@ static void cli_open_done(struct tevent_req *subreq)
tevent_req_done(req);
}
-NTSTATUS cli_open_recv(struct tevent_req *req, int *fnum)
+NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *pfnum)
{
struct cli_open_state *state = tevent_req_data(
req, struct cli_open_state);
@@ -1553,18 +1557,17 @@ NTSTATUS cli_open_recv(struct tevent_req *req, int *fnum)
if (tevent_req_is_nterror(req, &status)) {
return status;
}
- *fnum = state->fnum;
+ *pfnum = state->fnum;
return NT_STATUS_OK;
}
-int cli_open(struct cli_state *cli, const char *fname, int flags,
- int share_mode)
+NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
+ int share_mode, uint16_t *pfnum)
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
struct tevent_req *req;
NTSTATUS status = NT_STATUS_OK;
- int result = -1;
if (cli_has_async_calls(cli)) {
/*
@@ -1591,13 +1594,13 @@ int cli_open(struct cli_state *cli, const char *fname, int flags,
goto fail;
}
- cli_open_recv(req, &result);
+ status = cli_open_recv(req, pfnum);
fail:
TALLOC_FREE(frame);
if (!NT_STATUS_IS_OK(status)) {
cli_set_error(cli, status);
}
- return result;
+ return status;
}
/****************************************************************************
@@ -1611,9 +1614,10 @@ struct cli_close_state {
static void cli_close_done(struct tevent_req *subreq);
struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, int fnum,
- struct tevent_req **psubreq)
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ struct tevent_req **psubreq)
{
struct tevent_req *req, *subreq;
struct cli_close_state *state;
@@ -1637,8 +1641,9 @@ struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
}
struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli, int fnum)
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum)
{
struct tevent_req *req, *subreq;
@@ -1670,7 +1675,7 @@ NTSTATUS cli_close_recv(struct tevent_req *req)
return tevent_req_simple_recv_ntstatus(req);
}
-bool cli_close(struct cli_state *cli, int fnum)
+bool cli_close(struct cli_state *cli, uint16_t fnum)
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
@@ -1716,7 +1721,7 @@ bool cli_close(struct cli_state *cli, int fnum)
Truncate a file to a specified size
****************************************************************************/
-bool cli_ftruncate(struct cli_state *cli, int fnum, uint64_t size)
+bool cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size)
{
unsigned int param_len = 6;
unsigned int data_len = 8;
@@ -1766,7 +1771,7 @@ bool cli_ftruncate(struct cli_state *cli, int fnum, uint64_t size)
this is used for testing LOCKING_ANDX_CANCEL_LOCK
****************************************************************************/
-NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
+NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
uint32_t offset, uint32_t len,
int timeout, unsigned char locktype)
{
@@ -1819,7 +1824,7 @@ NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
note that timeout is in units of 2 milliseconds
****************************************************************************/
-bool cli_lock(struct cli_state *cli, int fnum,
+bool cli_lock(struct cli_state *cli, uint16_t fnum,
uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type)
{
char *p;
@@ -1874,7 +1879,7 @@ bool cli_lock(struct cli_state *cli, int fnum,
Unlock a file.
****************************************************************************/
-bool cli_unlock(struct cli_state *cli, int fnum, uint32_t offset, uint32_t len)
+bool cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len)
{
char *p;
@@ -1916,7 +1921,7 @@ bool cli_unlock(struct cli_state *cli, int fnum, uint32_t offset, uint32_t len)
Lock a file with 64 bit offsets.
****************************************************************************/
-bool cli_lock64(struct cli_state *cli, int fnum,
+bool cli_lock64(struct cli_state *cli, uint16_t fnum,
uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type)
{
char *p;
@@ -1977,7 +1982,7 @@ bool cli_lock64(struct cli_state *cli, int fnum,
Unlock a file with 64 bit offsets.
****************************************************************************/
-bool cli_unlock64(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len)
+bool cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len)
{
char *p;
@@ -2023,7 +2028,7 @@ bool cli_unlock64(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len
Get/unlock a POSIX lock on a file - internal function.
****************************************************************************/
-static bool cli_posix_lock_internal(struct cli_state *cli, int fnum,
+static bool cli_posix_lock_internal(struct cli_state *cli, uint16_t fnum,
uint64_t offset, uint64_t len, bool wait_lock, enum brl_type lock_type)
{
unsigned int param_len = 4;
@@ -2094,7 +2099,7 @@ static bool cli_posix_lock_internal(struct cli_state *cli, int fnum,
POSIX Lock a file.
****************************************************************************/
-bool cli_posix_lock(struct cli_state *cli, int fnum,
+bool cli_posix_lock(struct cli_state *cli, uint16_t fnum,
uint64_t offset, uint64_t len,
bool wait_lock, enum brl_type lock_type)
{
@@ -2108,7 +2113,7 @@ bool cli_posix_lock(struct cli_state *cli, int fnum,
POSIX Unlock a file.
****************************************************************************/
-bool cli_posix_unlock(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len)
+bool cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len)
{
return cli_posix_lock_internal(cli, fnum, offset, len, False, UNLOCK_LOCK);
}
@@ -2117,7 +2122,7 @@ bool cli_posix_unlock(struct cli_state *cli, int fnum, uint64_t offset, uint64_t
POSIX Get any lock covering a file.
****************************************************************************/
-bool cli_posix_getlock(struct cli_state *cli, int fnum, uint64_t *poffset, uint64_t *plen)
+bool cli_posix_getlock(struct cli_state *cli, uint16_t fnum, uint64_t *poffset, uint64_t *plen)
{
return True;
}
@@ -2603,7 +2608,7 @@ int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path)
/*
send a raw ioctl - used by the torture code
*/
-NTSTATUS cli_raw_ioctl(struct cli_state *cli, int fnum, uint32_t code, DATA_BLOB *blob)
+NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob)
{
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
@@ -2725,7 +2730,7 @@ bool cli_set_ea_path(struct cli_state *cli, const char *path, const char *ea_nam
Set an extended attribute on an fnum.
*********************************************************/
-bool cli_set_ea_fnum(struct cli_state *cli, int fnum, const char *ea_name, const char *ea_val, size_t ea_len)
+bool cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum, const char *ea_name, const char *ea_val, size_t ea_len)
{
char param[6];
uint16_t setup = TRANSACT2_SETFILEINFO;
@@ -2898,7 +2903,7 @@ bool cli_get_ea_list_path(struct cli_state *cli, const char *path,
Get an extended attribute list from an fnum.
*********************************************************/
-bool cli_get_ea_list_fnum(struct cli_state *cli, int fnum,
+bool cli_get_ea_list_fnum(struct cli_state *cli, uint16_t fnum,
TALLOC_CTX *ctx,
size_t *pnum_eas,
struct ea_struct **pea_list)
@@ -2979,7 +2984,7 @@ static int cli_posix_open_internal(struct cli_state *cli, const char *fname, int
char data[18];
char *rparam=NULL, *rdata=NULL;
char *p;
- int fnum = -1;
+ uint16_t fnum = (uint16_t)-1;
uint32_t wire_flags = open_flags_to_wire(flags);
size_t srclen = 2*(strlen(fname)+1);
diff --git a/source3/libsmb/clioplock.c b/source3/libsmb/clioplock.c
index e3fb66aba0..7350c4aaa3 100644
--- a/source3/libsmb/clioplock.c
+++ b/source3/libsmb/clioplock.c
@@ -80,7 +80,7 @@ NTSTATUS cli_oplock_ack_recv(struct tevent_req *req)
return tevent_req_simple_recv_ntstatus(req);
}
-bool cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level)
+NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char level)
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
@@ -118,14 +118,15 @@ bool cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level)
if (!NT_STATUS_IS_OK(status)) {
cli_set_error(cli, status);
}
- return NT_STATUS_IS_OK(status);
+ return status;
}
/****************************************************************************
set the oplock handler for a connection
****************************************************************************/
+
void cli_oplock_handler(struct cli_state *cli,
- bool (*handler)(struct cli_state *, int, unsigned char))
+ NTSTATUS (*handler)(struct cli_state *, uint16_t, unsigned char))
{
cli->oplock_handler = handler;
}
diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c
index 223ddb4186..e78930c1d5 100644
--- a/source3/libsmb/cliprint.c
+++ b/source3/libsmb/cliprint.c
@@ -237,7 +237,7 @@ int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_
Close a file.
****************************************************************************/
-bool cli_spl_close(struct cli_state *cli, int fnum)
+bool cli_spl_close(struct cli_state *cli, uint16_t fnum)
{
memset(cli->outbuf,'\0',smb_size);
memset(cli->inbuf,'\0',smb_size);
diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c
index e40dac368d..a8b1aa19fd 100644
--- a/source3/libsmb/cliquota.c
+++ b/source3/libsmb/cliquota.c
@@ -19,18 +19,12 @@
#include "includes.h"
-bool cli_get_quota_handle(struct cli_state *cli, int *quota_fnum)
+NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum)
{
- *quota_fnum = cli_nt_create_full(cli, FAKE_FILE_NAME_QUOTA_WIN32,
+ return cli_ntcreate(cli, FAKE_FILE_NAME_QUOTA_WIN32,
0x00000016, DESIRED_ACCESS_PIPE,
0x00000000, FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x00000000, 0x03);
-
- if (*quota_fnum == (-1)) {
- return False;
- }
-
- return True;
+ FILE_OPEN, 0x00000000, 0x03, quota_fnum);
}
void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list)
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index 976e184e9c..1771e8fd25 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -919,7 +919,7 @@ bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
Send a qfileinfo QUERY_FILE_NAME_INFO call.
****************************************************************************/
-bool cli_qfilename(struct cli_state *cli, int fnum, char *name, size_t namelen)
+bool cli_qfilename(struct cli_state *cli, uint16_t fnum, char *name, size_t namelen)
{
unsigned int data_len = 0;
unsigned int param_len = 0;
@@ -966,7 +966,7 @@ bool cli_qfilename(struct cli_state *cli, int fnum, char *name, size_t namelen)
Send a qfileinfo call.
****************************************************************************/
-bool cli_qfileinfo(struct cli_state *cli, int fnum,
+bool cli_qfileinfo(struct cli_state *cli, uint16_t fnum,
uint16 *mode, SMB_OFF_T *size,
struct timespec *create_time,
struct timespec *access_time,
@@ -1121,7 +1121,7 @@ bool cli_qpathinfo_basic( struct cli_state *cli, const char *name,
Send a qfileinfo call.
****************************************************************************/
-bool cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutdata, uint32 *poutlen)
+bool cli_qfileinfo_test(struct cli_state *cli, uint16_t fnum, int level, char **poutdata, uint32 *poutlen)
{
unsigned int data_len = 0;
unsigned int param_len = 0;
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 1d2f5f79ec..07d438fd25 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -82,7 +82,7 @@ static void cli_read_andx_done(struct tevent_req *subreq);
struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
struct event_context *ev,
- struct cli_state *cli, int fnum,
+ struct cli_state *cli, uint16_t fnum,
off_t offset, size_t size,
struct tevent_req **psmbreq)
{
@@ -135,7 +135,7 @@ struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
- struct cli_state *cli, int fnum,
+ struct cli_state *cli, uint16_t fnum,
off_t offset, size_t size)
{
struct tevent_req *req, *subreq;
@@ -554,7 +554,7 @@ static NTSTATUS cli_read_sink(char *buf, size_t n, void *priv)
return NT_STATUS_OK;
}
-ssize_t cli_read(struct cli_state *cli, int fnum, char *buf,
+ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
off_t offset, size_t size)
{
NTSTATUS status;
@@ -574,7 +574,7 @@ ssize_t cli_read(struct cli_state *cli, int fnum, char *buf,
****************************************************************************/
static bool cli_issue_write(struct cli_state *cli,
- int fnum,
+ uint16_t fnum,
off_t offset,
uint16 mode,
const char *buf,
@@ -674,7 +674,7 @@ static bool cli_issue_write(struct cli_state *cli,
****************************************************************************/
ssize_t cli_write(struct cli_state *cli,
- int fnum, uint16 write_mode,
+ uint16_t fnum, uint16 write_mode,
const char *buf, off_t offset, size_t size)
{
ssize_t bwritten = 0;
@@ -735,7 +735,7 @@ ssize_t cli_write(struct cli_state *cli,
****************************************************************************/
ssize_t cli_smbwrite(struct cli_state *cli,
- int fnum, char *buf, off_t offset, size_t size1)
+ uint16_t fnum, char *buf, off_t offset, size_t size1)
{
char *p;
ssize_t total = 0;
diff --git a/source3/libsmb/clisecdesc.c b/source3/libsmb/clisecdesc.c
index f0b786c899..1c87eabafe 100644
--- a/source3/libsmb/clisecdesc.c
+++ b/source3/libsmb/clisecdesc.c
@@ -22,7 +22,7 @@
/****************************************************************************
query the security descriptor for a open file
****************************************************************************/
-SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
+SEC_DESC *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
TALLOC_CTX *mem_ctx)
{
uint8_t param[8];
@@ -70,7 +70,7 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
/****************************************************************************
set the security descriptor for a open file
****************************************************************************/
-bool cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
+bool cli_set_secdesc(struct cli_state *cli, uint16_t fnum, SEC_DESC *sd)
{
char param[8];
char *rparam=NULL, *rdata=NULL;
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index aa02807092..4724658fe3 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -47,7 +47,8 @@ SMBC_open_ctx(SMBCCTX *context,
struct cli_state *targetcli = NULL;
SMBCSRV *srv = NULL;
SMBCFILE *file = NULL;
- int fd;
+ uint16_t fd;
+ NTSTATUS status = NT_STATUS_OBJECT_PATH_INVALID;
TALLOC_CTX *frame = talloc_stackframe();
if (!context || !context->internal->initialized) {
@@ -102,7 +103,7 @@ SMBC_open_ctx(SMBCCTX *context,
/* Hmmm, the test for a directory is suspect here ... FIXME */
if (strlen(path) > 0 && path[strlen(path) - 1] == '\\') {
- fd = -1;
+ status = NT_STATUS_OBJECT_PATH_INVALID;
} else {
file = SMB_MALLOC_P(SMBCFILE);
@@ -126,8 +127,9 @@ SMBC_open_ctx(SMBCCTX *context,
}
/*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/
- if ((fd = cli_open(targetcli, targetpath, flags,
- context->internal->share_mode)) < 0) {
+ status = cli_open(targetcli, targetpath, flags,
+ context->internal->share_mode, &fd);
+ if (!NT_STATUS_IS_OK(status)) {
/* Handle the error ... */
@@ -186,7 +188,7 @@ SMBC_open_ctx(SMBCCTX *context,
/* Check if opendir needed ... */
- if (fd == -1) {
+ if (!NT_STATUS_IS_OK(status)) {
int eno = 0;
eno = SMBC_errno(context, srv->cli);
@@ -627,7 +629,7 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
time_t change_time,
uint16 mode)
{
- int fd;
+ uint16_t fd;
int ret;
TALLOC_CTX *frame = talloc_stackframe();
@@ -659,7 +661,7 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
srv->no_pathinfo = True;
/* Open the file */
- if ((fd = cli_open(srv->cli, path, O_RDWR, DENY_NONE)) < 0) {
+ if (!NT_STATUS_IS_OK(cli_open(srv->cli, path, O_RDWR, DENY_NONE, &fd))) {
errno = SMBC_errno(context, srv->cli);
TALLOC_FREE(frame);
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index e4a0a05586..a152830c5d 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -730,7 +730,7 @@ cacl_get(SMBCCTX *context,
bool exclude_dos_inode = False;
bool numeric = True;
bool determine_size = (bufsize == 0);
- int fnum = -1;
+ uint16_t fnum;
SEC_DESC *sd;
fstring sidstr;
fstring name_sandbox;
@@ -901,9 +901,8 @@ cacl_get(SMBCCTX *context,
}
/* ... then obtain any NT attributes which were requested */
- fnum = cli_nt_create(targetcli, targetpath, CREATE_ACCESS_READ);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0, CREATE_ACCESS_READ, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
DEBUG(5, ("cacl_get failed to open %s: %s\n",
targetpath, cli_errstr(targetcli)));
errno = 0;
@@ -1507,7 +1506,7 @@ cacl_set(SMBCCTX *context,
int mode,
int flags)
{
- int fnum;
+ uint16_t fnum = (uint16_t)-1;
int err = 0;
SEC_DESC *sd = NULL, *old;
SEC_ACL *dacl = NULL;
@@ -1560,9 +1559,8 @@ cacl_set(SMBCCTX *context,
/* The desired access below is the only one I could find that works
with NT4, W2KP and Samba */
- fnum = cli_nt_create(targetcli, targetpath, CREATE_ACCESS_READ);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0, CREATE_ACCESS_READ, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
DEBUG(5, ("cacl_set failed to open %s: %s\n",
targetpath, cli_errstr(targetcli)));
errno = 0;
@@ -1666,10 +1664,9 @@ cacl_set(SMBCCTX *context,
sd = make_sec_desc(ctx, old->revision, SEC_DESC_SELF_RELATIVE,
owner_sid, group_sid, NULL, dacl, &sd_size);
- fnum = cli_nt_create(targetcli, targetpath,
- WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0,
+ WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
DEBUG(5, ("cacl_set failed to open %s: %s\n",
targetpath, cli_errstr(targetcli)));
errno = 0;