The branch, master has been updated
       via  8083849 s3: Make cli_cm_open return NTSTATUS
       via  714e101 s3: Make cli_cm_connect return NTSTATUS
       via  7ca63fb s3: Make "do_connect" return NTSTATUS
       via  3414182 s3: Remove a use of cli_errstr
       via  4569a3a s3: Remove a use of cli_errstr
       via  8238d89 s3: Remove a use of cli_errstr
       via  cfbd339 s3: Remove a use of cli_errstr
      from  e5ad524 s3: Remove two uses of cli_errstr

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 80838491e6ac9f4299daccfc5506b3e1e79fab38
Author: Volker Lendecke <[email protected]>
Date:   Sun Jul 3 19:59:37 2011 +0200

    s3: Make cli_cm_open return NTSTATUS
    
    Autobuild-User: Volker Lendecke <[email protected]>
    Autobuild-Date: Sun Jul  3 23:57:53 CEST 2011 on sn-devel-104

commit 714e1014c59979d9a7a7c12f21185fdf7bcab818
Author: Volker Lendecke <[email protected]>
Date:   Sun Jul 3 12:12:45 2011 +0200

    s3: Make cli_cm_connect return NTSTATUS

commit 7ca63fb8fe17ccbfa5400c2b6d465a21096cb8fc
Author: Volker Lendecke <[email protected]>
Date:   Sun Jul 3 12:08:54 2011 +0200

    s3: Make "do_connect" return NTSTATUS

commit 3414182af0ae2dcd8ebaa93cccfd62602e9863d1
Author: Volker Lendecke <[email protected]>
Date:   Sun Jul 3 12:04:24 2011 +0200

    s3: Remove a use of cli_errstr

commit 4569a3a75a047d2e4b84d681d8478640ad89d48d
Author: Volker Lendecke <[email protected]>
Date:   Sun Jul 3 11:49:07 2011 +0200

    s3: Remove a use of cli_errstr

commit 8238d89823ba9205546ea0538f1d6b844b3ba829
Author: Volker Lendecke <[email protected]>
Date:   Sun Jul 3 11:47:44 2011 +0200

    s3: Remove a use of cli_errstr

commit cfbd339b4a9e11f781755581efbe51d99dc997b6
Author: Volker Lendecke <[email protected]>
Date:   Sun Jul 3 11:46:50 2011 +0200

    s3: Remove a use of cli_errstr

-----------------------------------------------------------------------

Summary of changes:
 source3/client/client.c       |   62 +++++++++++-------
 source3/lib/netapi/cm.c       |   17 +++--
 source3/libsmb/clidfs.c       |  139 +++++++++++++++++++++++------------------
 source3/libsmb/libsmb_xattr.c |   28 +++++---
 source3/libsmb/proto.h        |    5 +-
 5 files changed, 148 insertions(+), 103 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index 94c7e98..bc653d5 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4466,12 +4466,15 @@ static int process_command_string(const char *cmd_in)
        /* establish the connection if not already */
 
        if (!cli) {
-               cli = cli_cm_open(talloc_tos(), NULL,
-                               have_ip ? dest_ss_str : desthost,
-                               service, auth_info,
-                               true, smb_encrypt,
-                               max_protocol, port, name_type);
-               if (!cli) {
+               NTSTATUS status;
+
+               status = cli_cm_open(talloc_tos(), NULL,
+                                    have_ip ? dest_ss_str : desthost,
+                                    service, auth_info,
+                                    true, smb_encrypt,
+                                    max_protocol, port, name_type,
+                                    &cli);
+               if (!NT_STATUS_IS_OK(status)) {
                        return 1;
                }
        }
@@ -4938,12 +4941,13 @@ static int process_stdin(void)
 static int process(const char *base_directory)
 {
        int rc = 0;
+       NTSTATUS status;
 
-       cli = cli_cm_open(talloc_tos(), NULL,
-                       have_ip ? dest_ss_str : desthost,
-                       service, auth_info, true, smb_encrypt,
-                       max_protocol, port, name_type);
-       if (!cli) {
+       status = cli_cm_open(talloc_tos(), NULL,
+                            have_ip ? dest_ss_str : desthost,
+                            service, auth_info, true, smb_encrypt,
+                            max_protocol, port, name_type, &cli);
+       if (!NT_STATUS_IS_OK(status)) {
                return 1;
        }
 
@@ -4971,11 +4975,15 @@ static int process(const char *base_directory)
 
 static int do_host_query(const char *query_host)
 {
-       cli = cli_cm_open(talloc_tos(), NULL,
-                       have_ip ? dest_ss_str : query_host, "IPC$", auth_info, 
true, smb_encrypt,
-                       max_protocol, port, name_type);
-       if (!cli)
+       NTSTATUS status;
+
+       status = cli_cm_open(talloc_tos(), NULL,
+                            have_ip ? dest_ss_str : query_host,
+                            "IPC$", auth_info, true, smb_encrypt,
+                            max_protocol, port, name_type, &cli);
+       if (!NT_STATUS_IS_OK(status)) {
                return 1;
+       }
 
        browse_host(true);
 
@@ -4997,10 +5005,13 @@ static int do_host_query(const char *query_host)
                   else but port 139... */
 
                cli_shutdown(cli);
-               cli = cli_cm_open(talloc_tos(), NULL,
-                               have_ip ? dest_ss_str : query_host, "IPC$",
-                               auth_info, true, smb_encrypt,
-                               max_protocol, 139, name_type);
+               status = cli_cm_open(talloc_tos(), NULL,
+                                    have_ip ? dest_ss_str : query_host,
+                                    "IPC$", auth_info, true, smb_encrypt,
+                                    max_protocol, 139, name_type, &cli);
+               if (!NT_STATUS_IS_OK(status)) {
+                       cli = NULL;
+               }
        }
 
        if (cli == NULL) {
@@ -5025,12 +5036,15 @@ static int do_tar_op(const char *base_directory)
 
        /* do we already have a connection? */
        if (!cli) {
-               cli = cli_cm_open(talloc_tos(), NULL,
-                       have_ip ? dest_ss_str : desthost,
-                       service, auth_info, true, smb_encrypt,
-                       max_protocol, port, name_type);
-               if (!cli)
+               NTSTATUS status;
+
+               status = cli_cm_open(talloc_tos(), NULL,
+                                    have_ip ? dest_ss_str : desthost,
+                                    service, auth_info, true, smb_encrypt,
+                                    max_protocol, port, name_type, &cli);
+               if (!NT_STATUS_IS_OK(status)) {
                        return 1;
+               }
        }
 
        recurse=true;
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index 47ccf8b..d41a5ca 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -67,6 +67,7 @@ static WERROR libnetapi_open_ipc_connection(struct 
libnetapi_ctx *ctx,
        struct user_auth_info *auth_info = NULL;
        struct cli_state *cli_ipc = NULL;
        struct client_ipc_connection *p;
+       NTSTATUS status;
 
        if (!ctx || !pp || !server_name) {
                return WERR_INVALID_PARAM;
@@ -103,16 +104,18 @@ static WERROR libnetapi_open_ipc_connection(struct 
libnetapi_ctx *ctx,
                set_cmdline_auth_info_use_ccache(auth_info, true);
        }
 
-       cli_ipc = cli_cm_open(ctx, NULL,
-                               server_name, "IPC$",
-                               auth_info,
-                               false, false,
-                               PROTOCOL_NT1,
-                               0, 0x20);
-       if (cli_ipc) {
+       status = cli_cm_open(ctx, NULL,
+                            server_name, "IPC$",
+                            auth_info,
+                            false, false,
+                            PROTOCOL_NT1,
+                            0, 0x20, &cli_ipc);
+       if (NT_STATUS_IS_OK(status)) {
                cli_set_username(cli_ipc, ctx->username);
                cli_set_password(cli_ipc, ctx->password);
                cli_set_domain(cli_ipc, ctx->workgroup);
+       } else {
+               cli_ipc = NULL;
        }
        TALLOC_FREE(auth_info);
 
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 5c5257f..bb08b22 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -77,7 +77,7 @@ NTSTATUS cli_cm_force_encryption(struct cli_state *c,
  Return a connection to a server.
 ********************************************************************/
 
-static struct cli_state *do_connect(TALLOC_CTX *ctx,
+static NTSTATUS do_connect(TALLOC_CTX *ctx,
                                        const char *server,
                                        const char *share,
                                        const struct user_auth_info *auth_info,
@@ -85,7 +85,8 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                                        bool force_encrypt,
                                        int max_protocol,
                                        int port,
-                                       int name_type)
+                                       int name_type,
+                                       struct cli_state **pcli)
 {
        struct cli_state *c = NULL;
        char *servicename;
@@ -98,7 +99,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
        /* make a copy so we don't modify the global string 'service' */
        servicename = talloc_strdup(ctx,share);
        if (!servicename) {
-               return NULL;
+               return NT_STATUS_NO_MEMORY;
        }
        sharename = servicename;
        if (*sharename == '\\') {
@@ -108,13 +109,13 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                }
                sharename = strchr_m(sharename,'\\');
                if (!sharename) {
-                       return NULL;
+                       return NT_STATUS_NO_MEMORY;
                }
                *sharename = 0;
                sharename++;
        }
        if (server == NULL) {
-               return NULL;
+               return NT_STATUS_INVALID_PARAMETER;
        }
 
        status = cli_connect_nb(
@@ -125,7 +126,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                d_printf("Connection to %s failed (Error %s)\n",
                                server,
                                nt_errstr(status));
-               return NULL;
+               return status;
        }
 
        if (max_protocol == 0) {
@@ -145,30 +146,32 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                d_printf("protocol negotiation failed: %s\n",
                         nt_errstr(status));
                cli_shutdown(c);
-               return NULL;
+               return status;
        }
 
        username = get_cmdline_auth_info_username(auth_info);
        password = get_cmdline_auth_info_password(auth_info);
 
-       if (!NT_STATUS_IS_OK(cli_session_setup(c, username,
-                                              password, strlen(password),
-                                              password, strlen(password),
-                                              lp_workgroup()))) {
+       status = cli_session_setup(c, username,
+                                  password, strlen(password),
+                                  password, strlen(password),
+                                  lp_workgroup());
+       if (!NT_STATUS_IS_OK(status)) {
                /* If a password was not supplied then
                 * try again with a null username. */
                if (password[0] || !username[0] ||
                        get_cmdline_auth_info_use_kerberos(auth_info) ||
-                       !NT_STATUS_IS_OK(cli_session_setup(c, "",
+                       !NT_STATUS_IS_OK(status = cli_session_setup(c, "",
                                                "", 0,
                                                "", 0,
                                               lp_workgroup()))) {
-                       d_printf("session setup failed: %s\n", cli_errstr(c));
+                       d_printf("session setup failed: %s\n",
+                                nt_errstr(status));
                        if (NT_STATUS_V(cli_nt_error(c)) ==
                            NT_STATUS_V(NT_STATUS_MORE_PROCESSING_REQUIRED))
                                d_printf("did you forget to run kinit?\n");
                        cli_shutdown(c);
-                       return NULL;
+                       return status;
                }
                d_printf("Anonymous login successful\n");
                status = cli_init_creds(c, "", lp_workgroup(), "");
@@ -179,7 +182,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10,("cli_init_creds() failed: %s\n", nt_errstr(status)));
                cli_shutdown(c);
-               return NULL;
+               return status;
        }
 
        if ( show_sessetup ) {
@@ -209,7 +212,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                return do_connect(ctx, newserver,
                                newshare, auth_info, false,
                                force_encrypt, max_protocol,
-                               port, name_type);
+                               port, name_type, pcli);
        }
 
        /* must be a normal share */
@@ -219,7 +222,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("tree connect failed: %s\n", nt_errstr(status));
                cli_shutdown(c);
-               return NULL;
+               return status;
        }
 
        if (force_encrypt) {
@@ -230,12 +233,13 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                                        sharename);
                if (!NT_STATUS_IS_OK(status)) {
                        cli_shutdown(c);
-                       return NULL;
+                       return status;
                }
        }
 
        DEBUG(4,(" tconx ok\n"));
-       return c;
+       *pcli = c;
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
@@ -257,26 +261,28 @@ 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;
 
-       cli = do_connect(ctx, server, share,
+       status = do_connect(ctx, server, share,
                                auth_info,
                                show_hdr, force_encrypt, max_protocol,
-                               port, name_type);
+                               port, name_type, &cli);
 
-       if (!cli ) {
-               return NULL;
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
        /* Enter into the list. */
@@ -287,7 +293,6 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
        if (referring_cli && referring_cli->requested_posix_capabilities) {
                uint16 major, minor;
                uint32 caplow, caphigh;
-               NTSTATUS status;
                status = cli_unix_extensions_version(cli, &major, &minor,
                                                     &caplow, &caphigh);
                if (NT_STATUS_IS_OK(status)) {
@@ -297,7 +302,8 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
                }
        }
 
-       return cli;
+       *pcli = cli;
+       return NT_STATUS_OK;
 }
 
 /********************************************************************
@@ -337,7 +343,7 @@ static struct cli_state *cli_cm_find(struct cli_state *cli,
  Open a client connection to a \\server\share.
 ****************************************************************************/
 
-struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
+NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
                                struct cli_state *referring_cli,
                                const char *server,
                                const char *share,
@@ -346,13 +352,16 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
                                bool force_encrypt,
                                int max_protocol,
                                int port,
-                               int name_type)
+                               int name_type,
+                               struct cli_state **pcli)
 {
        /* 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;
+               *pcli = c;
+               return NT_STATUS_OK;
        }
 
        if (auth_info == NULL) {
@@ -361,10 +370,10 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
                d_printf("cli_cm_open() Unable to open connection [\\%s\\%s] "
                        "without auth info\n",
                        server, share );
-               return NULL;
+               return NT_STATUS_INVALID_PARAMETER;
        }
 
-       return cli_cm_connect(ctx,
+       status = cli_cm_connect(ctx,
                                referring_cli,
                                server,
                                share,
@@ -373,7 +382,13 @@ 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 status;
+       }
+       *pcli = c;
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
@@ -817,16 +832,18 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
 
        /* Check for the referral. */
 
-       if (!(cli_ipc = cli_cm_open(ctx,
-                               rootcli,
-                               rootcli->desthost,
-                               "IPC$",
-                               dfs_auth_info,
-                               false,
-                               (rootcli->trans_enc_state != NULL),
-                               rootcli->protocol,
-                               0,
-                               0x20))) {
+       status = cli_cm_open(ctx,
+                            rootcli,
+                            rootcli->desthost,
+                            "IPC$",
+                            dfs_auth_info,
+                            false,
+                            (rootcli->trans_enc_state != NULL),
+                            rootcli->protocol,
+                            0,
+                            0x20,
+                            &cli_ipc);
+       if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
 
@@ -867,15 +884,17 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
         */
 
        /* Open the connection to the target server & share */
-       if ((*targetcli = cli_cm_open(ctx, rootcli,
-                                       server,
-                                       share,
-                                       dfs_auth_info,
-                                       false,
-                                       (rootcli->trans_enc_state != NULL),
-                                       rootcli->protocol,
-                                       0,
-                                       0x20)) == NULL) {
+       status = cli_cm_open(ctx, rootcli,
+                            server,
+                            share,
+                            dfs_auth_info,
+                            false,
+                            (rootcli->trans_enc_state != NULL),
+                            rootcli->protocol,
+                            0,
+                            0x20,
+                            targetcli);
+       if (!NT_STATUS_IS_OK(status)) {
                d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
                        server, share );
                return false;
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index eeff9a9..7695dfb 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -884,6 +884,7 @@ cacl_get(SMBCCTX *context,
         if (ipc_cli && (all || some_nt || all_nt_acls)) {
                char *targetpath = NULL;
                struct cli_state *targetcli = NULL;
+               NTSTATUS status;
 
                 /* Point to the portion after "system.nt_sec_desc." */
                 name += 19;     /* if (all) this will be invalid but unused */
@@ -898,10 +899,13 @@ cacl_get(SMBCCTX *context,
                }
 
                 /* ... then obtain any NT attributes which were requested */
-                if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0, 
CREATE_ACCESS_READ, 0,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 
0x0, 0x0, &fnum))) {
+               status = cli_ntcreate(targetcli, targetpath, 0,
+                                     CREATE_ACCESS_READ, 0,
+                                     FILE_SHARE_READ|FILE_SHARE_WRITE,
+                                     FILE_OPEN, 0x0, 0x0, &fnum);
+               if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(5, ("cacl_get failed to open %s: %s\n",
-                               targetpath, cli_errstr(targetcli)));
+                                 targetpath, nt_errstr(status)));
                        errno = 0;
                        return -1;
                }
@@ -1555,10 +1559,12 @@ cacl_set(SMBCCTX *context,
        /* The desired access below is the only one I could find that works
           with NT4, W2KP and Samba */
 
-       if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0, 
CREATE_ACCESS_READ, 0,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 
0x0, 0x0, &fnum))) {
+       status = cli_ntcreate(targetcli, targetpath, 0, CREATE_ACCESS_READ, 0,
+                             FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
+                             0x0, 0x0, &fnum);
+       if (!NT_STATUS_IS_OK(status)) {
                 DEBUG(5, ("cacl_set failed to open %s: %s\n",
-                          targetpath, cli_errstr(targetcli)));
+                          targetpath, nt_errstr(status)));
                 errno = 0;
                return -1;


-- 
Samba Shared Repository

Reply via email to