summaryrefslogtreecommitdiffstats
path: root/source3/passdb/passdb.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-05-24 13:36:43 +0000
committerLuke Leighton <lkcl@samba.org>1998-05-24 13:36:43 +0000
commit684edc9fcd73d9c2059d018c4b5eb599888cfd8b (patch)
tree56e99e6905c79a889d82630fc1e6d22f625f79ad /source3/passdb/passdb.c
parent0f9d24f083acb5bb17d220ac6bcac833625e1f74 (diff)
downloadsamba-684edc9fcd73d9c2059d018c4b5eb599888cfd8b.tar.gz
samba-684edc9fcd73d9c2059d018c4b5eb599888cfd8b.tar.xz
samba-684edc9fcd73d9c2059d018c4b5eb599888cfd8b.zip
- created pdb_sethexpwd(), to be called from all pwd apis that need to
store passwords in ascii format - dealt with lots of signed/unsigned char thingies spotted by Tim Winders. (This used to be commit bd825f1ef15c4bf12aeba945f8bfdc7fd0e14d25)
Diffstat (limited to 'source3/passdb/passdb.c')
-rw-r--r--source3/passdb/passdb.c72
1 files changed, 51 insertions, 21 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 4a86e095daf..b07829cb8b6 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -736,31 +736,61 @@ uint16 pdb_decode_acct_ctrl(char *p)
}
/*************************************************************
- Routine to get the next 32 hex characters and turn them
+ Routine to get the 32 hex characters and turn them
into a 16 byte array.
**************************************************************/
+BOOL pdb_gethexpwd(char *p, char *pwd)
+{
+ int i;
+ unsigned char lonybble, hinybble;
+ char *hexchars = "0123456789ABCDEF";
+ char *p1, *p2;
+
+ for (i = 0; i < 32; i += 2)
+ {
+ hinybble = toupper(p[i]);
+ lonybble = toupper(p[i + 1]);
+
+ p1 = strchr(hexchars, hinybble);
+ p2 = strchr(hexchars, lonybble);
+
+ if (!p1 || !p2)
+ {
+ return (False);
+ }
-int pdb_gethexpwd(char *p, char *pwd)
+ hinybble = PTR_DIFF(p1, hexchars);
+ lonybble = PTR_DIFF(p2, hexchars);
+
+ pwd[i / 2] = (hinybble << 4) | lonybble;
+ }
+ return (True);
+}
+
+/*************************************************************
+ Routine to set 32 hex password characters from a 16 byte array.
+**************************************************************/
+void pdb_sethexpwd(char *p, char *pwd, uint16 acct_ctrl)
{
- int i;
- unsigned char lonybble, hinybble;
- char *hexchars = "0123456789ABCDEF";
- char *p1, *p2;
-
- for (i = 0; i < 32; i += 2) {
- hinybble = toupper(p[i]);
- lonybble = toupper(p[i + 1]);
-
- p1 = strchr(hexchars, hinybble);
- p2 = strchr(hexchars, lonybble);
- if (!p1 || !p2)
- return (False);
- hinybble = PTR_DIFF(p1, hexchars);
- lonybble = PTR_DIFF(p2, hexchars);
-
- pwd[i / 2] = (hinybble << 4) | lonybble;
- }
- return (True);
+ if (pwd != NULL)
+ {
+ int i;
+ for (i = 0; i < 16; i++)
+ {
+ slprintf(&p[i*2], 33, "%02X", pwd[i]);
+ }
+ }
+ else
+ {
+ if (IS_BITS_SET_ALL(acct_ctrl, ACB_PWNOTREQ))
+ {
+ safe_strcpy(p, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX", 33);
+ }
+ else
+ {
+ safe_strcpy(p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 33);
+ }
+ }
}
/*******************************************************************