The branch, v4-6-test has been updated via eea9b63 ctdb-common: Call missing tevent_wakeup_recv() in sock_daemon via c54477d ctdb-daemon: Allocate deferred calls off calling context via 7e41c94 winbind: Remove winbind_messaging_context via 65bbf31 winbind: winbind_messaging_context -> server_messaging_context via 88a92ba winbind: Remove winbind_event_context via d0b4331 winbind: Replace winbind_event_context with server_event_context via 598cc46 s3: smbclient: tests: Test "volume" command over SMB1 and SMB2+. via 3490bbd s3: smbclient: Implement "volume" command over SMB2. from a7de852 VERSION: Bump version up to 4.6.12...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-6-test - Log ----------------------------------------------------------------- commit eea9b637f7c217bbbc9cdb5e6e99fd15fcb890b9 Author: Amitay Isaacs <ami...@gmail.com> Date: Fri Nov 10 12:18:01 2017 +1100 ctdb-common: Call missing tevent_wakeup_recv() in sock_daemon https://bugzilla.samba.org/show_bug.cgi?id=13153 Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> (cherry picked from commit 49308f7f22f3d6fa05cc81fdef3db020e503fa9f) Autobuild-User(v4-6-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-6-test): Wed Nov 22 13:43:49 CET 2017 on sn-devel-144 commit c54477d9bf4006156b261c374c0071ba87d6c03d Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Oct 19 14:58:18 2017 +1100 ctdb-daemon: Allocate deferred calls off calling context BUG: https://bugzilla.samba.org/show_bug.cgi?id=13152 This makes sure that if a client disconnects, all the deferred calls from the client are correctly freed. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> (cherry picked from commit 848f2425984667c243ccac847b8f48a66ce10178) commit 7e41c947641d3ec52174c9780b79e39871fd11be Author: Volker Lendecke <v...@samba.org> Date: Fri Nov 17 11:47:37 2017 +0100 winbind: Remove winbind_messaging_context BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Sat Nov 18 04:07:24 CET 2017 on sn-devel-144 (cherry picked from commit 050ca45dc7fc5bbab6e1c60b919ac0b1e9661e27) commit 65bbf314782d70a72c8500e4bcebefc8eefc102c Author: Volker Lendecke <v...@samba.org> Date: Fri Nov 17 11:42:34 2017 +0100 winbind: winbind_messaging_context -> server_messaging_context Don't use winbind_messaging_context anymore. This fixes a bug analysed by Peter Somogyi <psomo...@hu.ibm.com>: If a parent winbind forks, it only called reinit_after_fork on winbind_messaging_context. On the other hand, deep in dbwrap_open we use server_messaging_context(). This is not reinitialized by winbind_reinit_after fork, so the parent and child share a ctdb connection. This is invalid, because replies from ctdb end up in the wrong process. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit d8a01d09c13728f36107f6eb94ecb7653706a4db) commit 88a92ba2e77517359c68628019c9d67452b476be Author: Volker Lendecke <v...@samba.org> Date: Fri Nov 17 11:37:30 2017 +0100 winbind: Remove winbind_event_context BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit e1f12acc13a3cc004518ac3460c6000ea0b95115) commit d0b4331b5460e40a52b3c00776ef9272856239f5 Author: Volker Lendecke <v...@samba.org> Date: Fri Nov 17 11:35:19 2017 +0100 winbind: Replace winbind_event_context with server_event_context There's no point in having two global event contexts BUG: https://bugzilla.samba.org/show_bug.cgi?id=13150 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 7e83d1489406cd53d72097e40bf02295c88ea61e) commit 598cc463c5fb634588446fa15ea2e8ed39e36617 Author: Jeremy Allison <j...@samba.org> Date: Tue Nov 14 15:54:19 2017 -0800 s3: smbclient: tests: Test "volume" command over SMB1 and SMB2+. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13140 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Wed Nov 15 19:50:54 CET 2017 on sn-devel-144 (cherry picked from commit f8cd211acc3824e01d89a6f8b6666c39aa5cd54e) commit 3490bbd4df933d2cf3a548f1cc8794a55bc65978 Author: Jeremy Allison <j...@samba.org> Date: Tue Nov 14 15:42:14 2017 -0800 s3: smbclient: Implement "volume" command over SMB2. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13140 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit aaa52ab7b5ae711b80e3967ab1ecc91888c346f6) ----------------------------------------------------------------------- Summary of changes: ctdb/common/sock_daemon.c | 8 ++ ctdb/server/ctdb_call.c | 14 ++- source3/libsmb/cli_smb2_fnum.c | 130 +++++++++++++++++++++ source3/libsmb/cli_smb2_fnum.h | 5 + source3/libsmb/clifsinfo.c | 8 ++ source3/script/tests/test_smbclient_s3.sh | 32 +++++ source3/torture/torture.c | 9 -- source3/winbindd/idmap_ldap.c | 2 +- source3/winbindd/idmap_rfc2307.c | 2 +- source3/winbindd/winbindd.c | 110 ++++++----------- source3/winbindd/winbindd_cm.c | 36 +++--- source3/winbindd/winbindd_cred_cache.c | 14 +-- source3/winbindd/winbindd_dual.c | 50 ++++---- source3/winbindd/winbindd_dual_srv.c | 6 +- source3/winbindd/winbindd_irpc.c | 8 +- source3/winbindd/winbindd_misc.c | 2 +- source3/winbindd/winbindd_pam_auth.c | 2 +- source3/winbindd/winbindd_pam_auth_crap.c | 2 +- source3/winbindd/winbindd_pam_chauthtok.c | 2 +- .../winbindd/winbindd_pam_chng_pswd_auth_crap.c | 2 +- source3/winbindd/winbindd_pam_logoff.c | 2 +- source3/winbindd/winbindd_proto.h | 2 - source3/winbindd/winbindd_util.c | 2 +- 23 files changed, 298 insertions(+), 152 deletions(-) Changeset truncated at 500 lines: diff --git a/ctdb/common/sock_daemon.c b/ctdb/common/sock_daemon.c index b53b4d8..1fe5ff5 100644 --- a/ctdb/common/sock_daemon.c +++ b/ctdb/common/sock_daemon.c @@ -628,6 +628,14 @@ static void sock_daemon_run_started(struct tevent_req *subreq) struct sock_daemon_run_state *state = tevent_req_data( req, struct sock_daemon_run_state); struct sock_daemon_context *sockd = state->sockd; + bool status; + + status = tevent_wakeup_recv(subreq); + TALLOC_FREE(subreq); + if (! status) { + tevent_req_error(req, EIO); + return; + } D_NOTICE("daemon started, pid=%u\n", getpid()); diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c index b3bc9cf..a4f84a3 100644 --- a/ctdb/server/ctdb_call.c +++ b/ctdb/server/ctdb_call.c @@ -1567,6 +1567,7 @@ struct revokechild_deferred_call { struct ctdb_req_header *hdr; deferred_requeue_fn fn; void *ctx; + struct revokechild_handle *rc; }; struct revokechild_handle { @@ -1591,12 +1592,20 @@ static void deferred_call_requeue(struct tevent_context *ev, while (dlist != NULL) { struct revokechild_deferred_call *dcall = dlist; + talloc_set_destructor(dcall, NULL); DLIST_REMOVE(dlist, dcall); dcall->fn(dcall->ctx, dcall->hdr); talloc_free(dcall); } } +static int deferred_call_destructor(struct revokechild_deferred_call *dcall) +{ + struct revokechild_handle *rc = dcall->rc; + + DLIST_REMOVE(rc->deferred_call_list, dcall); + return 0; +} static int revokechild_destructor(struct revokechild_handle *rc) { @@ -1935,7 +1944,7 @@ int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb, struct ctdb_db_cont return -1; } - deferred_call = talloc(ctdb_db, struct revokechild_deferred_call); + deferred_call = talloc(call_context, struct revokechild_deferred_call); if (deferred_call == NULL) { DEBUG(DEBUG_ERR,("Failed to allocate deferred call structure for revoking record\n")); return -1; @@ -1945,6 +1954,9 @@ int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb, struct ctdb_db_cont deferred_call->hdr = talloc_steal(deferred_call, hdr); deferred_call->fn = fn; deferred_call->ctx = call_context; + deferred_call->rc = rc; + + talloc_set_destructor(deferred_call, deferred_call_destructor); DLIST_ADD(rc->deferred_call_list, deferred_call); diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index e5a4055..247f443 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -2001,6 +2001,136 @@ fail: } /*************************************************************** + Wrapper that allows SMB2 to query file system volume info. + Synchronous only. +***************************************************************/ + +NTSTATUS cli_smb2_get_fs_volume_info(struct cli_state *cli, + TALLOC_CTX *mem_ctx, + char **_volume_name, + uint32_t *pserial_number, + time_t *pdate) +{ + NTSTATUS status; + uint16_t fnum = 0xffff; + DATA_BLOB outbuf = data_blob_null; + struct smb2_hnd *ph = NULL; + uint32_t nlen; + char *volume_name = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + + if (smbXcli_conn_has_async_calls(cli->conn)) { + /* + * Can't use sync call while an async call is in flight + */ + status = NT_STATUS_INVALID_PARAMETER; + goto fail; + } + + if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) { + status = NT_STATUS_INVALID_PARAMETER; + goto fail; + } + + /* First open the top level directory. */ + status = + cli_smb2_create_fnum(cli, "", 0, /* create_flags */ + FILE_READ_ATTRIBUTES, /* desired_access */ + FILE_ATTRIBUTE_DIRECTORY, /* file attributes */ + FILE_SHARE_READ | FILE_SHARE_WRITE | + FILE_SHARE_DELETE, /* share_access */ + FILE_OPEN, /* create_disposition */ + FILE_DIRECTORY_FILE, /* create_options */ + &fnum, + NULL); + + if (!NT_STATUS_IS_OK(status)) { + goto fail; + } + + status = map_fnum_to_smb2_handle(cli, fnum, &ph); + if (!NT_STATUS_IS_OK(status)) { + goto fail; + } + + /* getinfo on the returned handle with info_type SMB2_GETINFO_FS (2), + level 1 (SMB_FS_VOLUME_INFORMATION). */ + + status = smb2cli_query_info(cli->conn, + cli->timeout, + cli->smb2.session, + cli->smb2.tcon, + SMB2_GETINFO_FS, /* in_info_type */ + /* in_file_info_class */ + SMB_FS_VOLUME_INFORMATION - 1000, + 0xFFFF, /* in_max_output_length */ + NULL, /* in_input_buffer */ + 0, /* in_additional_info */ + 0, /* in_flags */ + ph->fid_persistent, + ph->fid_volatile, + frame, + &outbuf); + if (!NT_STATUS_IS_OK(status)) { + goto fail; + } + + if (outbuf.length < 24) { + status = NT_STATUS_INVALID_NETWORK_RESPONSE; + goto fail; + } + + if (pdate) { + struct timespec ts; + ts = interpret_long_date((char *)outbuf.data); + *pdate = ts.tv_sec; + } + if (pserial_number) { + *pserial_number = IVAL(outbuf.data,8); + } + nlen = IVAL(outbuf.data,12); + if (nlen + 18 < 18) { + /* Integer wrap. */ + status = NT_STATUS_INVALID_NETWORK_RESPONSE; + goto fail; + } + /* + * The next check is safe as we know outbuf.length >= 24 + * from above. + */ + if (nlen > (outbuf.length - 18)) { + status = NT_STATUS_INVALID_NETWORK_RESPONSE; + goto fail; + } + + clistr_pull_talloc(mem_ctx, + (const char *)outbuf.data, + 0, + &volume_name, + outbuf.data + 18, + nlen, + STR_UNICODE); + if (volume_name == NULL) { + status = map_nt_error_from_unix(errno); + goto fail; + } + + *_volume_name = volume_name; + +fail: + + if (fnum != 0xffff) { + cli_smb2_close_fnum(cli, fnum); + } + + cli->raw_status = status; + + TALLOC_FREE(frame); + return status; +} + + +/*************************************************************** Wrapper that allows SMB2 to query a security descriptor. Synchronous only. ***************************************************************/ diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h index 5354b2d..1a7ecf1 100644 --- a/source3/libsmb/cli_smb2_fnum.h +++ b/source3/libsmb/cli_smb2_fnum.h @@ -133,6 +133,11 @@ NTSTATUS cli_smb2_get_fs_full_size_info(struct cli_state *cli, uint64_t *actual_allocation_units, uint64_t *sectors_per_allocation_unit, uint64_t *bytes_per_sector); +NTSTATUS cli_smb2_get_fs_volume_info(struct cli_state *cli, + TALLOC_CTX *mem_ctx, + char **_volume_name, + uint32_t *pserial_number, + time_t *pdate); NTSTATUS cli_smb2_query_security_descriptor(struct cli_state *cli, uint16_t fnum, uint32_t sec_info, diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c index 4623639..09c0d95 100644 --- a/source3/libsmb/clifsinfo.c +++ b/source3/libsmb/clifsinfo.c @@ -375,6 +375,14 @@ NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, unsigned int nlen; char *volume_name = NULL; + if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { + return cli_smb2_get_fs_volume_info(cli, + mem_ctx, + _volume_name, + pserial_number, + pdate); + } + SSVAL(setup, 0, TRANSACT2_QFSINFO); SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO); diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index ce1cb08..fae8b1f 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -1277,6 +1277,34 @@ done LOGDIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) +# Test doing a volume command. +test_volume() +{ + tmpfile=$PREFIX/smbclient_interactive_prompt_commands + cat > $tmpfile <<EOF +volume +quit +EOF + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + rm -f $tmpfile + + if [ $ret != 0 ] ; then + echo "$out" + echo "failed doing volume command with error $ret" + return 1 + fi + + echo "$out" | grep '^Volume: |tmp| serial number' + ret=$? + if [ $ret != 0 ] ; then + echo "$out" + echo "failed doing volume command" + return 1 + fi +} testit "smbclient -L $SERVER_IP" $SMBCLIENT -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1` testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT -L $SERVER -I $SERVER_IP -N -p 139 -c quit || failed=`expr $failed + 1` @@ -1373,6 +1401,10 @@ testit "follow local symlinks" \ test_local_symlinks || \ failed=`expr $failed + 1` +testit "volume" \ + test_volume || \ + failed=`expr $failed + 1` + testit "rm -rf $LOGDIR" \ rm -rf $LOGDIR || \ failed=`expr $failed + 1` diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 015ea37..bb4fefa 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -11486,15 +11486,6 @@ static struct { { "qpathinfo-bufsize", run_qpathinfo_bufsize, 0 }, {NULL, NULL, 0}}; -/* - * dummy function to satisfy linker dependency - */ -struct tevent_context *winbind_event_context(void); -struct tevent_context *winbind_event_context(void) -{ - return NULL; -} - /**************************************************************************** run a specified test or "ALL" ****************************************************************************/ diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c index 0520f21..7fa4365 100644 --- a/source3/winbindd/idmap_ldap.c +++ b/source3/winbindd/idmap_ldap.c @@ -471,7 +471,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom) /* get_credentials deals with setting up creds */ - ret = smbldap_init(ctx, winbind_event_context(), ctx->url, + ret = smbldap_init(ctx, server_event_context(), ctx->url, false, NULL, NULL, &ctx->smbldap_state); if (!NT_STATUS_IS_OK(ret)) { DEBUG(1, ("ERROR: smbldap_init (%s) failed!\n", ctx->url)); diff --git a/source3/winbindd/idmap_rfc2307.c b/source3/winbindd/idmap_rfc2307.c index 0e0311a..cfe774b 100644 --- a/source3/winbindd/idmap_rfc2307.c +++ b/source3/winbindd/idmap_rfc2307.c @@ -194,7 +194,7 @@ static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx, } /* assume anonymous if we don't have a specified user */ - ret = smbldap_init(mem_ctx, winbind_event_context(), url, + ret = smbldap_init(mem_ctx, server_event_context(), url, (user_dn == NULL), user_dn, secret, &ctx->smbldap_state); SAFE_FREE(secret); diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 2cd2001..f601005 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -59,44 +59,6 @@ static bool interactive = False; extern bool override_logfile; -struct tevent_context *winbind_event_context(void) -{ - static struct tevent_context *ev = NULL; - - if (ev != NULL) { - return ev; - } - - /* - * Note we MUST use the NULL context here, not the autofree context, - * to avoid side effects in forked children exiting. - */ - ev = samba_tevent_context_init(NULL); - if (ev == NULL) { - smb_panic("Could not init winbindd's messaging context.\n"); - } - return ev; -} - -struct messaging_context *winbind_messaging_context(void) -{ - static struct messaging_context *msg = NULL; - - if (msg != NULL) { - return msg; - } - - /* - * Note we MUST use the NULL context here, not the autofree context, - * to avoid side effects in forked children exiting. - */ - msg = messaging_init(NULL, winbind_event_context()); - if (msg == NULL) { - smb_panic("Could not init winbindd's messaging context.\n"); - } - return msg; -} - struct imessaging_context *winbind_imessaging_context(void) { static struct imessaging_context *msg = NULL; @@ -123,7 +85,7 @@ struct imessaging_context *winbind_imessaging_context(void) * Note we MUST use the NULL context here, not the autofree context, * to avoid side effects in forked children exiting. */ - msg = imessaging_init(NULL, lp_ctx, myself, winbind_event_context()); + msg = imessaging_init(NULL, lp_ctx, myself, server_event_context()); talloc_unlink(NULL, lp_ctx); if (msg == NULL) { @@ -258,7 +220,7 @@ static void terminate(bool is_parent) #endif if (is_parent) { - struct messaging_context *msg = winbind_messaging_context(); + struct messaging_context *msg = server_messaging_context(); struct server_id self = messaging_server_id(msg); serverid_deregister(self); pidfile_unlink(lp_pid_directory(), "winbindd"); @@ -306,14 +268,14 @@ bool winbindd_setup_sig_term_handler(bool parent) struct tevent_signal *se; bool *is_parent; - is_parent = talloc(winbind_event_context(), bool); + is_parent = talloc(server_event_context(), bool); if (!is_parent) { return false; } *is_parent = parent; - se = tevent_add_signal(winbind_event_context(), + se = tevent_add_signal(server_event_context(), is_parent, SIGTERM, 0, winbindd_sig_term_handler, @@ -324,7 +286,7 @@ bool winbindd_setup_sig_term_handler(bool parent) return false; } - se = tevent_add_signal(winbind_event_context(), + se = tevent_add_signal(server_event_context(), is_parent, SIGINT, 0, winbindd_sig_term_handler, @@ -335,7 +297,7 @@ bool winbindd_setup_sig_term_handler(bool parent) return false; } - se = tevent_add_signal(winbind_event_context(), + se = tevent_add_signal(server_event_context(), is_parent, SIGQUIT, 0, winbindd_sig_term_handler, @@ -356,7 +318,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) if (foreground) { struct stat st; - is_parent = talloc(winbind_event_context(), bool); + is_parent = talloc(server_event_context(), bool); if (!is_parent) { return false; } @@ -372,7 +334,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground) return false; } if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { - tevent_add_fd(winbind_event_context(), + tevent_add_fd(server_event_context(), is_parent, 0, TEVENT_FD_READ, @@ -404,15 +366,15 @@ bool winbindd_setup_sig_hup_handler(const char *lfile) char *file = NULL; if (lfile) { - file = talloc_strdup(winbind_event_context(), + file = talloc_strdup(server_event_context(), lfile); if (!file) { return false; } } - se = tevent_add_signal(winbind_event_context(), - winbind_event_context(), + se = tevent_add_signal(server_event_context(), + server_event_context(), SIGHUP, 0, winbindd_sig_hup_handler, file); @@ -441,8 +403,8 @@ static bool winbindd_setup_sig_chld_handler(void) { struct tevent_signal *se; - se = tevent_add_signal(winbind_event_context(), - winbind_event_context(), + se = tevent_add_signal(server_event_context(), + server_event_context(), SIGCHLD, 0, winbindd_sig_chld_handler, NULL); @@ -467,8 +429,8 @@ static bool winbindd_setup_sig_usr2_handler(void) { struct tevent_signal *se; - se = tevent_add_signal(winbind_event_context(), - winbind_event_context(), + se = tevent_add_signal(server_event_context(), -- Samba Shared Repository