2 * $Header: /data/src/mirror/cvs/samba/source/pam_ntdom/Attic/support.c,v 1.1.2.1 2000/04/09 02:04:30 lkcl Exp $
6 * Copyright Andrew Morgan, 1996. All rights reserved.
7 * Modified by Alexander O. Yuriev
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, and the entire permission notice in its entirety,
14 * including the disclaimer of warranties.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote
19 * products derived from this software without specific prior
22 * ALTERNATIVELY, this product may be distributed under the terms of
23 * the GNU Public License, in which case the provisions of the GPL are
24 * required INSTEAD OF the above restrictions. (This clause is
25 * necessary due to a potential bad interaction between the GPL and
26 * the restrictions contained in a BSD-style copyright.)
28 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
32 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
38 * OF THE POSSIBILITY OF SUCH DAMAGE.
43 * Revision 1.1.2.1 2000/04/09 02:04:30 lkcl
44 * added pam_ntdom. amazingly, it actually works.
46 * Revision 1.1 1998/04/17 15:34:25 lkcl
48 * adding pam_ntdom to samba source repository. this version is known as 0.21
50 * further work to be done is:
52 * - to add the "change machine password" support so that the transmission
53 * of the user's password is secure.
55 * - the session key needs to be generated from a random number.
57 * - the domain server needs to be automatically detected (using a UDP 138
58 * broadcast SAMQUERY packet to \\DOMAIN-NAME\MAILSLOT\NTLOGON)
60 * - the code to be changed from SamLogon immediately followed by SamLogoff
61 * to SamLogon when PAM user session starts followed by SamLogoff (or
62 * drop SMB connection) when PAM user session ends.
64 * this will result in the user _really_ joining the domain from the
65 * workstation, will all the benefits thereof (including that of the
66 * administrator being able to disconnect them!)
68 * Revision 1.1 1996/11/09 19:44:35 morgan
71 * Revision 1.1 1996/04/17 01:11:08 alex
76 #include <stdlib.h> /* define NULL */
80 #include <security/pam_appl.h>
84 #include <security/pam_modules.h>
94 /* Phototype declarations */
96 int converse( pam_handle_t
*pamh
,
98 struct pam_message
**message
,
99 struct pam_response
**response
);
101 int _set_auth_tok( pam_handle_t
*pamh
,
108 int converse( pam_handle_t
*pamh
,
110 struct pam_message
**message
,
111 struct pam_response
**response
)
115 struct pam_conv
*conv
;
117 retval
= pam_get_item( pamh
, PAM_CONV
, (const void **) &conv
) ;
118 if ( retval
== PAM_SUCCESS
)
120 retval
= conv
->conv( nargs
,
121 ( const struct pam_message
** ) message
,
128 /***************************************************************************/
129 /* prompt user for a using conversation calls */
130 /***************************************************************************/
132 int _set_auth_tok( pam_handle_t
*pamh
,
139 struct pam_message msg
[1],*pmsg
[1];
140 struct pam_response
*resp
;
142 /* set up conversation call */
145 msg
[0].msg_style
= PAM_PROMPT_ECHO_OFF
;
146 msg
[0].msg
= "Password: ";
149 if ( ( retval
= converse( pamh
, 1 , pmsg
, &resp
) ) != PAM_SUCCESS
)
154 if ( ( flags
& PAM_DISALLOW_NULL_AUTHTOK
) &&
155 resp
[0].resp
== NULL
)
163 /* This could be a memory leak. If resp[0].resp
164 is malloc()ed, then it has to be free()ed!
168 resp
[ 0 ].resp
= NULL
;
175 pam_set_item( pamh
, PAM_AUTHTOK
, p
);