2 Unix SMB/Netbios implementation.
5 Winbind daemon - pam auuth funcions
7 Copyright (C) Andrew Tridgell 2000
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /************************************************************************
26 form a key for fetching a domain trust password
27 ************************************************************************/
28 static char *trust_keystr(char *domain)
30 static fstring keystr;
31 slprintf(keystr,sizeof(keystr),"%s/%s", SECRETS_MACHINE_ACCT_PASS, domain);
35 /************************************************************************
36 Routine to get the trust account password for a domain.
37 The user of this function must have locked the trust password file.
38 ************************************************************************/
39 static BOOL _get_trust_account_password(char *domain, unsigned char *ret_pwd, time_t *pass_last_set_time)
41 struct machine_acct_pass *pass;
44 if (!(pass = secrets_fetch(trust_keystr(domain), &size)) ||
45 size != sizeof(*pass)) return False;
47 if (pass_last_set_time) *pass_last_set_time = pass->mod_time;
48 memcpy(ret_pwd, pass->hash, 16);
54 /* Return a password structure from a username. Specify whether cached data
57 enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state)
59 NET_USER_INFO_3 info3;
62 uchar trust_passwd[16];
65 fstring name_domain, name_user;
66 extern pstring global_myname;
68 DEBUG(1,("winbindd_pam_auth user=%s\n",
69 state->request.data.auth.user));
71 /* Parse domain and username */
72 parse_domain_user(state->request.data.auth.user, name_domain, name_user);
74 /* don't allow the null domain */
75 if (strcmp(name_domain,"") == 0) return WINBINDD_ERROR;
79 if (!_get_trust_account_password(name_domain, trust_passwd, NULL)) return WINBINDD_ERROR;
81 nt_lm_owf_gen(state->request.data.auth.pass, ntpw, lmpw);
83 slprintf(server, sizeof(server), "\\\\%s", server_state.controller);
85 status = domain_client_validate_backend(server,
86 name_user, name_domain,
87 global_myname, SEC_CHAN_WKSTA,
91 ntpw, sizeof(ntpw), &info3);
93 if (status != NT_STATUS_NOPROBLEMO) return WINBINDD_ERROR;