s3:net: remove useless net_prompt_pass() wrapper
authorStefan Metzmacher <metze@samba.org>
Thu, 7 Mar 2024 13:54:18 +0000 (14:54 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 14 May 2024 10:18:31 +0000 (10:18 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/utils/net.c
source3/utils/net_ads.c
source3/utils/net_proto.h
source3/utils/net_util.c

index 7747aff917172b1e6a5cd28dc6c49af5bc9be6f4..06ccbc00016cd761f2bcc0e9e856da8e2d0f9a90 100644 (file)
@@ -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;
index 6a106af3f89dbbbdf40d7b26df914230bfff20c7..f368724215bdc58b92a55f7e814d01e83ed049c4 100644 (file)
@@ -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; i<argc; i++) {
@@ -3279,11 +3280,11 @@ static int net_ads_kerberos_pac_common(struct net_context *c, int argc, const ch
                }
        }
 
-       c->opt_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,
index cabbc751aaf21181ba22dee5e79b9737397c7a1f..1678affd30caddfbe1e4bab59effb5ddd0a6f43f 100644 (file)
@@ -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);
index 757228a72e2f82482ee3a3d7d12081dd058468bc..1168983e0b47255b67149392988cf33ec5866de8 100644 (file)
@@ -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)
 {