Ignore:
Timestamp:
Jul 1, 2011, 8:40:10 AM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/lib/netapi/cm.c

    r414 r590  
    2626********************************************************************/
    2727
     28struct client_ipc_connection {
     29        struct client_ipc_connection *prev, *next;
     30        struct cli_state *cli;
     31        struct client_pipe_connection *pipe_connections;
     32};
     33
     34struct client_pipe_connection {
     35        struct client_pipe_connection *prev, *next;
     36        struct rpc_pipe_client *pipe;
     37};
     38
     39/********************************************************************
     40********************************************************************/
     41
     42static struct client_ipc_connection *ipc_cm_find(
     43        struct libnetapi_private_ctx *priv_ctx, const char *server_name)
     44{
     45        struct client_ipc_connection *p;
     46
     47        for (p = priv_ctx->ipc_connections; p; p = p->next) {
     48                if (strequal(p->cli->desthost, server_name)) {
     49                        return p;
     50                }
     51        }
     52
     53        return NULL;
     54}
     55
     56/********************************************************************
     57********************************************************************/
     58
    2859static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
    2960                                            const char *server_name,
    30                                             struct cli_state **cli)
    31 {
     61                                            struct client_ipc_connection **pp)
     62{
     63        struct libnetapi_private_ctx *priv_ctx =
     64                (struct libnetapi_private_ctx *)ctx->private_data;
    3265        struct user_auth_info *auth_info = NULL;
    3366        struct cli_state *cli_ipc = NULL;
    34 
    35         if (!ctx || !cli || !server_name) {
     67        struct client_ipc_connection *p;
     68
     69        if (!ctx || !pp || !server_name) {
    3670                return WERR_INVALID_PARAM;
    3771        }
    3872
    39         auth_info = user_auth_info_init(NULL);
     73        p = ipc_cm_find(priv_ctx, server_name);
     74        if (p) {
     75                *pp = p;
     76                return WERR_OK;
     77        }
     78
     79        auth_info = user_auth_info_init(ctx);
    4080        if (!auth_info) {
    4181                return WERR_NOMEM;
     
    79119        }
    80120
    81         *cli = cli_ipc;
     121        p = TALLOC_ZERO_P(ctx, struct client_ipc_connection);
     122        if (p == NULL) {
     123                return WERR_NOMEM;
     124        }
     125
     126        p->cli = cli_ipc;
     127        DLIST_ADD(priv_ctx->ipc_connections, p);
     128
     129        *pp = p;
    82130
    83131        return WERR_OK;
     
    87135********************************************************************/
    88136
    89 struct client_pipe_connection {
    90         struct client_pipe_connection *prev, *next;
    91         struct rpc_pipe_client *pipe;
    92         struct cli_state *cli;
    93 };
    94 
    95 static struct client_pipe_connection *pipe_connections;
    96 
    97 /********************************************************************
    98 ********************************************************************/
    99 
    100137WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx)
    101138{
    102         struct client_pipe_connection *p;
    103 
    104         for (p = pipe_connections; p; p = p->next) {
     139        struct libnetapi_private_ctx *priv_ctx =
     140                (struct libnetapi_private_ctx *)ctx->private_data;
     141        struct client_ipc_connection *p;
     142
     143        for (p = priv_ctx->ipc_connections; p; p = p->next) {
    105144                cli_shutdown(p->cli);
    106145        }
     
    112151********************************************************************/
    113152
    114 static NTSTATUS pipe_cm_find(struct cli_state *cli,
     153static NTSTATUS pipe_cm_find(struct client_ipc_connection *ipc,
    115154                             const struct ndr_syntax_id *interface,
    116155                             struct rpc_pipe_client **presult)
     
    118157        struct client_pipe_connection *p;
    119158
    120         for (p = pipe_connections; p; p = p->next) {
     159        for (p = ipc->pipe_connections; p; p = p->next) {
    121160
    122161                if (!rpc_pipe_np_smb_conn(p->pipe)) {
     
    124163                }
    125164
    126                 if (strequal(cli->desthost, p->pipe->desthost)
     165                if (strequal(ipc->cli->desthost, p->pipe->desthost)
    127166                    && ndr_syntax_id_equal(&p->pipe->abstract_syntax,
    128167                                           interface)) {
     
    139178
    140179static NTSTATUS pipe_cm_connect(TALLOC_CTX *mem_ctx,
    141                                 struct cli_state *cli,
     180                                struct client_ipc_connection *ipc,
    142181                                const struct ndr_syntax_id *interface,
    143182                                struct rpc_pipe_client **presult)
     
    151190        }
    152191
    153         status = cli_rpc_pipe_open_noauth(cli, interface, &p->pipe);
     192        status = cli_rpc_pipe_open_noauth(ipc->cli, interface, &p->pipe);
    154193        if (!NT_STATUS_IS_OK(status)) {
    155194                TALLOC_FREE(p);
     
    157196        }
    158197
    159         p->cli = cli;
    160         DLIST_ADD(pipe_connections, p);
     198        DLIST_ADD(ipc->pipe_connections, p);
    161199
    162200        *presult = p->pipe;
     
    168206
    169207static NTSTATUS pipe_cm_open(TALLOC_CTX *ctx,
    170                              struct cli_state *cli,
     208                             struct client_ipc_connection *ipc,
    171209                             const struct ndr_syntax_id *interface,
    172210                             struct rpc_pipe_client **presult)
    173211{
    174         if (NT_STATUS_IS_OK(pipe_cm_find(cli, interface, presult))) {
     212        if (NT_STATUS_IS_OK(pipe_cm_find(ipc, interface, presult))) {
    175213                return NT_STATUS_OK;
    176214        }
    177215
    178         return pipe_cm_connect(ctx, cli, interface, presult);
     216        return pipe_cm_connect(ctx, ipc, interface, presult);
    179217}
    180218
     
    190228        NTSTATUS status;
    191229        WERROR werr;
    192         struct cli_state *cli = NULL;
     230        struct client_ipc_connection *ipc = NULL;
    193231
    194232        if (!presult) {
     
    196234        }
    197235
    198         werr = libnetapi_open_ipc_connection(ctx, server_name, &cli);
     236        werr = libnetapi_open_ipc_connection(ctx, server_name, &ipc);
    199237        if (!W_ERROR_IS_OK(werr)) {
    200238                return werr;
    201239        }
    202240
    203         status = pipe_cm_open(ctx, cli, interface, &result);
     241        status = pipe_cm_open(ctx, ipc, interface, &result);
    204242        if (!NT_STATUS_IS_OK(status)) {
    205243                libnetapi_set_error_string(ctx, "failed to open PIPE %s: %s",
Note: See TracChangeset for help on using the changeset viewer.