]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: Use libnetapi_set_creds() in net_rpc
authorAndreas Schneider <asn@samba.org>
Thu, 25 Mar 2021 10:44:36 +0000 (11:44 +0100)
committerRalph Boehme <slow@samba.org>
Tue, 30 Mar 2021 05:48:37 +0000 (05:48 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/utils/net_rpc.c

index da1d904305bd28042afdfcbbfd928c31f14faf2d..46d35e6a90f53a5b639e4670293c863c18f7c0cb 100644 (file)
@@ -1256,6 +1256,7 @@ static int rpc_user_list(struct net_context *c, int argc, const char **argv)
 int net_rpc_user(struct net_context *c, int argc, const char **argv)
 {
        NET_API_STATUS status;
+       struct cli_credentials *creds = NULL;
 
        struct functable func[] = {
                {
@@ -1309,14 +1310,19 @@ int net_rpc_user(struct net_context *c, int argc, const char **argv)
                {NULL, NULL, 0, NULL, NULL}
        };
 
+       creds = net_context_creds(c, c);
+       if (creds == NULL) {
+               return -1;
+       }
+
        status = libnetapi_net_init(&c->netapi_ctx);
        if (status != 0) {
                return -1;
        }
-       libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
-       libnetapi_set_password(c->netapi_ctx, c->opt_password);
-       if (c->opt_kerberos) {
-               libnetapi_set_use_kerberos(c->netapi_ctx);
+
+       status = libnetapi_set_creds(c->netapi_ctx, creds);
+       if (status != 0) {
+               return -1;
        }
 
        if (argc == 0) {
@@ -3441,6 +3447,7 @@ static int rpc_group_rename(struct net_context *c, int argc, const char **argv)
 int net_rpc_group(struct net_context *c, int argc, const char **argv)
 {
        NET_API_STATUS status;
+       struct cli_credentials *creds = NULL;
 
        struct functable func[] = {
                {
@@ -3502,14 +3509,19 @@ int net_rpc_group(struct net_context *c, int argc, const char **argv)
                {NULL, NULL, 0, NULL, NULL}
        };
 
+       creds = net_context_creds(c, c);
+       if (creds == NULL) {
+               return -1;
+       }
+
        status = libnetapi_net_init(&c->netapi_ctx);
        if (status != 0) {
                return -1;
        }
-       libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
-       libnetapi_set_password(c->netapi_ctx, c->opt_password);
-       if (c->opt_kerberos) {
-               libnetapi_set_use_kerberos(c->netapi_ctx);
+
+       status = libnetapi_set_creds(c->netapi_ctx, creds);
+       if (status != 0) {
+               return -1;
        }
 
        if (argc == 0) {
@@ -5428,6 +5440,7 @@ int net_usersidlist_usage(struct net_context *c, int argc, const char **argv)
 int net_rpc_share(struct net_context *c, int argc, const char **argv)
 {
        NET_API_STATUS status;
+       struct cli_credentials *creds = NULL;
 
        struct functable func[] = {
                {
@@ -5473,16 +5486,22 @@ int net_rpc_share(struct net_context *c, int argc, const char **argv)
                {NULL, NULL, 0, NULL, NULL}
        };
 
+       creds = net_context_creds(c, c);
+       if (creds == NULL) {
+               return -1;
+       }
+
        status = libnetapi_net_init(&c->netapi_ctx);
        if (status != 0) {
                return -1;
        }
-       libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
-       libnetapi_set_password(c->netapi_ctx, c->opt_password);
-       if (c->opt_kerberos) {
-               libnetapi_set_use_kerberos(c->netapi_ctx);
+
+       status = libnetapi_set_creds(c->netapi_ctx, creds);
+       if (status != 0) {
+               return -1;
        }
 
+
        if (argc == 0) {
                if (c->display_usage) {
                        d_printf("%s\n%s",
@@ -5724,6 +5743,7 @@ static int rpc_file_user(struct net_context *c, int argc, const char **argv)
 int net_rpc_file(struct net_context *c, int argc, const char **argv)
 {
        NET_API_STATUS status;
+       struct cli_credentials *creds = NULL;
 
        struct functable func[] = {
                {
@@ -5755,14 +5775,19 @@ int net_rpc_file(struct net_context *c, int argc, const char **argv)
                {NULL, NULL, 0, NULL, NULL}
        };
 
+       creds = net_context_creds(c, c);
+       if (creds == NULL) {
+               return -1;
+       }
+
        status = libnetapi_net_init(&c->netapi_ctx);
        if (status != 0) {
                return -1;
        }
-       libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
-       libnetapi_set_password(c->netapi_ctx, c->opt_password);
-       if (c->opt_kerberos) {
-               libnetapi_set_use_kerberos(c->netapi_ctx);
+
+       status = libnetapi_set_creds(c->netapi_ctx, creds);
+       if (status != 0) {
+               return -1;
        }
 
        if (argc == 0) {
@@ -8176,6 +8201,7 @@ int net_rpc_printer(struct net_context *c, int argc, const char **argv)
 int net_rpc(struct net_context *c, int argc, const char **argv)
 {
        NET_API_STATUS status;
+       struct cli_credentials *creds = NULL;
 
        struct functable func[] = {
                {
@@ -8366,17 +8392,19 @@ int net_rpc(struct net_context *c, int argc, const char **argv)
                {NULL, NULL, 0, NULL, NULL}
        };
 
+       creds = net_context_creds(c, c);
+       if (creds == NULL) {
+               return -1;
+       }
+
        status = libnetapi_net_init(&c->netapi_ctx);
        if (status != 0) {
                return -1;
        }
-       libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
-       libnetapi_set_password(c->netapi_ctx, c->opt_password);
-       if (c->opt_kerberos) {
-               libnetapi_set_use_kerberos(c->netapi_ctx);
-       }
-       if (c->opt_ccache) {
-               libnetapi_set_use_ccache(c->netapi_ctx);
+
+       status = libnetapi_set_creds(c->netapi_ctx, creds);
+       if (status != 0) {
+               return -1;
        }
 
        return net_run_function(c, argc, argv, "net rpc", func);