From 55c9a6c0e3a403ac38f018fcf3b003e39c3c79f3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 7 Mar 2024 14:54:18 +0100 Subject: [PATCH] s3:net: remove useless net_prompt_pass() wrapper Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- source3/utils/net.c | 2 +- source3/utils/net_ads.c | 12 +++++++----- source3/utils/net_proto.h | 1 - source3/utils/net_util.c | 12 ------------ 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/source3/utils/net.c b/source3/utils/net.c index 7747aff9171..06ccbc00016 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -308,7 +308,7 @@ static int net_setauthuser(struct net_context *c, int argc, const char **argv) return 1; } - password = net_prompt_pass(c, _("the auth user")); + password = cli_credentials_get_password(c->creds); if (password == NULL) { d_fprintf(stderr,_("Failed to get the auth users password.\n")); return 1; diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 6a106af3f89..f368724215b 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -701,7 +701,7 @@ retry_connect: retry: if (!c->opt_password && need_password && !c->opt_machine_pass) { - c->opt_password = net_prompt_pass(c, c->opt_user_name); + c->opt_password = cli_credentials_get_password(c->creds); if (!c->opt_password) { TALLOC_FREE(ads); return ADS_ERROR(LDAP_NO_MEMORY); @@ -3254,6 +3254,7 @@ static int net_ads_kerberos_pac_common(struct net_context *c, int argc, const ch int ret = -1; const char *impersonate_princ_s = NULL; const char *local_service = NULL; + const char *password = NULL; int i; for (i=0; iopt_password = net_prompt_pass(c, c->opt_user_name); + password = cli_credentials_get_password(c->creds); status = kerberos_return_pac(c, c->opt_user_name, - c->opt_password, + password, 0, NULL, NULL, @@ -3444,6 +3445,7 @@ static int net_ads_kerberos_kinit(struct net_context *c, int argc, const char ** { int ret = -1; NTSTATUS status; + const char *password = NULL; if (c->display_usage) { d_printf( "%s\n" @@ -3454,10 +3456,10 @@ static int net_ads_kerberos_kinit(struct net_context *c, int argc, const char ** return -1; } - c->opt_password = net_prompt_pass(c, c->opt_user_name); + password = cli_credentials_get_password(c->creds); ret = kerberos_kinit_password_ext(c->opt_user_name, - c->opt_password, + password, 0, NULL, NULL, diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h index cabbc751aaf..1678affd30c 100644 --- a/source3/utils/net_proto.h +++ b/source3/utils/net_proto.h @@ -447,7 +447,6 @@ NTSTATUS net_make_ipc_connection_ex(struct net_context *c ,const char *domain, const char *server, const struct sockaddr_storage *pss, unsigned flags, struct cli_state **pcli); -const char *net_prompt_pass(struct net_context *c, const char *user); int net_run_function(struct net_context *c, int argc, const char **argv, const char *whoami, struct functable *table); void net_display_usage_from_functable(struct functable *table); diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index 757228a72e2..1168983e0b4 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -442,18 +442,6 @@ done: /**************************************************************************** ****************************************************************************/ -/* TODO FIXME: Pass cli_creds via net_context and get rid of this function. */ -const char *net_prompt_pass(struct net_context *c, const char *user) -{ - struct cli_credentials *creds = samba_cmdline_get_creds(); - - if (c->opt_password == NULL) { - c->opt_password = cli_credentials_get_password(creds); - } - - return c->opt_password; -} - int net_run_function(struct net_context *c, int argc, const char **argv, const char *whoami, struct functable *table) { -- 2.11.4.GIT