moving gethexpwd into util.c, because it's used in both smbpass.c and ldap.c
authorLuke Leighton <lkcl@samba.org>
Thu, 7 May 1998 19:59:32 +0000 (19:59 +0000)
committerLuke Leighton <lkcl@samba.org>
Thu, 7 May 1998 19:59:32 +0000 (19:59 +0000)
source/include/proto.h
source/lib/util.c
source/passdb/ldap.c
source/passdb/smbpass.c
source/utils/smbpasswd.c

index 3cc48bb78f388123bd3edb70f46bdd3ffb32b7b0..fda55a652cf1df2760eec9c44cb67b2278b0d594 100644 (file)
@@ -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  */
 
index 2416110857955291bdbd118920688b1b05f62603..2f637e14955b835bf58ce17830912923d26f0802 100644 (file)
@@ -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);
+}
index d9387dfcc488e0e7e2f8c520b3636d6aba66f3c1..60455349983ca17b5abd153aec514e95075d8c24 100644 (file)
@@ -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.
 ******************************************************************/
index 31567eafd808e2b4f8eb1bb14b7edd36e6406ea1..3344a22eb503d41546dd5691ada4cfaae607cb37 100644 (file)
@@ -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. */
index cc883ff51b71daff1e60866a9f4687e8bb2c915b..2504727bd6c0517cdfa2d0b7b2e8f3117b0b97eb 100644 (file)
@@ -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)