*BSD News Article 46035


Return to BSD News archive

Xref: sserve comp.infosystems.www.servers.unix:1484 comp.unix.bsd.freebsd.misc:2567
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.sprintlink.net!cam.news.pipex.net!pipex!edi.news.pipex.net!pipex!sunic!sunic.sunet.se!news.funet.fi!news.eunet.fi!news.spb.su!hq.pu.ru!dux.ru!newsserv
From: ptitz@myframe.dux.ru
Newsgroups: comp.infosystems.www.servers.unix,comp.unix.bsd.freebsd.misc
Subject: Re: Desperate for CERN Passwd prog
Date: 25 Jun 1995 22:39:35 GMT
Organization: DUX
Lines: 116
Message-ID: <3skoj7$eod@hq.pu.ru>
NNTP-Posting-Host: ns.dux.ru
Keywords: cern htadm freebsd


In comp.infosystems.www.servers.unix,comp.unix.bsd.freebsd.misc article
    <3scfq6$n3k@sun.sirius.com> Timothy Kingwell writes:

>Hi.  I have CERN 3.0 and FreeBSD 2.0.  Is there anyone out there with the
>same setup who has been able to compile a working copy of htadm?  It seems
>to compile just fine (I compiled all the necessary files separately), but
>when I run it, it can't verify the passwd files it creates.  If anyone has
>been able to get this to work properly, I'd be really, really grateful for
>some email with the necessary mods to the source.  Or the FreeBSD htadm
>binary for that matter :)

*** Daemon/I/HTPasswd.c	Sun Sep 25 16:52:56 1994
--- Daemon/Implementation/HTPasswd.c	Sat Jun 17 23:55:41 1995
***************
*** 27,35 ****
  extern char *crypt();


  PRIVATE char salt_chars [65] =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
!

  /* PRIVATE						next_rec()
  **		GO TO THE BEGINNING OF THE NEXT RECORD
--- 27,51 ----
  extern char *crypt();


+ #ifndef __FreeBSD__
  PRIVATE char salt_chars [65] =
      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
! #else
! PRIVATE unsigned char itoa64[] =		/* 0 ... 63 => ascii - 64 */
! 	"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
!
! void
! to64(s, v, n)
! 	char *s;
! 	long v;
! 	int n;
! {
! 	while (--n >= 0) {
! 		*s++ = itoa64[v&0x3f];
! 		v >>= 6;
! 	}
! }
! #endif

  /* PRIVATE						next_rec()
  **		GO TO THE BEGINNING OF THE NEXT RECORD
***************
*** 80,86 ****
--- 96,106 ----
  */
  PUBLIC char *HTAA_encryptPasswd ARGS1(CONST char *, password)
  {
+ #ifndef __FreeBSD__
      char salt[3];
+ #else
+     char salt[9];
+ #endif
      char chunk[9];
      char *result;
      char *tmp;
***************
*** 89,94 ****
--- 109,115 ----
      extern time_t theTime;
      int random = (int)theTime;	/* This is random enough */

+ #ifndef __FreeBSD__
      if (!(result = (char*)malloc(13*(((int)strlen(password)+7)/8) + 1)))
  	outofmem(__FILE__, "HTAA_encryptPasswd");

***************
*** 107,114 ****
  	cur += 8;
  	len -= 8;
      } /* while */
-
      return result;
  }


--- 128,140 ----
  	cur += 8;
  	len -= 8;
      } /* while */
      return result;
+ #else
+     salt[0] = '_';
+     to64(&salt[1], (long) (29 * 25), 4);
+     to64(&salt[5], random, 4);
+     return strdup(crypt(password, salt));
+ #endif
  }


***************
*** 273,279 ****
--- 299,309 ----
  		/* User's record found */
  		if (*pw) {	    /* So password is required for this user */
  		    if (!password ||
+ #ifdef __FreeBSD__
+             strcmp(crypt(password, pw), pw))
+ #else
  			!HTAA_passwdMatch(password,pw))	     /* Check the pw */
+ #endif
  			status = EOF;	/* If wrong, indicate it with EOF */
  		}
  		break;  /* exit loop */
--
D.