diff options
author | Volker Lendecke <vl@samba.org> | 2010-01-09 20:20:36 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2010-01-24 20:32:16 +0100 |
commit | 7d18d058a1203ab7079f9dbdf37962803064d699 (patch) | |
tree | 44b5e54adfe02dccd954570ad5993c3dceed9475 /source3 | |
parent | 185815a6472a7a09602b3c51198e20257241dfa7 (diff) | |
download | samba-7d18d058a1203ab7079f9dbdf37962803064d699.tar.gz samba-7d18d058a1203ab7079f9dbdf37962803064d699.tar.bz2 samba-7d18d058a1203ab7079f9dbdf37962803064d699.zip |
s3: Add wbinfo --ccache-save
With this command you can give winbind your password for later use by
the automatic ntlm_auth
Diffstat (limited to 'source3')
-rw-r--r-- | source3/winbindd/winbindd.c | 1 | ||||
-rw-r--r-- | source3/winbindd/winbindd_ccache_access.c | 72 | ||||
-rw-r--r-- | source3/winbindd/winbindd_domain.c | 4 | ||||
-rw-r--r-- | source3/winbindd/winbindd_proto.h | 3 |
4 files changed, 80 insertions, 0 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index f6f4a8fee7..c0b42b811d 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -451,6 +451,7 @@ static struct winbindd_dispatch_table { /* Credential cache access */ { WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" }, + { WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" }, /* WINS functions */ diff --git a/source3/winbindd/winbindd_ccache_access.c b/source3/winbindd/winbindd_ccache_access.c index 2f71aaae52..b0efc6474b 100644 --- a/source3/winbindd/winbindd_ccache_access.c +++ b/source3/winbindd/winbindd_ccache_access.c @@ -278,3 +278,75 @@ enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *doma process_result: return NT_STATUS_IS_OK(result) ? WINBINDD_OK : WINBINDD_ERROR; } + +void winbindd_ccache_save(struct winbindd_cli_state *state) +{ + struct winbindd_domain *domain; + fstring name_domain, name_user; + + /* Ensure null termination */ + state->request->data.ccache_save.user[ + sizeof(state->request->data.ccache_save.user)-1]='\0'; + state->request->data.ccache_save.pass[ + sizeof(state->request->data.ccache_save.pass)-1]='\0'; + + DEBUG(3, ("[%5lu]: save passord of user %s\n", + (unsigned long)state->pid, + state->request->data.ccache_save.user)); + + /* Parse domain and username */ + + if (!canonicalize_username(state->request->data.ccache_ntlm_auth.user, + name_domain, name_user)) { + DEBUG(5,("winbindd_ccache_save: cannot parse domain and user " + "from name [%s]\n", + state->request->data.ccache_save.user)); + request_error(state); + return; + } + + domain = find_auth_domain(state->request->flags, name_domain); + + if (domain == NULL) { + DEBUG(5, ("winbindd_ccache_save: can't get domain [%s]\n", + name_domain)); + request_error(state); + return; + } + + if (!check_client_uid(state, state->request->data.ccache_save.uid)) { + request_error(state); + return; + } + + sendto_domain(state, domain); +} + +enum winbindd_result winbindd_dual_ccache_save( + struct winbindd_domain *domain, struct winbindd_cli_state *state) +{ + NTSTATUS status = NT_STATUS_NOT_SUPPORTED; + + /* Ensure null termination */ + state->request->data.ccache_save.user[ + sizeof(state->request->data.ccache_save.user)-1]='\0'; + state->request->data.ccache_save.pass[ + sizeof(state->request->data.ccache_save.pass)-1]='\0'; + + DEBUG(3, ("winbindd_dual_ccache_save: [%5lu]: save password of user " + "%s\n", (unsigned long)state->pid, + state->request->data.ccache_save.user)); + + status = winbindd_add_memory_creds( + state->request->data.ccache_save.user, + state->request->data.ccache_save.uid, + state->request->data.ccache_save.pass); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("winbindd_add_memory_creds failed %s\n", + nt_errstr(status))); + return WINBINDD_ERROR; + } + + return WINBINDD_OK; +} diff --git a/source3/winbindd/winbindd_domain.c b/source3/winbindd/winbindd_domain.c index 45da57e132..2cb6e31a9e 100644 --- a/source3/winbindd/winbindd_domain.c +++ b/source3/winbindd/winbindd_domain.c @@ -67,6 +67,10 @@ static const struct winbindd_child_dispatch_table domain_dispatch_table[] = { .struct_cmd = WINBINDD_CCACHE_NTLMAUTH, .struct_fn = winbindd_dual_ccache_ntlm_auth, },{ + .name = "CCACHE_SAVE", + .struct_cmd = WINBINDD_CCACHE_SAVE, + .struct_fn = winbindd_dual_ccache_save, + },{ .name = "NDRCMD", .struct_cmd = WINBINDD_DUAL_NDRCMD, .struct_fn = winbindd_dual_ndrcmd, diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 93d5748c49..f6c4dade4a 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -180,6 +180,9 @@ void wcache_store_ndr(struct winbindd_domain *domain, uint32_t opnum, void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state); enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *domain, struct winbindd_cli_state *state); +void winbindd_ccache_save(struct winbindd_cli_state *state); +enum winbindd_result winbindd_dual_ccache_save( + struct winbindd_domain *domain, struct winbindd_cli_state *state); /* The following definitions come from winbindd/winbindd_cm.c */ |