The branch, master has been updated via 46551d7 Fix bug #8644 - vfs_acl_xattr and vfs_acl_tdb modules can fail to add inheritable entries on a directory with no stored ACL. via 3e0d923 Ensure we map our own Samba return of ERRSRV, ERRunknownsmb on an unknown SMB request to NT_STATUS_NOT_IMPLEMENTED. via 0105662 Convert smbclient to using NtCreateX by preference, fall back to openX on 'not implemented' or similar error. from a47780a s3: Fix some nonblank line endings
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 46551d750dc58b32630fb6744364fe5a1052b87d Author: Jeremy Allison <j...@samba.org> Date: Fri Dec 2 10:55:40 2011 -0800 Fix bug #8644 - vfs_acl_xattr and vfs_acl_tdb modules can fail to add inheritable entries on a directory with no stored ACL. If referring to an fsp sbuf can be left as an uninitialized variable, causing the 'is_directory' variable to be false when it should be true. Autobuild-User: Jeremy Allison <j...@samba.org> Autobuild-Date: Fri Dec 2 22:13:03 CET 2011 on sn-devel-104 commit 3e0d923096cddcbf83cfa2d9594df5fa21331650 Author: Jeremy Allison <j...@samba.org> Date: Fri Dec 2 10:28:23 2011 -0800 Ensure we map our own Samba return of ERRSRV, ERRunknownsmb on an unknown SMB request to NT_STATUS_NOT_IMPLEMENTED. commit 010566215b4d76ae5348652e1f8f175b1895849a Author: Jeremy Allison <j...@samba.org> Date: Fri Dec 2 10:11:17 2011 -0800 Convert smbclient to using NtCreateX by preference, fall back to openX on 'not implemented' or similar error. ----------------------------------------------------------------------- Summary of changes: source3/client/client.c | 121 +++++++++++++++++++++++++++++++++++++- source3/client/client_proto.h | 2 + source3/client/clitar.c | 4 +- source3/libsmb/errormap.c | 1 + source3/modules/vfs_acl_common.c | 2 +- 5 files changed, 124 insertions(+), 6 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/client/client.c b/source3/client/client.c index 47d4470..b355917 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -301,6 +301,121 @@ static void send_message(const char *username) } /**************************************************************************** + Wrapper function around cli_open() that does an NtCreateX open by preference. +****************************************************************************/ + +NTSTATUS smbclient_cli_open(struct cli_state *cli, const char *fname, int flags, + int share_mode_in, uint16_t *pfnum) +{ + NTSTATUS status; + unsigned int openfn = 0; + unsigned int dos_deny = 0; + uint32_t access_mask, share_mode, create_disposition, create_options; + + /* Do the initial mapping into OpenX parameters. */ + if (flags & O_CREAT) { + openfn |= (1<<4); + } + if (!(flags & O_EXCL)) { + if (flags & O_TRUNC) + openfn |= (1<<1); + else + openfn |= (1<<0); + } + + dos_deny = (share_mode_in<<4); + + if ((flags & O_ACCMODE) == O_RDWR) { + dos_deny |= 2; + } else if ((flags & O_ACCMODE) == O_WRONLY) { + dos_deny |= 1; + } + +#if defined(O_SYNC) + if ((flags & O_SYNC) == O_SYNC) { + dos_deny |= (1<<14); + } +#endif /* O_SYNC */ + + if (share_mode_in == DENY_FCB) { + dos_deny = 0xFF; + } + +#if 0 + /* Hmmm. This is what I think the above code + should look like if it's using the constants + we #define. JRA. */ + + if (flags & O_CREAT) { + openfn |= OPENX_FILE_CREATE_IF_NOT_EXIST; + } + if (!(flags & O_EXCL)) { + if (flags & O_TRUNC) + openfn |= OPENX_FILE_EXISTS_TRUNCATE; + else + openfn |= OPENX_FILE_EXISTS_OPEN; + } + + dos_deny = SET_DENY_MODE(share_mode_in); + + if ((flags & O_ACCMODE) == O_RDWR) { + dos_deny |= DOS_OPEN_RDWR; + } else if ((flags & O_ACCMODE) == O_WRONLY) { + dos_deny |= DOS_OPEN_WRONLY; + } + +#if defined(O_SYNC) + if ((flags & O_SYNC) == O_SYNC) { + dos_deny |= FILE_SYNC_OPENMODE; + } +#endif /* O_SYNC */ + + if (share_mode_in == DENY_FCB) { + dos_deny = 0xFF; + } +#endif + + if (!map_open_params_to_ntcreate(fname, dos_deny, + openfn, &access_mask, + &share_mode, &create_disposition, + &create_options, NULL)) { + goto try_openx; + } + + status = cli_ntcreate(cli, + fname, + 0, + access_mask, + 0, + share_mode, + create_disposition, + create_options, + 0, + pfnum); + + /* Try and cope will all varients of "we don't do this call" + and fall back to openX. */ + + if (NT_STATUS_EQUAL(status,NT_STATUS_NOT_IMPLEMENTED) || + NT_STATUS_EQUAL(status,NT_STATUS_INVALID_INFO_CLASS) || + NT_STATUS_EQUAL(status,NT_STATUS_PROCEDURE_NOT_FOUND) || + NT_STATUS_EQUAL(status,NT_STATUS_INVALID_LEVEL) || + NT_STATUS_EQUAL(status,NT_STATUS_INVALID_PARAMETER) || + NT_STATUS_EQUAL(status,NT_STATUS_INVALID_DEVICE_REQUEST) || + NT_STATUS_EQUAL(status,NT_STATUS_INVALID_DEVICE_STATE) || + NT_STATUS_EQUAL(status,NT_STATUS_CTL_FILE_NOT_SUPPORTED) || + NT_STATUS_EQUAL(status,NT_STATUS_UNSUCCESSFUL)) { + goto try_openx; + } + + return status; + + try_openx: + + return cli_open(cli, fname, flags, share_mode_in, pfnum); +} + +/**************************************************************************** Check the space on a device. ****************************************************************************/ @@ -1097,7 +1212,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget) clock_gettime_mono(&tp_start); - status = cli_open(targetcli, targetname, O_RDONLY, DENY_NONE, &fnum); + status = smbclient_cli_open(targetcli, targetname, O_RDONLY, DENY_NONE, &fnum); if (!NT_STATUS_IS_OK(status)) { d_printf("%s opening remote file %s\n", nt_errstr(status), rname); @@ -1856,7 +1971,7 @@ static int do_put(const char *rname, const char *lname, bool reput) clock_gettime_mono(&tp_start); if (reput) { - status = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum); + status = smbclient_cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum); if (NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status = cli_qfileinfo_basic( targetcli, fnum, NULL, @@ -1871,7 +1986,7 @@ static int do_put(const char *rname, const char *lname, bool reput) } } } else { - status = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum); + status = smbclient_cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum); } if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/client/client_proto.h b/source3/client/client_proto.h index d119014..3032e5b 100644 --- a/source3/client/client_proto.h +++ b/source3/client/client_proto.h @@ -30,6 +30,8 @@ struct file_info; const char *client_get_cur_dir(void); const char *client_set_cur_dir(const char *newdir); +NTSTATUS smbclient_cli_open(struct cli_state *cli, const char *fname, int flags, + int share_mode_in, uint16_t *pfnum); NTSTATUS do_list(const char *mask, uint16 attribute, NTSTATUS (*fn)(struct cli_state *cli_state, struct file_info *, diff --git a/source3/client/clitar.c b/source3/client/clitar.c index 5943926..d8890ea 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -655,7 +655,7 @@ static NTSTATUS do_atar(const char *rname_in, char *lname, goto cleanup; } - status = cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum); + status = smbclient_cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("%s opening remote file %s (%s)\n", nt_errstr(status),rname, client_get_cur_dir())); @@ -1016,7 +1016,7 @@ static int get_file(file_info2 finfo) return False; } - status = cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum); + status = smbclient_cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("abandoning restore\n")); return False; diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c index 975de4f..b80065d 100644 --- a/source3/libsmb/errormap.c +++ b/source3/libsmb/errormap.c @@ -166,6 +166,7 @@ static const struct { {ERRSRV, ERRnoroom, NT_STATUS_DISK_FULL}, {ERRSRV, ERRnoresource, NT_STATUS_REQUEST_NOT_ACCEPTED}, {ERRSRV, ERRtoomanyuids, NT_STATUS_TOO_MANY_SESSIONS}, + {ERRSRV, ERRunknownsmb, NT_STATUS_NOT_IMPLEMENTED}, {ERRSRV, 123, NT_STATUS_OBJECT_NAME_INVALID}, {ERRSRV, 206, NT_STATUS_OBJECT_NAME_INVALID}, {ERRHRD, 1, NT_STATUS_NOT_IMPLEMENTED}, diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c index 00ac2a1..bf535c5 100644 --- a/source3/modules/vfs_acl_common.c +++ b/source3/modules/vfs_acl_common.c @@ -391,7 +391,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle, return map_nt_error_from_unix(errno); } } - is_directory = S_ISDIR(sbuf.st_ex_mode); + is_directory = S_ISDIR(psbuf->st_ex_mode); if (ignore_file_system_acl) { TALLOC_FREE(pdesc_next); -- Samba Shared Repository