diff options
author | Luke Leighton <lkcl@samba.org> | 1998-05-07 19:59:32 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1998-05-07 19:59:32 +0000 |
commit | b543829dfceae6781624bebe11a2365c34e2d159 (patch) | |
tree | 6ff2af6dada6447e556f199b4b63508a8dd02cf0 | |
parent | 01df1ed95f880a671ead7bc92b3bcff01a2e2dc0 (diff) | |
download | samba-b543829dfceae6781624bebe11a2365c34e2d159.tar.gz samba-b543829dfceae6781624bebe11a2365c34e2d159.tar.bz2 samba-b543829dfceae6781624bebe11a2365c34e2d159.zip |
moving gethexpwd into util.c, because it's used in both smbpass.c and ldap.c
(This used to be commit abe261b2f5ea7036e7be6230876176d134ef4ee4)
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/lib/util.c | 27 | ||||
-rw-r--r-- | source3/passdb/ldap.c | 28 | ||||
-rw-r--r-- | source3/passdb/smbpass.c | 29 | ||||
-rw-r--r-- | source3/utils/smbpasswd.c | 20 |
5 files changed, 38 insertions, 67 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 3cc48bb78f..fda55a652c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2028,6 +2028,7 @@ void print_asc(int level, unsigned char *buf,int len); void dump_data(int level,char *buf1,int len); char *tab_depth(int depth); char *dom_sid_to_string(DOM_SID *sid); +int gethexpwd(char *p, char *pwd); /*The following definitions come from web/cgi.c */ diff --git a/source3/lib/util.c b/source3/lib/util.c index 2416110857..2f637e1495 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -4965,3 +4965,30 @@ char *dom_sid_to_string(DOM_SID *sid) DEBUG(7,("dom_sid_to_string returning %s\n", sidstr)); return sidstr; } + +/************************************************************* + Routine to get the next 32 hex characters and turn them + into a 16 byte array. +**************************************************************/ +int 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); + hinybble = PTR_DIFF(p1, hexchars); + lonybble = PTR_DIFF(p2, hexchars); + + pwd[i / 2] = (hinybble << 4) | lonybble; + } + return (True); +} diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c index d9387dfcc4..6045534998 100644 --- a/source3/passdb/ldap.c +++ b/source3/passdb/ldap.c @@ -401,34 +401,6 @@ static void ldap_get_user(LDAP *ldap_struct,LDAPMessage *entry, } } -/************************************************************* - Routine to get the next 32 hex characters and turn them - into a 16 byte array. -**************************************************************/ - -static int 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); - hinybble = PTR_DIFF(p1, hexchars); - lonybble = PTR_DIFF(p2, hexchars); - - pwd[i / 2] = (hinybble << 4) | lonybble; - } - return (True); -} - /******************************************************************* retrieve the machine's info and contruct a smb_passwd structure. ******************************************************************/ diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index 31567eafd8..3344a22eb5 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -165,41 +165,12 @@ void endsmbpwent(void *vp) DEBUG(7, ("endsmbpwent: closed password file.\n")); } -/************************************************************* - Routine to get the next 32 hex characters and turn them - into a 16 byte array. -**************************************************************/ - -static int 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); - hinybble = PTR_DIFF(p1, hexchars); - lonybble = PTR_DIFF(p2, hexchars); - - pwd[i / 2] = (hinybble << 4) | lonybble; - } - return (True); -} - /************************************************************************* Routine to return the next entry in the smbpasswd list. do not call this function directly. use passdb.c instead. *************************************************************************/ - struct smb_passwd *getsmbpwent(void *vp) { /* Static buffers we will return. */ diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index cc883ff51b..2504727bd6 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -637,13 +637,13 @@ int main(int argc, char **argv) /* * Open the smbpaswd file. */ - vp = startsmbpwent(True); + vp = startsampwent(True); if (!vp && errno == ENOENT) { fp = fopen(lp_smb_passwd_file(), "w"); if (fp) { fprintf(fp, "# Samba SMB password file\n"); fclose(fp); - vp = startsmbpwent(True); + vp = startsampwent(True); } } if (!fp) { @@ -656,12 +656,12 @@ int main(int argc, char **argv) } /* Get the smb passwd entry for this user */ - smb_pwent = getsmbpwnam(user_name); + smb_pwent = getsampwnam(user_name); if (smb_pwent == NULL) { if(add_user == False) { fprintf(stderr, "%s: Failed to find entry for user %s.\n", prog_name, pwd->pw_name); - endsmbpwent(vp); + endsampwent(vp); exit(1); } @@ -684,14 +684,14 @@ int main(int argc, char **argv) new_smb_pwent.smb_nt_passwd = new_nt_p16; } - if(add_smbpwd_entry(&new_smb_pwent) == False) { + if(add_sampwd_entry(&new_smb_pwent) == False) { fprintf(stderr, "%s: Failed to add entry for user %s.\n", prog_name, pwd->pw_name); - endsmbpwent(vp); + endsampwent(vp); exit(1); } - endsmbpwent(vp); + endsampwent(vp); printf("%s: Added user %s.\n", prog_name, user_name); exit(0); } @@ -726,14 +726,14 @@ int main(int argc, char **argv) smb_pwent->smb_nt_passwd = new_nt_p16; } - if(mod_smbpwd_entry(smb_pwent,True) == False) { + if(mod_sampwd_entry(smb_pwent,True) == False) { fprintf(stderr, "%s: Failed to modify entry for user %s.\n", prog_name, pwd->pw_name); - endsmbpwent(vp); + endsampwent(vp); exit(1); } - endsmbpwent(vp); + endsampwent(vp); if(disable_user) printf("User %s disabled.\n", user_name); else if (set_no_password) |