The branch, master has been updated via 531b713c558 lib/util: inline lib/util/util_runcmd.h again via 65e52c24bc1 s4:dsdb:util: make use of samba_runcmd_export_stdin() via 10114238c6c lib/util: add samba_runcmd_export_stdin() helper function from eaf63f0b845 docs-xml: "cluster addresses" dns registration
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 531b713c558fad56c20b9f9d1fa4e6fbb236b100 Author: Stefan Metzmacher <me...@samba.org> Date: Sat Feb 2 13:09:37 2019 +0100 lib/util: inline lib/util/util_runcmd.h again samba_runcmd_state should not be exposed! Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Fri Feb 8 02:54:20 CET 2019 on sn-devel-144 commit 65e52c24bc16d6c1c67e92244bc6e96d391525a1 Author: Stefan Metzmacher <me...@samba.org> Date: Sat Feb 2 13:00:13 2019 +0100 s4:dsdb:util: make use of samba_runcmd_export_stdin() Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> commit 10114238c6c743bb25f5a7ff5788856693f420cb Author: Stefan Metzmacher <me...@samba.org> Date: Sat Feb 2 12:58:57 2019 +0100 lib/util: add samba_runcmd_export_stdin() helper function Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> ----------------------------------------------------------------------- Summary of changes: lib/util/samba_util.h | 1 + lib/util/util_runcmd.c | 27 ++++++++++++++++++++++++++- lib/util/util_runcmd.h | 37 ------------------------------------- source4/dsdb/common/util.c | 20 ++++++++++++++------ 4 files changed, 41 insertions(+), 44 deletions(-) delete mode 100644 lib/util/util_runcmd.h Changeset truncated at 500 lines: diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 7b96a595d43..1cd1235f8f1 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -649,6 +649,7 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx, int stderr_log_level, const char * const *argv0, ...); int samba_runcmd_recv(struct tevent_req *req, int *perrno); +int samba_runcmd_export_stdin(struct tevent_req *req); #ifdef DEVELOPER void samba_start_debugger(void); diff --git a/lib/util/util_runcmd.c b/lib/util/util_runcmd.c index 42d84a895bf..3bb4cd83f68 100644 --- a/lib/util/util_runcmd.c +++ b/lib/util/util_runcmd.c @@ -27,11 +27,25 @@ #include "includes.h" #include "system/filesys.h" +#include <tevent.h> #include "../lib/util/tevent_unix.h" -#include "../lib/util/util_runcmd.h" #include "../lib/util/tfork.h" #include "../lib/util/sys_rw.h" +struct samba_runcmd_state { + int stdout_log_level; + int stderr_log_level; + struct tevent_fd *fde_stdout; + struct tevent_fd *fde_stderr; + struct tevent_fd *fde_status; + int fd_stdin, fd_stdout, fd_stderr, fd_status; + char *arg0; + pid_t pid; + struct tfork *tfork; + char buf[1024]; + uint16_t buf_used; +}; + static void samba_runcmd_cleanup_fn(struct tevent_req *req, enum tevent_req_state req_state) { @@ -49,6 +63,17 @@ static void samba_runcmd_cleanup_fn(struct tevent_req *req, } } +int samba_runcmd_export_stdin(struct tevent_req *req) +{ + struct samba_runcmd_state *state = tevent_req_data(req, + struct samba_runcmd_state); + int ret = state->fd_stdin; + + state->fd_stdin = -1; + + return ret; +} + static void samba_runcmd_io_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, diff --git a/lib/util/util_runcmd.h b/lib/util/util_runcmd.h deleted file mode 100644 index 55329615a25..00000000000 --- a/lib/util/util_runcmd.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - run a child command - - Copyright (C) Andrew Tridgell 2010 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include <tevent.h> - -struct samba_runcmd_state { - int stdout_log_level; - int stderr_log_level; - struct tevent_fd *fde_stdout; - struct tevent_fd *fde_stderr; - struct tevent_fd *fde_status; - int fd_stdin, fd_stdout, fd_stderr, fd_status; - char *arg0; - pid_t pid; - struct tfork *tfork; - char buf[1024]; - uint16_t buf_used; -}; diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index d173a75ebb7..3ac21d0e43c 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -45,7 +45,6 @@ #include "lib/socket/socket.h" #include "librpc/gen_ndr/irpc.h" #include "libds/common/flag_mapping.h" -#include "../lib/util/util_runcmd.h" #include "lib/util/access.h" #include "lib/util/util_str_hex.h" #include "libcli/util/ntstatus.h" @@ -2112,7 +2111,7 @@ enum samr_ValidationStatus samdb_check_password(TALLOC_CTX *mem_ctx, int error = 0; struct tevent_context *event_ctx = NULL; struct tevent_req *req = NULL; - struct samba_runcmd_state *run_cmd = NULL; + int cps_stdin = -1; const char * const cmd[4] = { "/bin/sh", "-c", password_script, @@ -2133,15 +2132,24 @@ enum samr_ValidationStatus samdb_check_password(TALLOC_CTX *mem_ctx, req = samba_runcmd_send(event_ctx, event_ctx, tevent_timeval_current_ofs(10, 0), 100, 100, cmd, NULL); - run_cmd = tevent_req_data(req, struct samba_runcmd_state); - if (write(run_cmd->fd_stdin, utf8_pw, utf8_len) != utf8_len) { + if (req == NULL) { TALLOC_FREE(password_script); TALLOC_FREE(event_ctx); return SAMR_VALIDATION_STATUS_PASSWORD_FILTER_ERROR; } - close(run_cmd->fd_stdin); - run_cmd->fd_stdin = -1; + cps_stdin = samba_runcmd_export_stdin(req); + + if (write(cps_stdin, utf8_pw, utf8_len) != utf8_len) { + close(cps_stdin); + cps_stdin = -1; + TALLOC_FREE(password_script); + TALLOC_FREE(event_ctx); + return SAMR_VALIDATION_STATUS_PASSWORD_FILTER_ERROR; + } + + close(cps_stdin); + cps_stdin = -1; if (!tevent_req_poll(req, event_ctx)) { TALLOC_FREE(password_script); -- Samba Shared Repository