s3: Make cli_cm_connect return NTSTATUS
authorVolker Lendecke <vl@samba.org>
Sun, 3 Jul 2011 10:12:45 +0000 (12:12 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 3 Jul 2011 20:45:26 +0000 (22:45 +0200)
source3/libsmb/clidfs.c

index eb168a614ce239d57ada10fa1dd1870be6c7b3a8..da4150dee9176fbba458702edbaf34a7bf430385 100644 (file)
@@ -261,16 +261,17 @@ static void cli_set_mntpoint(struct cli_state *cli, const char *mnt)
  referring_cli == NULL means a new initial connection.
 ********************************************************************/
 
-static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
-                                       struct cli_state *referring_cli,
-                                       const char *server,
-                                       const char *share,
-                                       const struct user_auth_info *auth_info,
-                                       bool show_hdr,
-                                       bool force_encrypt,
-                                       int max_protocol,
-                                       int port,
-                                       int name_type)
+static NTSTATUS cli_cm_connect(TALLOC_CTX *ctx,
+                              struct cli_state *referring_cli,
+                              const char *server,
+                              const char *share,
+                              const struct user_auth_info *auth_info,
+                              bool show_hdr,
+                              bool force_encrypt,
+                              int max_protocol,
+                              int port,
+                              int name_type,
+                              struct cli_state **pcli)
 {
        struct cli_state *cli;
        NTSTATUS status;
@@ -281,7 +282,7 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
                                port, name_type, &cli);
 
        if (!NT_STATUS_IS_OK(status)) {
-               return NULL;
+               return status;
        }
 
        /* Enter into the list. */
@@ -301,7 +302,8 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
                }
        }
 
-       return cli;
+       *pcli = cli;
+       return NT_STATUS_OK;
 }
 
 /********************************************************************
@@ -354,6 +356,7 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
 {
        /* Try to reuse an existing connection in this list. */
        struct cli_state *c = cli_cm_find(referring_cli, server, share);
+       NTSTATUS status;
 
        if (c) {
                return c;
@@ -368,7 +371,7 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
                return NULL;
        }
 
-       return cli_cm_connect(ctx,
+       status = cli_cm_connect(ctx,
                                referring_cli,
                                server,
                                share,
@@ -377,7 +380,12 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
                                force_encrypt,
                                max_protocol,
                                port,
-                               name_type);
+                               name_type,
+                               &c);
+       if (!NT_STATUS_IS_OK(status)) {
+               return NULL;
+       }
+       return c;
 }
 
 /****************************************************************************