diff options
author | Andreas Schneider <asn@samba.org> | 2021-03-24 10:08:04 +0100 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2021-03-30 05:48:37 +0000 |
commit | db95414c1decda8ce3a4878cb765da8c73e7079a (patch) | |
tree | b5f3d4563c0e23bc211393191caa1a36ef3e4407 /source3 | |
parent | 2cab43cfca094c21899daddadfcb84469c0e2a02 (diff) | |
download | samba-db95414c1decda8ce3a4878cb765da8c73e7079a.tar.gz |
s3:utils: Use secrets_store_creds() in net utility
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/net.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c index 17d9a61ed87..585b79fcfcf 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -260,6 +260,8 @@ static int net_changesecretpw(struct net_context *c, int argc, static int net_setauthuser(struct net_context *c, int argc, const char **argv) { const char *password = NULL; + struct cli_credentials *creds = NULL; + bool ok; if (!secrets_init()) { d_fprintf(stderr, _("Failed to open secrets.tdb.\n")); @@ -305,21 +307,16 @@ static int net_setauthuser(struct net_context *c, int argc, const char **argv) return 1; } - if (!secrets_store(SECRETS_AUTH_USER, c->opt_user_name, - strlen(c->opt_user_name) + 1)) { - d_fprintf(stderr, _("error storing auth user name\n")); + creds = net_context_creds(c, c); + if (creds == NULL) { + d_fprintf(stderr, _("Failed creating auth credentials\n")); return 1; } - if (!secrets_store(SECRETS_AUTH_DOMAIN, c->opt_workgroup, - strlen(c->opt_workgroup) + 1)) { - d_fprintf(stderr, _("error storing auth user domain\n")); - return 1; - } - - if (!secrets_store(SECRETS_AUTH_PASSWORD, password, - strlen(password) + 1)) { - d_fprintf(stderr, _("error storing auth user password\n")); + ok = secrets_store_creds(creds); + TALLOC_FREE(creds); + if (!ok) { + d_fprintf(stderr, _("Failed storing auth user credentials\n")); return 1; } |