net: Add libnetapi context to net's impressive list of globals.
authorGünther Deschner <gd@samba.org>
Mon, 21 Apr 2008 18:14:32 +0000 (20:14 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 21 Apr 2008 18:21:40 +0000 (20:21 +0200)
Guenther
(This used to be commit 8a5fadf6a183e4e4ccc77283b3ddba0748c6abfb)

source3/utils/net.c
source3/utils/net.h
source3/utils/net_rpc.c

index f6851f69da67b0ddb3a0923ceaac9bcf872dd821..c4b31d46b07d172eaaa87e96f88eb114971e2df5 100644 (file)
@@ -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;
index 00a818a60631643d60198ea71dfe9bfdcc260eed..68ed179a7a37076512e8eda0b146303315a96ef9 100644 (file)
@@ -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[];
 
index 924398fc33bd2f392e6568b8b1622610a82098ba..5845c1431407097e67e0e7fccb41d46b26c647b0 100644 (file)
@@ -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,