diff options
-rw-r--r-- | source3/utils/net.c | 7 | ||||
-rw-r--r-- | source3/utils/net.h | 1 | ||||
-rw-r--r-- | source3/utils/net_rpc.c | 11 |
3 files changed, 8 insertions, 11 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c index f6851f69da..c4b31d46b0 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -89,6 +89,7 @@ int opt_testmode = False; int opt_have_ip = False; struct sockaddr_storage opt_dest_ip; bool smb_encrypt; +struct libnetapi_ctx *netapi_ctx = NULL; extern bool AllowDebugChange; @@ -1170,11 +1171,7 @@ static struct functable net_func[] = { DEBUG(2,("return code = %d\n", rc)); - { - struct libnetapi_ctx *ctx = NULL; - libnetapi_getctx(&ctx); - libnetapi_free(ctx); - } + libnetapi_free(netapi_ctx); TALLOC_FREE(frame); return rc; diff --git a/source3/utils/net.h b/source3/utils/net.h index 00a818a606..68ed179a7a 100644 --- a/source3/utils/net.h +++ b/source3/utils/net.h @@ -117,6 +117,7 @@ extern int opt_testmode; extern int opt_have_ip; extern struct sockaddr_storage opt_dest_ip; +extern struct libnetapi_ctx *netapi_ctx; extern const char *share_type[]; diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 924398fc33..5845c14314 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -601,7 +601,7 @@ static int rpc_user_add(int argc, const char **argv) if (status != 0) { d_fprintf(stderr, "Failed to add user '%s' with: %s.\n", - argv[0], libnetapi_get_error_string(NULL, status)); + argv[0], libnetapi_get_error_string(netapi_ctx, status)); return -1; } else { d_printf("Added user '%s'.\n", argv[0]); @@ -769,7 +769,7 @@ static int rpc_user_delete(int argc, const char **argv) if (status != 0) { d_fprintf(stderr, "Failed to delete user '%s' with: %s.\n", argv[0], - libnetapi_get_error_string(NULL, status)); + libnetapi_get_error_string(netapi_ctx, status)); return -1; } else { d_printf("Deleted user '%s'.\n", argv[0]); @@ -1147,7 +1147,6 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid, int net_rpc_user(int argc, const char **argv) { - struct libnetapi_ctx *ctx = NULL; NET_API_STATUS status; struct functable func[] = { @@ -1159,12 +1158,12 @@ int net_rpc_user(int argc, const char **argv) {NULL, NULL} }; - status = libnetapi_init(&ctx); + status = libnetapi_init(&netapi_ctx); if (status != 0) { return -1; } - libnetapi_set_username(ctx, opt_user_name); - libnetapi_set_password(ctx, opt_password); + libnetapi_set_username(netapi_ctx, opt_user_name); + libnetapi_set_password(netapi_ctx, opt_password); if (argc == 0) { return run_rpc_command(NULL,PI_SAMR, 0, |