The branch, v4-1-test has been updated via a3d2970 s3: modules: Fix *allocate* calls to follow POSIX error return convention. via 1a128c4 s3: smbd: Fix *allocate* calls to follow POSIX error return convention. via 5b5546b s3: smbd: Fix *allocate* calls to follow POSIX error return convention. via 8999aca s3-libsmb: Duplicate the memory before we free it. via 4051499 s3-libsmb: Set the netbios_name in use_ccache case too. via 8ca520e s3-lib: Do not require a password with --use-ccache. via 6e030c2 pam_winbind: fix warn_pwd_expire implementation. from 2bea37d libcli: SMB2: Pure SMB2-only negprot fix to make us behave as a Windows client does.
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-1-test - Log ----------------------------------------------------------------- commit a3d2970d58401035ff09bd31c36ed5d69e02b140 Author: Jeremy Allison <j...@samba.org> Date: Sun Dec 7 18:59:26 2014 -0800 s3: modules: Fix *allocate* calls to follow POSIX error return convention. Fix up the ceph, time_audit and streams_xattr modules to follow the -1,errno convention for errors. Reported by Jones <jones.k...@gmail.com> who provided the initial patch. This patch tested and confirmed working by him as well. Signed-off-by: Jeremy Allison <j...@samba.org> Autobuild-User(v4-1-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-1-test): Mon Dec 8 12:29:00 CET 2014 on sn-devel-104 commit 1a128c4b44aa33760803d2326eca5dcd5a48cb8a Author: Jeremy Allison <j...@samba.org> Date: Fri Dec 5 15:34:12 2014 -0800 s3: smbd: Fix *allocate* calls to follow POSIX error return convention. Fix vfs_allocate_file_space(), vfs_slow_fallocate(), vfs_fill_sparse() to follow the -1,errno convention for errors. Standardize on the -1,errno convention. Reported by Jones <jones.k...@gmail.com> who provided the initial patch. This patch tested and confirmed working by him as well. https://bugzilla.samba.org/show_bug.cgi?id=10982 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: David Disseldorp <dd...@suse.de> (cherry picked from commit cc1f91cec627cb3e4fc89b96aae1e7e4c539cd1c) commit 5b5546b28a401d7cc77402455b62ea5f69753499 Author: Jeremy Allison <j...@samba.org> Date: Fri Dec 5 15:31:19 2014 -0800 s3: smbd: Fix *allocate* calls to follow POSIX error return convention. vfswrap_fallocate() is broken in that it can call posix_fallocate() which returns an int error (and doesn't set errno) but can also call Linux fallocate() which returns -1 and sets errno. Standardize on the -1,errno convention. Reported by Jones <jones.k...@gmail.com> who provided the initial patch. This patch tested and confirmed working by him as well. https://bugzilla.samba.org/show_bug.cgi?id=10982 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: David Disseldorp <dd...@suse.de> (cherry picked from commit c9235deee0fc49c99cfaf2329b7af526d9dd12d0) commit 8999acabfc3aaf9fcfecb4e71a2af96c74021a8d Author: Andreas Schneider <a...@samba.org> Date: Fri Nov 14 10:05:13 2014 +0100 s3-libsmb: Duplicate the memory before we free it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10279 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Guenther Deschner <g...@samba.org> (cherry picked from commit 8c41795c81d85114e383e694ba7421e95bacb912) commit 4051499d2cb0cbb737edc12da28d9e6656fb9f71 Author: Andreas Schneider <a...@samba.org> Date: Fri Nov 14 10:03:07 2014 +0100 s3-libsmb: Set the netbios_name in use_ccache case too. If we do not set the netbios_name we are not able to connect to a Windows DC. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10279 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Guenther Deschner <g...@samba.org> (cherry picked from commit 206f25d815024248214f076fd60c35862e9de8a1) commit 8ca520e6b4fba0365e31df6c6b3c28ec66feb3e7 Author: Andreas Schneider <a...@samba.org> Date: Fri Nov 14 09:31:51 2014 +0100 s3-lib: Do not require a password with --use-ccache. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10279 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Guenther Deschner <g...@samba.org> (cherry picked from commit 1e148a91fd20053f823b57e19d757665fa30c53d) commit 6e030c2c21f605e4364af05afa08dabd8001fdfd Author: Günther Deschner <g...@samba.org> Date: Wed Dec 3 16:55:39 2014 +0100 pam_winbind: fix warn_pwd_expire implementation. BUG: https://bugzilla.samba.org/show_bug.cgi?id=9056 warn_pwd_expire parameter is not working as documented in pam_winbind manual page. This patch adds missing bit and allows disabling warning message fully, i.e. setting warn time to zero days. Guenther Signed-off-by: Guenther Deschner <g...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Reviewed-by: Guenther Deschner <g...@samba.org> Autobuild-User(master): Günther Deschner <g...@samba.org> Autobuild-Date(master): Wed Dec 3 21:36:49 CET 2014 on sn-devel-104 ----------------------------------------------------------------------- Summary of changes: nsswitch/pam_winbind.c | 5 ++++- source3/lib/util_cmdline.c | 3 ++- source3/libsmb/ntlmssp.c | 18 +++++++++++++++--- source3/modules/vfs_ceph.c | 13 +++---------- source3/modules/vfs_default.c | 17 ++++++++++++----- source3/modules/vfs_streams_xattr.c | 5 +++-- source3/modules/vfs_time_audit.c | 8 +++++++- source3/script/tests/test_smbclient_s3.sh | 4 ++-- source3/smbd/vfs.c | 22 +++++++++++----------- 9 files changed, 59 insertions(+), 36 deletions(-) Changeset truncated at 500 lines: diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c index 98cf97e..b4baed0 100644 --- a/nsswitch/pam_winbind.c +++ b/nsswitch/pam_winbind.c @@ -475,6 +475,9 @@ config_from_pam: ctrl |= WINBIND_CACHED_LOGIN; else if (!strcasecmp(*v, "mkhomedir")) ctrl |= WINBIND_MKHOMEDIR; + else if (!strncasecmp(*v, "warn_pwd_expire", + strlen("warn_pwd_expire"))) + ctrl |= WINBIND_WARN_PWD_EXPIRE; else { __pam_log(pamh, ctrl, LOG_ERR, "pam_parse: unknown option: %s", *v); @@ -2351,7 +2354,7 @@ static int get_warn_pwd_expire_from_config(struct pwb_context *ctx) ret = get_config_item_int(ctx, "warn_pwd_expire", WINBIND_WARN_PWD_EXPIRE); /* no or broken setting */ - if (ret <= 0) { + if (ret < 0) { return DEFAULT_DAYS_TO_WARN_BEFORE_PWD_EXPIRES; } return ret; diff --git a/source3/lib/util_cmdline.c b/source3/lib/util_cmdline.c index d15f325..80c3ecd 100644 --- a/source3/lib/util_cmdline.c +++ b/source3/lib/util_cmdline.c @@ -251,7 +251,8 @@ void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info) TALLOC_CTX *frame; if (get_cmdline_auth_info_got_pass(auth_info) || - get_cmdline_auth_info_use_kerberos(auth_info)) { + get_cmdline_auth_info_use_ccache(auth_info) || + get_cmdline_auth_info_use_kerberos(auth_info)) { /* Already got one... */ return; } diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index e8c9ebf..617b34b 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -383,6 +383,15 @@ static NTSTATUS ntlmssp3_client_challenge(struct ntlmssp_state *ntlmssp_state, wbcErr wbc_status; int i; + /* + * We need to set the netbios name or we are not able to connect + * a Windows DC. + */ + if (ntlmssp_state->server.netbios_domain == NULL || + ntlmssp_state->server.netbios_domain[0] == '\0') { + ntlmssp_state->server.netbios_domain = ntlmssp_state->domain; + } + params.account_name = ntlmssp_state->user; params.domain_name = ntlmssp_state->domain; params.level = WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP; @@ -413,9 +422,12 @@ static NTSTATUS ntlmssp3_client_challenge(struct ntlmssp_state *ntlmssp_state, goto noccache; } - *next_request = data_blob(wbc_next->data, wbc_next->length); - ntlmssp_state->session_key = data_blob( - wbc_session_key->data, wbc_session_key->length); + *next_request = data_blob_talloc(ntlmssp_state, + wbc_next->data, + wbc_next->length); + ntlmssp_state->session_key = data_blob_talloc(ntlmssp_state, + wbc_session_key->data, + wbc_session_key->length); wbcFreeMemory(info); goto done; diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index e402ff1..b0a0024 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -795,15 +795,14 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str return ENOTSUP or EINVAL in cases like that. */ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, pst->st_ex_size, space_to_write); - if (ret == ENOSPC) { - errno = ENOSPC; + if (ret == -1 && errno == ENOSPC) { return -1; } if (ret == 0) { return 0; } DEBUG(10,("[CEPH] strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with " - "error %d. Falling back to slow manual allocation\n", ret)); + "error %d. Falling back to slow manual allocation\n", errno)); /* available disk space is enough or not? */ space_avail = get_dfree_info(fsp->conn, @@ -817,13 +816,7 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str } /* Write out the real space on disk. */ - ret = vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write); - if (ret != 0) { - errno = ret; - ret = -1; - } - - return 0; + return vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write); } static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index ed14c67..23c1cc2 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1819,15 +1819,14 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs return ENOTSUP or EINVAL in cases like that. */ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, pst->st_ex_size, space_to_write); - if (ret == ENOSPC) { - errno = ENOSPC; + if (ret == -1 && errno == ENOSPC) { return -1; } if (ret == 0) { return 0; } DEBUG(10,("strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with " - "error %d. Falling back to slow manual allocation\n", ret)); + "error %d. Falling back to slow manual allocation\n", errno)); /* available disk space is enough or not? */ space_avail = get_dfree_info(fsp->conn, @@ -1843,8 +1842,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs /* Write out the real space on disk. */ ret = vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write); if (ret != 0) { - errno = ret; - ret = -1; + return -1; } return 0; @@ -1929,6 +1927,15 @@ static int vfswrap_fallocate(vfs_handle_struct *handle, START_PROFILE(syscall_fallocate); if (mode == VFS_FALLOCATE_EXTEND_SIZE) { result = sys_posix_fallocate(fsp->fh->fd, offset, len); + /* + * posix_fallocate returns 0 on success, errno on error + * and doesn't set errno. Make it behave like fallocate() + * which returns -1, and sets errno on failure. + */ + if (result != 0) { + errno = result; + result = -1; + } } else if (mode == VFS_FALLOCATE_KEEP_SIZE) { result = sys_fallocate(fsp->fh->fd, mode, offset, len); } else { diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 5e9bd3e..0409c05 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -1021,11 +1021,12 @@ static int streams_xattr_fallocate(struct vfs_handle_struct *handle, } if (!streams_xattr_recheck(sio)) { - return errno; + return -1; } /* Let the pwrite code path handle it. */ - return ENOSYS; + errno = ENOSYS; + return -1; } diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 1b14d65..e0dcc90 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -1211,18 +1211,24 @@ static int smb_time_audit_fallocate(vfs_handle_struct *handle, off_t len) { int result; + int saved_errno = 0; struct timespec ts1,ts2; double timediff; clock_gettime_mono(&ts1); result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len); + if (result == -1) { + saved_errno = errno; + } clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { smb_time_audit_log_fsp("fallocate", timediff, fsp); } - + if (result == -1) { + errno = saved_errno; + } return result; } diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 596cd42..f73643f 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -602,7 +602,7 @@ test_ccache_access() return fi - $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}%" \ + $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" \ -c quit 2>&1 ret=$? @@ -621,7 +621,7 @@ test_ccache_access() return fi - $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}%" \ + $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}" \ -c quit 2>&1 ret=$? diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 4a0588e..cdd5042 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -580,6 +580,10 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len) return 0; } + if (ret == -1 && errno == ENOSPC) { + return -1; + } + len -= fsp->fsp_name->st.st_ex_size; len /= 1024; /* Len is now number of 1k blocks needed. */ space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, false, @@ -634,7 +638,7 @@ int vfs_set_filelen(files_struct *fsp, off_t len) fails. Needs to be outside of the default version of SMB_VFS_FALLOCATE as this is also called from the default SMB_VFS_FTRUNCATE code. Always extends the file size. - Returns 0 on success, errno on failure. + Returns 0 on success, -1 on failure. ****************************************************************************/ #define SPARSE_BUF_WRITE_SIZE (32*1024) @@ -648,7 +652,7 @@ int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len) sparse_buf = SMB_CALLOC_ARRAY(char, SPARSE_BUF_WRITE_SIZE); if (!sparse_buf) { errno = ENOMEM; - return ENOMEM; + return -1; } } @@ -657,10 +661,12 @@ int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len) pwrite_ret = SMB_VFS_PWRITE(fsp, sparse_buf, curr_write_size, offset + total); if (pwrite_ret == -1) { + int saved_errno = errno; DEBUG(10,("vfs_slow_fallocate: SMB_VFS_PWRITE for file " "%s failed with error %s\n", - fsp_str_dbg(fsp), strerror(errno))); - return errno; + fsp_str_dbg(fsp), strerror(saved_errno))); + errno = saved_errno; + return -1; } total += pwrite_ret; } @@ -718,9 +724,7 @@ int vfs_fill_sparse(files_struct *fsp, off_t len) * return ENOTSUP or EINVAL in cases like that. */ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, offset, num_to_write); - if (ret == ENOSPC) { - errno = ENOSPC; - ret = -1; + if (ret == -1 && errno == ENOSPC) { goto out; } if (ret == 0) { @@ -731,10 +735,6 @@ int vfs_fill_sparse(files_struct *fsp, off_t len) } ret = vfs_slow_fallocate(fsp, offset, num_to_write); - if (ret != 0) { - errno = ret; - ret = -1; - } out: -- Samba Shared Repository