s4-process_model: use the static module prototyping
[sfrench/samba-autobuild/.git] / source4 / winbind / wb_cmd_getpwuid.c
index 63a71b02ccd76c72196baa23587d771c0687f244..f6f3cb282e77be726c697d6bf547979c62b90c87 100644 (file)
 #include "includes.h"
 #include "libcli/composite/composite.h"
 #include "winbind/wb_server.h"
-#include "winbind/wb_async_helpers.h"
-#include "winbind/wb_helper.h"
 #include "smbd/service_task.h"
-#include "nsswitch/winbindd_nss.h"
-#include "libnet/libnet_proto.h"
 #include "param/param.h"
-#include "libcli/security/proto.h"
-#include "auth/credentials/credentials.h"
 
 struct cmd_getpwuid_state {
        struct composite_context *ctx;
        struct wbsrv_service *service;
        uid_t uid;
+       struct dom_sid *sid;
        char *workgroup;
        struct wbsrv_domain *domain;
 
@@ -55,7 +50,7 @@ struct composite_context *wb_cmd_getpwuid_send(TALLOC_CTX *mem_ctx,
        struct composite_context *ctx, *result;
        struct cmd_getpwuid_state *state;
 
-       DEBUG(5, ("wb_cmd_getpwnam_send called\n"));
+       DEBUG(5, ("wb_cmd_getpwuid_send called\n"));
 
        result = composite_create(mem_ctx, service->task->event_ctx);
        if (!result) return NULL;
@@ -82,14 +77,13 @@ static void cmd_getpwuid_recv_sid(struct composite_context *ctx)
        struct cmd_getpwuid_state *state =
                talloc_get_type(ctx->async.private_data,
                                struct cmd_getpwuid_state);
-       struct dom_sid *sid;
 
        DEBUG(5, ("cmd_getpwuid_recv_sid called %p\n", ctx->private_data));
 
-       state->ctx->status = wb_uid2sid_recv(ctx, state, &sid);
+       state->ctx->status = wb_uid2sid_recv(ctx, state, &state->sid);
        if (!composite_is_ok(state->ctx)) return;
 
-       ctx = wb_sid2domain_send(state, state->service, sid);
+       ctx = wb_sid2domain_send(state, state->service, state->sid);
 
        composite_continue(state->ctx, ctx, cmd_getpwuid_recv_domain, state);
 }
@@ -111,7 +105,8 @@ static void cmd_getpwuid_recv_domain(struct composite_context *ctx)
        user_info = talloc(state, struct libnet_UserInfo);
        if (composite_nomem(user_info, state->ctx)) return;
 
-       user_info->in.user_name = state->domain->libnet_ctx->cred->username;
+       user_info->in.level = USER_INFO_BY_SID;
+       user_info->in.data.user_sid = state->sid;
        user_info->in.domain_name = state->domain->libnet_ctx->samr.name;
 
        /* We need the workgroup later, so copy it  */
@@ -149,12 +144,14 @@ static void cmd_getpwuid_recv_user_info(struct composite_context *ctx)
        WBSRV_SAMBA3_SET_STRING(pw->pw_name, user_info->out.account_name);
        WBSRV_SAMBA3_SET_STRING(pw->pw_passwd, "*");
        WBSRV_SAMBA3_SET_STRING(pw->pw_gecos, user_info->out.full_name);
-       WBSRV_SAMBA3_SET_STRING(pw->pw_dir, lp_template_homedir());
+       WBSRV_SAMBA3_SET_STRING(pw->pw_dir, 
+               lpcfg_template_homedir(state->service->task->lp_ctx));
        all_string_sub(pw->pw_dir, "%WORKGROUP%", state->workgroup,
                        sizeof(fstring) - 1);
        all_string_sub(pw->pw_dir, "%ACCOUNTNAME%", user_info->out.account_name,
                        sizeof(fstring) - 1);
-       WBSRV_SAMBA3_SET_STRING(pw->pw_shell, lp_template_shell());
+       WBSRV_SAMBA3_SET_STRING(pw->pw_shell, 
+                               lpcfg_template_shell(state->service->task->lp_ctx));
 
        pw->pw_uid = state->uid;
 
@@ -188,7 +185,7 @@ NTSTATUS wb_cmd_getpwuid_recv(struct composite_context *ctx,
 {
        NTSTATUS status = composite_wait(ctx);
 
-       DEBUG(5, ("wb_cmd_getpwnam_recv called\n"));
+       DEBUG(5, ("wb_cmd_getpwuid_recv called\n"));
 
        if (NT_STATUS_IS_OK(status)) {
                struct cmd_getpwuid_state *state =