1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | Password cacheing. obfuscation is planned
|
---|
4 | Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
---|
5 |
|
---|
6 | This program is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2 of the License, or
|
---|
9 | (at your option) any later version.
|
---|
10 |
|
---|
11 | This program is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with this program; if not, write to the Free Software
|
---|
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #include "includes.h"
|
---|
22 |
|
---|
23 | /****************************************************************************
|
---|
24 | Initialises a password structure.
|
---|
25 | ****************************************************************************/
|
---|
26 |
|
---|
27 | static void pwd_init(struct pwd_info *pwd)
|
---|
28 | {
|
---|
29 | memset((char *)pwd->password , '\0', sizeof(pwd->password ));
|
---|
30 |
|
---|
31 | pwd->null_pwd = True; /* safest option... */
|
---|
32 | }
|
---|
33 |
|
---|
34 | /****************************************************************************
|
---|
35 | Stores a cleartext password.
|
---|
36 | ****************************************************************************/
|
---|
37 |
|
---|
38 | void pwd_set_cleartext(struct pwd_info *pwd, const char *clr)
|
---|
39 | {
|
---|
40 | pwd_init(pwd);
|
---|
41 | if (clr) {
|
---|
42 | fstrcpy(pwd->password, clr);
|
---|
43 | pwd->null_pwd = False;
|
---|
44 | } else {
|
---|
45 | pwd->null_pwd = True;
|
---|
46 | }
|
---|
47 |
|
---|
48 | pwd->cleartext = True;
|
---|
49 | }
|
---|
50 |
|
---|
51 | /****************************************************************************
|
---|
52 | Gets a cleartext password.
|
---|
53 | ****************************************************************************/
|
---|
54 |
|
---|
55 | void pwd_get_cleartext(struct pwd_info *pwd, fstring clr)
|
---|
56 | {
|
---|
57 | if (pwd->cleartext)
|
---|
58 | fstrcpy(clr, pwd->password);
|
---|
59 | else
|
---|
60 | clr[0] = 0;
|
---|
61 |
|
---|
62 | }
|
---|