mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
Get medieval on our ass about SMB1 file descriptors being 16 bits, not an int.
Convert all uses of cli_open(), cli_nt_createXXX to NTSTATUS versions. This is smaller than it looks, it just fixes a lot of old code. Next up, ensure all cli_XX functions return NTSTATUS. Jeremy.
This commit is contained in:
parent
ab4b8c9c04
commit
8cf78ff553
@ -535,12 +535,12 @@ static void display_finfo(file_info *finfo, const char *dir)
|
||||
dir_total += finfo->size;
|
||||
} else {
|
||||
char *afname = NULL;
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
|
||||
/* skip if this is . or .. */
|
||||
if ( strequal(finfo->name,"..") || strequal(finfo->name,".") )
|
||||
return;
|
||||
/* create absolute filename for cli_nt_create() FIXME */
|
||||
/* create absolute filename for cli_ntcreate() FIXME */
|
||||
afname = talloc_asprintf(ctx,
|
||||
"%s%s%s",
|
||||
dir,
|
||||
@ -554,8 +554,9 @@ static void display_finfo(file_info *finfo, const char *dir)
|
||||
d_printf( "MODE:%s\n", attrib_string(finfo->mode));
|
||||
d_printf( "SIZE:%.0f\n", (double)finfo->size);
|
||||
d_printf( "MTIME:%s", time_to_asc(t));
|
||||
fnum = cli_nt_create(finfo->cli, afname, CREATE_ACCESS_READ);
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(finfo->cli, afname, 0,
|
||||
CREATE_ACCESS_READ, 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
DEBUG( 0, ("display_finfo() Failed to open %s: %s\n",
|
||||
afname,
|
||||
cli_errstr( finfo->cli)));
|
||||
@ -999,7 +1000,8 @@ static NTSTATUS writefile_sink(char *buf, size_t n, void *priv)
|
||||
static int do_get(const char *rname, const char *lname_in, bool reget)
|
||||
{
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
int handle = 0, fnum;
|
||||
int handle = 0;
|
||||
uint16_t fnum;
|
||||
bool newhandle = false;
|
||||
struct timeval tp_start;
|
||||
uint16 attr;
|
||||
@ -1028,9 +1030,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
|
||||
|
||||
GetTimeOfDay(&tp_start);
|
||||
|
||||
fnum = cli_open(targetcli, targetname, O_RDONLY, DENY_NONE);
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_open(targetcli, targetname, O_RDONLY, DENY_NONE, &fnum))) {
|
||||
d_printf("%s opening remote file %s\n",cli_errstr(cli),rname);
|
||||
return 1;
|
||||
}
|
||||
@ -1618,7 +1618,7 @@ static int cmd_allinfo(void)
|
||||
static int do_put(const char *rname, const char *lname, bool reput)
|
||||
{
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
XFILE *f;
|
||||
SMB_OFF_T start = 0;
|
||||
int rc = 0;
|
||||
@ -1636,8 +1636,8 @@ static int do_put(const char *rname, const char *lname, bool reput)
|
||||
GetTimeOfDay(&tp_start);
|
||||
|
||||
if (reput) {
|
||||
fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE);
|
||||
if (fnum >= 0) {
|
||||
status = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
if (!cli_qfileinfo(targetcli, fnum, NULL, &start, NULL, NULL, NULL, NULL, NULL) &&
|
||||
!cli_getattrE(targetcli, fnum, NULL, &start, NULL, NULL, NULL)) {
|
||||
d_printf("getattrib: %s\n",cli_errstr(cli));
|
||||
@ -1645,10 +1645,10 @@ static int do_put(const char *rname, const char *lname, bool reput)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
|
||||
status = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum);
|
||||
}
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
d_printf("%s opening remote file %s\n",cli_errstr(targetcli),rname);
|
||||
return 1;
|
||||
}
|
||||
@ -2207,7 +2207,7 @@ static int cmd_open(void)
|
||||
char *buf = NULL;
|
||||
char *targetname = NULL;
|
||||
struct cli_state *targetcli;
|
||||
int fnum;
|
||||
uint16_t fnum = (uint16_t)-1;
|
||||
|
||||
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
|
||||
d_printf("open <filename>\n");
|
||||
@ -2226,10 +2226,12 @@ static int cmd_open(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
fnum = cli_nt_create(targetcli, targetname, FILE_READ_DATA|FILE_WRITE_DATA);
|
||||
if (fnum == -1) {
|
||||
fnum = cli_nt_create(targetcli, targetname, FILE_READ_DATA);
|
||||
if (fnum != -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetname, 0,
|
||||
FILE_READ_DATA|FILE_WRITE_DATA, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
if (NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetname, 0,
|
||||
FILE_READ_DATA, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
d_printf("open file %s: for read/write fnum %d\n", targetname, fnum);
|
||||
} else {
|
||||
d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
|
||||
|
@ -613,7 +613,7 @@ append one remote file to the tar file
|
||||
|
||||
static void do_atar(const char *rname_in,char *lname,file_info *finfo1)
|
||||
{
|
||||
int fnum = -1;
|
||||
uint16_t fnum = (uint16_t)-1;
|
||||
uint64_t nread=0;
|
||||
char ftype;
|
||||
file_info2 finfo;
|
||||
@ -660,9 +660,7 @@ static void do_atar(const char *rname_in,char *lname,file_info *finfo1)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE);
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum))) {
|
||||
DEBUG(0,("%s opening remote file %s (%s)\n",
|
||||
cli_errstr(cli),rname, client_get_cur_dir()));
|
||||
goto cleanup;
|
||||
@ -998,13 +996,14 @@ static int skip_file(int skipsize)
|
||||
|
||||
static int get_file(file_info2 finfo)
|
||||
{
|
||||
int fnum = -1, pos = 0, dsize = 0, bpos = 0;
|
||||
uint16_t fnum;
|
||||
int pos = 0, dsize = 0, bpos = 0;
|
||||
uint64_t rsize = 0;
|
||||
|
||||
DEBUG(5, ("get_file: file: %s, size %.0f\n", finfo.name, (double)finfo.size));
|
||||
|
||||
if (ensurepath(finfo.name) &&
|
||||
(fnum=cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
|
||||
(!NT_STATUS_IS_OK(cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE,&fnum)))) {
|
||||
DEBUG(0, ("abandoning restore\n"));
|
||||
return(False);
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
|
||||
char *title, /* I - Title/job name */
|
||||
FILE * fp)
|
||||
{ /* I - File to print */
|
||||
int fnum; /* File number */
|
||||
uint16_t fnum; /* File number */
|
||||
int nbytes, /* Number of bytes read */
|
||||
tbytes; /* Total bytes read */
|
||||
char buffer[8192], /* Buffer for copy */
|
||||
@ -574,8 +574,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
|
||||
* Open the printer device...
|
||||
*/
|
||||
|
||||
fnum = cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum))) {
|
||||
fprintf(stderr, "ERROR: %s opening remote spool %s\n",
|
||||
cli_errstr(cli), title);
|
||||
return (get_exit_code(cli, cli_nt_error(cli)));
|
||||
|
@ -259,7 +259,7 @@ struct cli_state {
|
||||
bool use_level_II_oplocks; /* should we use level II oplocks? */
|
||||
|
||||
/* a oplock break request handler */
|
||||
bool (*oplock_handler)(struct cli_state *cli, int fnum, unsigned char level);
|
||||
NTSTATUS (*oplock_handler)(struct cli_state *cli, uint16_t fnum, unsigned char level);
|
||||
|
||||
bool force_dos_errors;
|
||||
bool case_sensitive; /* False by default. */
|
||||
|
@ -2375,12 +2375,7 @@ struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
|
||||
const char *dname);
|
||||
NTSTATUS cli_rmdir_recv(struct tevent_req *req);
|
||||
NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
|
||||
int cli_nt_delete_on_close(struct cli_state *cli, int fnum, bool flag);
|
||||
int cli_nt_create_full(struct cli_state *cli, const char *fname,
|
||||
uint32_t CreatFlags, uint32_t DesiredAccess,
|
||||
uint32_t FileAttributes, uint32_t ShareAccess,
|
||||
uint32_t CreateDisposition, uint32_t CreateOptions,
|
||||
uint8_t SecuityFlags);
|
||||
int cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
|
||||
struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev,
|
||||
struct cli_state *cli,
|
||||
@ -2403,7 +2398,6 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
|
||||
uint32_t CreateOptions,
|
||||
uint8_t SecurityFlags,
|
||||
uint16_t *pfid);
|
||||
int cli_nt_create(struct cli_state *cli, const char *fname, uint32_t DesiredAccess);
|
||||
uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
|
||||
size_t str_len, size_t *pconverted_size);
|
||||
struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
|
||||
@ -2414,32 +2408,32 @@ struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
|
||||
struct cli_state *cli, const char *fname,
|
||||
int flags, int share_mode);
|
||||
NTSTATUS cli_open_recv(struct tevent_req *req, int *fnum);
|
||||
int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode);
|
||||
NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
|
||||
NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
|
||||
struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev,
|
||||
struct cli_state *cli, int fnum,
|
||||
struct cli_state *cli, uint16_t fnum,
|
||||
struct tevent_req **psubreq);
|
||||
struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev,
|
||||
struct cli_state *cli, int fnum);
|
||||
struct cli_state *cli, uint16_t fnum);
|
||||
NTSTATUS cli_close_recv(struct tevent_req *req);
|
||||
bool cli_close(struct cli_state *cli, int fnum);
|
||||
bool cli_ftruncate(struct cli_state *cli, int fnum, uint64_t size);
|
||||
NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
|
||||
bool cli_close(struct cli_state *cli, uint16_t fnum);
|
||||
bool cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
|
||||
NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
|
||||
uint32_t offset, uint32_t len,
|
||||
int timeout, unsigned char locktype);
|
||||
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);
|
||||
bool cli_unlock(struct cli_state *cli, int fnum, uint32_t offset, uint32_t len);
|
||||
bool cli_lock64(struct cli_state *cli, int fnum,
|
||||
bool cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
|
||||
bool cli_lock64(struct cli_state *cli, uint16_t fnum,
|
||||
uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type);
|
||||
bool cli_unlock64(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len);
|
||||
bool cli_posix_lock(struct cli_state *cli, int fnum,
|
||||
bool cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
|
||||
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);
|
||||
bool cli_posix_unlock(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len);
|
||||
bool cli_posix_getlock(struct cli_state *cli, int fnum, uint64_t *poffset, uint64_t *plen);
|
||||
bool cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
|
||||
bool cli_posix_getlock(struct cli_state *cli, uint16_t fnum, uint64_t *poffset, uint64_t *plen);
|
||||
bool cli_getattrE(struct cli_state *cli, int fd,
|
||||
uint16_t *attr, SMB_OFF_T *size,
|
||||
time_t *change_time,
|
||||
@ -2465,14 +2459,14 @@ NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
|
||||
int *avail);
|
||||
NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
|
||||
int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path);
|
||||
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);
|
||||
bool cli_set_ea_path(struct cli_state *cli, const char *path, const char *ea_name, const char *ea_val, size_t ea_len);
|
||||
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);
|
||||
bool cli_get_ea_list_path(struct cli_state *cli, const char *path,
|
||||
TALLOC_CTX *ctx,
|
||||
size_t *pnum_eas,
|
||||
struct ea_struct **pea_list);
|
||||
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);
|
||||
@ -2564,9 +2558,9 @@ struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
|
||||
struct cli_state *cli,
|
||||
uint16_t fnum, uint8_t level);
|
||||
NTSTATUS cli_oplock_ack_recv(struct tevent_req *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);
|
||||
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));
|
||||
|
||||
/* The following definitions come from libsmb/cliprint.c */
|
||||
|
||||
@ -2574,11 +2568,11 @@ int cli_print_queue(struct cli_state *cli,
|
||||
void (*fn)(struct print_job_info *));
|
||||
int cli_printjob_del(struct cli_state *cli, int job);
|
||||
int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_mode);
|
||||
bool cli_spl_close(struct cli_state *cli, int fnum);
|
||||
bool cli_spl_close(struct cli_state *cli, uint16_t fnum);
|
||||
|
||||
/* The following definitions come from libsmb/cliquota.c */
|
||||
|
||||
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);
|
||||
void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
|
||||
bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
|
||||
bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
|
||||
@ -2626,8 +2620,8 @@ bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
unsigned int *pnum_streams,
|
||||
struct stream_struct **pstreams);
|
||||
bool cli_qfilename(struct cli_state *cli, int fnum, char *name, size_t namelen);
|
||||
bool cli_qfileinfo(struct cli_state *cli, int fnum,
|
||||
bool cli_qfilename(struct cli_state *cli, uint16_t fnum, char *name, size_t namelen);
|
||||
bool cli_qfileinfo(struct cli_state *cli, uint16_t fnum,
|
||||
uint16 *mode, SMB_OFF_T *size,
|
||||
struct timespec *create_time,
|
||||
struct timespec *access_time,
|
||||
@ -2636,7 +2630,7 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum,
|
||||
SMB_INO_T *ino);
|
||||
bool cli_qpathinfo_basic( struct cli_state *cli, const char *name,
|
||||
SMB_STRUCT_STAT *sbuf, uint32 *attributes );
|
||||
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);
|
||||
NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name);
|
||||
|
||||
/* The following definitions come from libsmb/clirap2.c */
|
||||
@ -2693,12 +2687,12 @@ int cli_NetConnectionEnum(struct cli_state *cli, const char *qualifier,
|
||||
|
||||
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);
|
||||
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);
|
||||
NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
|
||||
uint8_t **rcvbuf);
|
||||
@ -2715,14 +2709,14 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
|
||||
off_t start_offset, SMB_OFF_T size, size_t window_size,
|
||||
NTSTATUS (*sink)(char *buf, size_t n, void *priv),
|
||||
void *priv, SMB_OFF_T *received);
|
||||
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);
|
||||
ssize_t cli_readraw(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
|
||||
ssize_t cli_readraw(struct cli_state *cli, uint16_t fnum, char *buf, off_t offset, size_t size);
|
||||
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 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);
|
||||
struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev,
|
||||
struct cli_state *cli, uint16_t fnum,
|
||||
@ -2753,9 +2747,9 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
|
||||
|
||||
/* The following definitions come from libsmb/clisecdesc.c */
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
/* The following definitions come from libsmb/clispnego.c */
|
||||
|
||||
|
@ -39,15 +39,15 @@ NTSTATUS gpo_copy_file(TALLOC_CTX *mem_ctx,
|
||||
const char *unix_path)
|
||||
{
|
||||
NTSTATUS result;
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
int fd = 0;
|
||||
char *data = NULL;
|
||||
static int io_bufsize = 64512;
|
||||
int read_size = io_bufsize;
|
||||
off_t nread = 0;
|
||||
|
||||
if ((fnum = cli_open(cli, nt_path, O_RDONLY, DENY_NONE)) == -1) {
|
||||
result = NT_STATUS_NO_SUCH_FILE;
|
||||
result = cli_open(cli, nt_path, O_RDONLY, DENY_NONE, &fnum);
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -1406,9 +1406,10 @@ static void progress_bar(unsigned i, unsigned total)
|
||||
bool torture_denytest1(int dummy)
|
||||
{
|
||||
struct cli_state *cli1;
|
||||
int fnum1, fnum2;
|
||||
uint16_t fnum1, fnum2;
|
||||
int i;
|
||||
bool correct = True;
|
||||
NTSTATUS ret1, ret2;
|
||||
const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"};
|
||||
|
||||
if (!torture_open_connection(&cli1, 0)) {
|
||||
@ -1419,7 +1420,7 @@ bool torture_denytest1(int dummy)
|
||||
|
||||
for (i=0;i<2;i++) {
|
||||
cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
|
||||
fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
|
||||
cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1);
|
||||
cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
|
||||
cli_close(cli1, fnum1);
|
||||
}
|
||||
@ -1432,16 +1433,16 @@ bool torture_denytest1(int dummy)
|
||||
|
||||
progress_bar(i, ARRAY_SIZE(denytable1));
|
||||
|
||||
fnum1 = cli_open(cli1, fname,
|
||||
ret1 = cli_open(cli1, fname,
|
||||
denytable1[i].mode1,
|
||||
denytable1[i].deny1);
|
||||
fnum2 = cli_open(cli1, fname,
|
||||
denytable1[i].deny1, &fnum1);
|
||||
ret2 = cli_open(cli1, fname,
|
||||
denytable1[i].mode2,
|
||||
denytable1[i].deny2);
|
||||
denytable1[i].deny2, &fnum2);
|
||||
|
||||
if (fnum1 == -1) {
|
||||
if (!NT_STATUS_IS_OK(ret1)) {
|
||||
res = A_X;
|
||||
} else if (fnum2 == -1) {
|
||||
} else if (!NT_STATUS_IS_OK(ret2)) {
|
||||
res = A_0;
|
||||
} else {
|
||||
char x = 1;
|
||||
@ -1492,9 +1493,10 @@ bool torture_denytest1(int dummy)
|
||||
bool torture_denytest2(int dummy)
|
||||
{
|
||||
static struct cli_state *cli1, *cli2;
|
||||
int fnum1, fnum2;
|
||||
uint16_t fnum1, fnum2;
|
||||
int i;
|
||||
bool correct = True;
|
||||
NTSTATUS ret1, ret2;
|
||||
const char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"};
|
||||
|
||||
if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
|
||||
@ -1505,7 +1507,7 @@ bool torture_denytest2(int dummy)
|
||||
|
||||
for (i=0;i<2;i++) {
|
||||
cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
|
||||
fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
|
||||
cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1);
|
||||
cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
|
||||
cli_close(cli1, fnum1);
|
||||
}
|
||||
@ -1516,16 +1518,16 @@ bool torture_denytest2(int dummy)
|
||||
|
||||
progress_bar(i, ARRAY_SIZE(denytable2));
|
||||
|
||||
fnum1 = cli_open(cli1, fname,
|
||||
ret1 = cli_open(cli1, fname,
|
||||
denytable2[i].mode1,
|
||||
denytable2[i].deny1);
|
||||
fnum2 = cli_open(cli2, fname,
|
||||
denytable2[i].deny1, &fnum1);
|
||||
ret2 = cli_open(cli2, fname,
|
||||
denytable2[i].mode2,
|
||||
denytable2[i].deny2);
|
||||
denytable2[i].deny2, &fnum2);
|
||||
|
||||
if (fnum1 == -1) {
|
||||
if (!NT_STATUS_IS_OK(ret1)) {
|
||||
res = A_X;
|
||||
} else if (fnum2 == -1) {
|
||||
} else if (!NT_STATUS_IS_OK(ret2)) {
|
||||
res = A_0;
|
||||
} else {
|
||||
char x = 1;
|
||||
|
@ -273,7 +273,7 @@ static struct cli_state *connect_one(char *share, int snum)
|
||||
}
|
||||
|
||||
|
||||
static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
|
||||
static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES],
|
||||
char *share[NSERVERS])
|
||||
{
|
||||
int server, conn, f;
|
||||
@ -282,9 +282,9 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NS
|
||||
for (conn=0;conn<NCONNECTIONS;conn++) {
|
||||
if (cli[server][conn]) {
|
||||
for (f=0;f<NFILES;f++) {
|
||||
if (fnum[server][conn][f] != -1) {
|
||||
if (fnum[server][conn][f] != (uint16_t)-1) {
|
||||
cli_close(cli[server][conn], fnum[server][conn][f]);
|
||||
fnum[server][conn][f] = -1;
|
||||
fnum[server][conn][f] = (uint16_t)-1;
|
||||
}
|
||||
}
|
||||
cli_ulogoff(cli[server][conn]);
|
||||
@ -301,7 +301,7 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NS
|
||||
|
||||
|
||||
static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
int fnum[NSERVERS][NCONNECTIONS][NFILES],
|
||||
uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES],
|
||||
struct record *rec)
|
||||
{
|
||||
unsigned conn = rec->conn;
|
||||
@ -362,13 +362,13 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
/* reopen the file */
|
||||
for (server=0;server<NSERVERS;server++) {
|
||||
cli_close(cli[server][conn], fnum[server][conn][f]);
|
||||
fnum[server][conn][f] = -1;
|
||||
fnum[server][conn][f] = (uint16_t)-1;
|
||||
}
|
||||
for (server=0;server<NSERVERS;server++) {
|
||||
fnum[server][conn][f] = cli_open(cli[server][conn], FILENAME,
|
||||
fnum[server][conn][f] = (uint16_t)-1;
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli[server][conn], FILENAME,
|
||||
O_RDWR|O_CREAT,
|
||||
DENY_NONE);
|
||||
if (fnum[server][conn][f] == -1) {
|
||||
DENY_NONE, &fnum[server][conn][f]))) {
|
||||
printf("failed to reopen on share%d\n", server);
|
||||
return False;
|
||||
}
|
||||
@ -385,16 +385,16 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
}
|
||||
|
||||
static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
int fnum[NSERVERS][NCONNECTIONS][NFILES])
|
||||
uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES])
|
||||
{
|
||||
int server, conn, f;
|
||||
|
||||
for (server=0;server<NSERVERS;server++)
|
||||
for (conn=0;conn<NCONNECTIONS;conn++)
|
||||
for (f=0;f<NFILES;f++) {
|
||||
if (fnum[server][conn][f] != -1) {
|
||||
if (fnum[server][conn][f] != (uint16_t)-1) {
|
||||
cli_close(cli[server][conn], fnum[server][conn][f]);
|
||||
fnum[server][conn][f] = -1;
|
||||
fnum[server][conn][f] = (uint16_t)-1;
|
||||
}
|
||||
}
|
||||
for (server=0;server<NSERVERS;server++) {
|
||||
@ -403,17 +403,18 @@ static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
}
|
||||
|
||||
static void open_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
int fnum[NSERVERS][NCONNECTIONS][NFILES])
|
||||
uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES])
|
||||
{
|
||||
int server, conn, f;
|
||||
|
||||
for (server=0;server<NSERVERS;server++)
|
||||
for (conn=0;conn<NCONNECTIONS;conn++)
|
||||
for (f=0;f<NFILES;f++) {
|
||||
fnum[server][conn][f] = cli_open(cli[server][conn], FILENAME,
|
||||
fnum[server][conn][f] = (uint16_t)-1;
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli[server][conn], FILENAME,
|
||||
O_RDWR|O_CREAT,
|
||||
DENY_NONE);
|
||||
if (fnum[server][conn][f] == -1) {
|
||||
DENY_NONE,
|
||||
&fnum[server][conn][f]))) {
|
||||
fprintf(stderr,"Failed to open fnum[%u][%u][%u]\n",
|
||||
server, conn, f);
|
||||
exit(1);
|
||||
@ -423,7 +424,7 @@ static void open_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
|
||||
|
||||
static int retest(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
int fnum[NSERVERS][NCONNECTIONS][NFILES],
|
||||
uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES],
|
||||
int n)
|
||||
{
|
||||
int i;
|
||||
@ -449,7 +450,7 @@ static int retest(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
static void test_locks(char *share[NSERVERS])
|
||||
{
|
||||
struct cli_state *cli[NSERVERS][NCONNECTIONS];
|
||||
int fnum[NSERVERS][NCONNECTIONS][NFILES];
|
||||
uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES];
|
||||
int n, i, n1, skip, r1, r2;
|
||||
|
||||
ZERO_STRUCT(fnum);
|
||||
|
@ -68,7 +68,13 @@ static int try_open(struct cli_state *c, char *nfs, int fstype, const char *fnam
|
||||
|
||||
switch (fstype) {
|
||||
case FSTYPE_SMB:
|
||||
return cli_open(c, fname, flags, DENY_NONE);
|
||||
{
|
||||
uint16_t fd;
|
||||
if (!NT_STATUS_IS_OK(cli_open(c, fname, flags, DENY_NONE, &fd))) {
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
case FSTYPE_NFS:
|
||||
if (asprintf(&path, "%s%s", nfs, fname) > 0) {
|
||||
|
@ -29,7 +29,7 @@ static unsigned total, collisions, failures;
|
||||
|
||||
static bool test_one(struct cli_state *cli, const char *name)
|
||||
{
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
fstring shortname;
|
||||
fstring name2;
|
||||
NTSTATUS status;
|
||||
@ -37,8 +37,7 @@ static bool test_one(struct cli_state *cli, const char *name)
|
||||
|
||||
total++;
|
||||
|
||||
fnum = cli_open(cli, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
|
||||
printf("open of %s failed (%s)\n", name, cli_errstr(cli));
|
||||
return False;
|
||||
}
|
||||
@ -63,8 +62,7 @@ static bool test_one(struct cli_state *cli, const char *name)
|
||||
}
|
||||
|
||||
/* recreate by short name */
|
||||
fnum = cli_open(cli, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
|
||||
printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli));
|
||||
return False;
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ static void get_real_name(struct cli_state *cli,
|
||||
|
||||
static void testpair(struct cli_state *cli, const char *mask, const char *file)
|
||||
{
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
fstring res1;
|
||||
char *res2;
|
||||
static int count;
|
||||
@ -322,8 +322,7 @@ static void testpair(struct cli_state *cli, const char *mask, const char *file)
|
||||
|
||||
fstrcpy(res1, "---");
|
||||
|
||||
fnum = cli_open(cli, file, O_CREAT|O_TRUNC|O_RDWR, 0);
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, file, O_CREAT|O_TRUNC|O_RDWR, 0, &fnum))) {
|
||||
DEBUG(0,("Can't create %s\n", file));
|
||||
return;
|
||||
}
|
||||
|
@ -140,7 +140,9 @@ void nb_unlink(const char *fname)
|
||||
void nb_createx(const char *fname,
|
||||
unsigned create_options, unsigned create_disposition, int handle)
|
||||
{
|
||||
int fd, i;
|
||||
uint16_t fd = (uint16_t)-1;
|
||||
int i;
|
||||
NTSTATUS status;
|
||||
uint32 desired_access;
|
||||
|
||||
if (create_options & FILE_DIRECTORY_FILE) {
|
||||
@ -149,22 +151,22 @@ void nb_createx(const char *fname,
|
||||
desired_access = FILE_READ_DATA | FILE_WRITE_DATA;
|
||||
}
|
||||
|
||||
fd = cli_nt_create_full(c, fname, 0,
|
||||
status = cli_ntcreate(c, fname, 0,
|
||||
desired_access,
|
||||
0x0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
create_disposition,
|
||||
create_options, 0);
|
||||
if (fd == -1 && handle != -1) {
|
||||
printf("ERROR: cli_nt_create_full failed for %s - %s\n",
|
||||
create_options, 0, &fd);
|
||||
if (!NT_STATUS_IS_OK(status) && handle != -1) {
|
||||
printf("ERROR: cli_ntcreate failed for %s - %s\n",
|
||||
fname, cli_errstr(c));
|
||||
exit(1);
|
||||
}
|
||||
if (fd != -1 && handle == -1) {
|
||||
printf("ERROR: cli_nt_create_full succeeded for %s\n", fname);
|
||||
if (NT_STATUS_IS_OK(status) && handle == -1) {
|
||||
printf("ERROR: cli_ntcreate succeeded for %s\n", fname);
|
||||
exit(1);
|
||||
}
|
||||
if (fd == -1) return;
|
||||
if (fd == (uint16_t)-1) return;
|
||||
|
||||
for (i=0;i<MAX_FILES;i++) {
|
||||
if (ftable[i].handle == 0) break;
|
||||
|
@ -194,7 +194,7 @@ bool torture_trans2_scan(int dummy)
|
||||
static struct cli_state *cli;
|
||||
int op, level;
|
||||
const char *fname = "\\scanner.dat";
|
||||
int fnum, dnum;
|
||||
uint16_t fnum, dnum;
|
||||
|
||||
printf("starting trans2 scan test\n");
|
||||
|
||||
@ -202,9 +202,15 @@ bool torture_trans2_scan(int dummy)
|
||||
return False;
|
||||
}
|
||||
|
||||
fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
|
||||
DENY_NONE);
|
||||
dnum = cli_open(cli, "\\", O_RDONLY, DENY_NONE);
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
|
||||
DENY_NONE, &fnum))) {
|
||||
printf("open of %s failed\n", fname);
|
||||
return false;
|
||||
}
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, "\\", O_RDONLY, DENY_NONE, &dnum))) {
|
||||
printf("open of \\ failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (op=OP_MIN; op<=OP_MAX; op++) {
|
||||
printf("Scanning op=%d\n", op);
|
||||
@ -396,7 +402,7 @@ bool torture_nttrans_scan(int dummy)
|
||||
static struct cli_state *cli;
|
||||
int op, level;
|
||||
const char *fname = "\\scanner.dat";
|
||||
int fnum, dnum;
|
||||
uint16_t fnum, dnum;
|
||||
|
||||
printf("starting nttrans scan test\n");
|
||||
|
||||
@ -404,9 +410,9 @@ bool torture_nttrans_scan(int dummy)
|
||||
return False;
|
||||
}
|
||||
|
||||
fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
|
||||
DENY_NONE);
|
||||
dnum = cli_open(cli, "\\", O_RDONLY, DENY_NONE);
|
||||
cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
|
||||
DENY_NONE, &fnum);
|
||||
cli_open(cli, "\\", O_RDONLY, DENY_NONE, &dnum);
|
||||
|
||||
for (op=OP_MIN; op<=OP_MAX; op++) {
|
||||
printf("Scanning op=%d\n", op);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@ bool torture_utable(int dummy)
|
||||
{
|
||||
struct cli_state *cli;
|
||||
fstring fname, alt_name;
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
smb_ucs2_t c2;
|
||||
int c, len, fd;
|
||||
int chars_allowed=0, alt_allowed=0;
|
||||
@ -52,9 +52,10 @@ bool torture_utable(int dummy)
|
||||
p[len] = 0;
|
||||
fstrcat(fname,"_a_long_extension");
|
||||
|
||||
fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
|
||||
DENY_NONE);
|
||||
if (fnum == -1) continue;
|
||||
if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
|
||||
DENY_NONE, &fnum))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chars_allowed++;
|
||||
|
||||
@ -118,7 +119,7 @@ bool torture_casetable(int dummy)
|
||||
{
|
||||
static struct cli_state *cli;
|
||||
char *fname;
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
int c, i;
|
||||
#define MAX_EQUIVALENCE 8
|
||||
smb_ucs2_t equiv[0x10000][MAX_EQUIVALENCE];
|
||||
@ -145,13 +146,11 @@ bool torture_casetable(int dummy)
|
||||
printf("%04x (%c)\n", c, isprint(c)?c:'.');
|
||||
|
||||
fname = form_name(c);
|
||||
fnum = cli_nt_create_full(cli, fname, 0,
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, fname, 0,
|
||||
GENERIC_ALL_ACCESS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
FILE_SHARE_NONE,
|
||||
FILE_OPEN_IF, 0, 0);
|
||||
|
||||
if (fnum == -1) {
|
||||
FILE_OPEN_IF, 0, 0, &fnum))) {
|
||||
printf("Failed to create file with char %04x\n", c);
|
||||
continue;
|
||||
}
|
||||
|
@ -4249,7 +4249,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
|
||||
int num_tokens,
|
||||
struct user_token *tokens)
|
||||
{
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
SEC_DESC *share_sd = NULL;
|
||||
SEC_DESC *root_sd = NULL;
|
||||
struct cli_state *cli = rpc_pipe_np_smb_conn(pipe_hnd);
|
||||
@ -4284,9 +4284,8 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd,
|
||||
return;
|
||||
}
|
||||
|
||||
fnum = cli_nt_create(cli, "\\", READ_CONTROL_ACCESS);
|
||||
|
||||
if (fnum != -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, "\\", 0, READ_CONTROL_ACCESS, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
root_sd = cli_query_secdesc(cli, fnum, mem_ctx);
|
||||
}
|
||||
|
||||
|
@ -155,8 +155,8 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
|
||||
bool copy_timestamps, bool is_file)
|
||||
{
|
||||
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
||||
int fnum_src = 0;
|
||||
int fnum_dst = 0;
|
||||
uint16_t fnum_src = 0;
|
||||
uint16_t fnum_dst = 0;
|
||||
SEC_DESC *sd = NULL;
|
||||
uint16_t attr;
|
||||
time_t f_atime, f_ctime, f_mtime;
|
||||
@ -170,8 +170,8 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
|
||||
DEBUGADD(3,("opening %s %s on originating server\n",
|
||||
is_file?"file":"dir", src_name));
|
||||
|
||||
fnum_src = cli_nt_create(cli_share_src, src_name, READ_CONTROL_ACCESS);
|
||||
if (fnum_src == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src))) {
|
||||
DEBUGADD(0,("cannot open %s %s on originating server %s\n",
|
||||
is_file?"file":"dir", src_name, cli_errstr(cli_share_src)));
|
||||
nt_status = cli_nt_error(cli_share_src);
|
||||
@ -210,8 +210,8 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
|
||||
|
||||
/* open the file/dir on the destination server */
|
||||
|
||||
fnum_dst = cli_nt_create(cli_share_dst, dst_name, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS);
|
||||
if (fnum_dst == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_dst, dst_name, 0, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_dst))) {
|
||||
DEBUG(0,("failed to open %s on the destination server: %s: %s\n",
|
||||
is_file?"file":"dir", dst_name, cli_errstr(cli_share_dst)));
|
||||
nt_status = cli_nt_error(cli_share_dst);
|
||||
@ -309,8 +309,8 @@ NTSTATUS net_copy_file(struct net_context *c,
|
||||
bool copy_timestamps, bool is_file)
|
||||
{
|
||||
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
||||
int fnum_src = 0;
|
||||
int fnum_dst = 0;
|
||||
uint16_t fnum_src = 0;
|
||||
uint16_t fnum_dst = 0;
|
||||
static int io_bufsize = 64512;
|
||||
int read_size = io_bufsize;
|
||||
char *data = NULL;
|
||||
@ -327,15 +327,15 @@ NTSTATUS net_copy_file(struct net_context *c,
|
||||
DEBUGADD(3,("opening %s %s on originating server\n",
|
||||
is_file ? "file":"dir", src_name));
|
||||
if (is_file)
|
||||
fnum_src = cli_open(cli_share_src, src_name, O_RDONLY, DENY_NONE);
|
||||
nt_status = cli_open(cli_share_src, src_name, O_RDONLY, DENY_NONE, &fnum_src);
|
||||
else
|
||||
fnum_src = cli_nt_create(cli_share_src, src_name, READ_CONTROL_ACCESS);
|
||||
nt_status = cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src);
|
||||
|
||||
if (fnum_src == -1) {
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
DEBUGADD(0,("cannot open %s %s on originating server %s\n",
|
||||
is_file ? "file":"dir",
|
||||
src_name, cli_errstr(cli_share_src)));
|
||||
nt_status = cli_nt_error(cli_share_src);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -344,13 +344,12 @@ NTSTATUS net_copy_file(struct net_context *c,
|
||||
|
||||
/* open file on the destination server */
|
||||
DEBUGADD(3,("opening file %s on destination server\n", dst_name));
|
||||
fnum_dst = cli_open(cli_share_dst, dst_name,
|
||||
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
|
||||
nt_status = cli_open(cli_share_dst, dst_name,
|
||||
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum_dst);
|
||||
|
||||
if (fnum_dst == -1) {
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
DEBUGADD(1,("cannot create file %s on destination server: %s\n",
|
||||
dst_name, cli_errstr(cli_share_dst)));
|
||||
nt_status = cli_nt_error(cli_share_dst);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -660,15 +660,14 @@ dump the acls for a file
|
||||
static int cacl_dump(struct cli_state *cli, char *filename)
|
||||
{
|
||||
int result = EXIT_FAILED;
|
||||
int fnum = -1;
|
||||
uint16_t fnum = (uint16_t)-1;
|
||||
SEC_DESC *sd;
|
||||
|
||||
if (test_args)
|
||||
return EXIT_OK;
|
||||
|
||||
fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
|
||||
goto done;
|
||||
}
|
||||
@ -685,7 +684,7 @@ static int cacl_dump(struct cli_state *cli, char *filename)
|
||||
result = EXIT_OK;
|
||||
|
||||
done:
|
||||
if (fnum != -1)
|
||||
if (fnum != (uint16_t)-1)
|
||||
cli_close(cli, fnum);
|
||||
|
||||
return result;
|
||||
@ -699,14 +698,13 @@ because the NT docs say this can't be done :-). JRA.
|
||||
static int owner_set(struct cli_state *cli, enum chown_mode change_mode,
|
||||
const char *filename, const char *new_username)
|
||||
{
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
DOM_SID sid;
|
||||
SEC_DESC *sd, *old;
|
||||
size_t sd_size;
|
||||
|
||||
fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
|
||||
return EXIT_FAILED;
|
||||
}
|
||||
@ -728,9 +726,8 @@ static int owner_set(struct cli_state *cli, enum chown_mode change_mode,
|
||||
(change_mode == REQUEST_CHGRP) ? &sid : NULL,
|
||||
NULL, NULL, &sd_size);
|
||||
|
||||
fnum = cli_nt_create(cli, filename, WRITE_OWNER_ACCESS);
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, WRITE_OWNER_ACCESS, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
|
||||
return EXIT_FAILED;
|
||||
}
|
||||
@ -815,7 +812,7 @@ set the ACLs on a file given an ascii description
|
||||
static int cacl_set(struct cli_state *cli, char *filename,
|
||||
char *the_acl, enum acl_mode mode)
|
||||
{
|
||||
int fnum;
|
||||
uint16_t fnum;
|
||||
SEC_DESC *sd, *old;
|
||||
uint32 i, j;
|
||||
size_t sd_size;
|
||||
@ -829,9 +826,8 @@ static int cacl_set(struct cli_state *cli, char *filename,
|
||||
/* The desired access below is the only one I could find that works
|
||||
with NT4, W2KP and Samba */
|
||||
|
||||
fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
printf("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli));
|
||||
return EXIT_FAILED;
|
||||
}
|
||||
@ -930,9 +926,8 @@ static int cacl_set(struct cli_state *cli, char *filename,
|
||||
old->owner_sid, old->group_sid,
|
||||
NULL, old->dacl, &sd_size);
|
||||
|
||||
fnum = cli_nt_create(cli, filename, WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS);
|
||||
|
||||
if (fnum == -1) {
|
||||
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS, 0,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
|
||||
printf("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli));
|
||||
return EXIT_FAILED;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ static int do_quota(struct cli_state *cli,
|
||||
SMB_NTQUOTA_STRUCT *pqt)
|
||||
{
|
||||
uint32 fs_attrs = 0;
|
||||
int quota_fnum = 0;
|
||||
uint16_t quota_fnum = 0;
|
||||
SMB_NTQUOTA_LIST *qtl = NULL;
|
||||
SMB_NTQUOTA_STRUCT qt;
|
||||
ZERO_STRUCT(qt);
|
||||
@ -246,7 +246,7 @@ static int do_quota(struct cli_state *cli,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!cli_get_quota_handle(cli, "a_fnum)) {
|
||||
if (!NT_STATUS_IS_OK(cli_get_quota_handle(cli, "a_fnum))) {
|
||||
d_printf("Quotas are not enabled on this share.\n");
|
||||
d_printf("Failed to open %s %s.\n",
|
||||
FAKE_FILE_NAME_QUOTA_WIN32,cli_errstr(cli));
|
||||
|
Loading…
Reference in New Issue
Block a user