Changeset 988 for vendor/current/nsswitch/libwbclient/wbclient.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/nsswitch/libwbclient/wbclient.c
r740 r988 5 5 6 6 Copyright (C) Gerald (Jerry) Carter 2007 7 Copyright (C) Matthew Newton 2015 7 8 8 9 … … 28 29 /* From wb_common.c */ 29 30 30 NSS_STATUS winbindd_request_response(int req_type, 31 struct winbindd_context; 32 33 NSS_STATUS winbindd_request_response(struct winbindd_context *wbctx, 34 int req_type, 31 35 struct winbindd_request *request, 32 36 struct winbindd_response *response); 33 NSS_STATUS winbindd_priv_request_response(int req_type, 37 NSS_STATUS winbindd_priv_request_response(struct winbindd_context *wbctx, 38 int req_type, 34 39 struct winbindd_request *request, 35 40 struct winbindd_response *response); 41 struct winbindd_context *winbindd_ctx_create(void); 42 void winbindd_ctx_free(struct winbindd_context *ctx); 43 44 /* Global context used for non-Ctx functions */ 45 46 static struct wbcContext wbcGlobalCtx = { 47 .winbindd_ctx = NULL, 48 .pw_cache_size = 0, 49 .pw_cache_idx = 0, 50 .gr_cache_size = 0, 51 .gr_cache_idx = 0 52 }; 36 53 37 54 /* … … 49 66 50 67 static wbcErr wbcRequestResponseInt( 68 struct winbindd_context *wbctx, 51 69 int cmd, 52 70 struct winbindd_request *request, 53 71 struct winbindd_response *response, 54 NSS_STATUS (*fn)( int req_type,72 NSS_STATUS (*fn)(struct winbindd_context *wbctx, int req_type, 55 73 struct winbindd_request *request, 56 74 struct winbindd_response *response)) … … 61 79 /* for some calls the request and/or response can be NULL */ 62 80 63 nss_status = fn( cmd, request, response);81 nss_status = fn(wbctx, cmd, request, response); 64 82 65 83 switch (nss_status) { … … 84 102 * @brief Wrapper around Winbind's send/receive API call 85 103 * 104 * @param ctx Context 86 105 * @param cmd Winbind command operation to perform 87 106 * @param request Send structure … … 90 109 * @return #wbcErr 91 110 */ 92 wbcErr wbcRequestResponse( int cmd,111 wbcErr wbcRequestResponse(struct wbcContext *ctx, int cmd, 93 112 struct winbindd_request *request, 94 113 struct winbindd_response *response) 95 114 { 96 return wbcRequestResponseInt(cmd, request, response, 115 struct winbindd_context *wbctx = NULL; 116 117 if (ctx) { 118 wbctx = ctx->winbindd_ctx; 119 } 120 121 return wbcRequestResponseInt(wbctx, cmd, request, response, 97 122 winbindd_request_response); 98 123 } 99 124 100 wbcErr wbcRequestResponsePriv( int cmd,125 wbcErr wbcRequestResponsePriv(struct wbcContext *ctx, int cmd, 101 126 struct winbindd_request *request, 102 127 struct winbindd_response *response) 103 128 { 104 return wbcRequestResponseInt(cmd, request, response, 129 struct winbindd_context *wbctx = NULL; 130 131 if (ctx) { 132 wbctx = ctx->winbindd_ctx; 133 } 134 135 return wbcRequestResponseInt(wbctx, cmd, request, response, 105 136 winbindd_priv_request_response); 106 137 } … … 258 289 return WBC_ERR_SUCCESS; 259 290 } 291 292 /* Context handling functions */ 293 294 static void wbcContextDestructor(void *ptr) 295 { 296 struct wbcContext *ctx = (struct wbcContext *)ptr; 297 298 winbindd_ctx_free(ctx->winbindd_ctx); 299 } 300 301 struct wbcContext *wbcCtxCreate(void) 302 { 303 struct wbcContext *ctx; 304 struct winbindd_context *wbctx; 305 306 ctx = (struct wbcContext *)wbcAllocateMemory( 307 1, sizeof(struct wbcContext), wbcContextDestructor); 308 309 if (!ctx) { 310 return NULL; 311 } 312 313 wbctx = winbindd_ctx_create(); 314 315 if (!wbctx) { 316 wbcFreeMemory(ctx); 317 return NULL; 318 } 319 320 ctx->winbindd_ctx = wbctx; 321 322 return ctx; 323 } 324 325 void wbcCtxFree(struct wbcContext *ctx) 326 { 327 wbcFreeMemory(ctx); 328 } 329 330 struct wbcContext *wbcGetGlobalCtx(void) 331 { 332 return &wbcGlobalCtx; 333 }
Note:
See TracChangeset
for help on using the changeset viewer.