Commit 4bf2407e authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Kryptera l|senord.

parent 8a35a7b7
Thu Sep 12 01:00:13 1991 Per Cederqvist (ceder at lysator)
* ramkomd.c (main): Anropa srand() om ENCRYPT_PASSWORDS {r satt,
s} att vi f}r ett slumpm{ssigt fr|.
* person.c (do_set_passwd, chk_passwd) Kryptera l|senord om
ENCRYPT_PASSWORDS {r satt. (Inkompatibelt med gamla
databasformatet).
Tue Sep 10 21:58:18 1991 Per Cederqvist (ceder at robert)
* conference.c (delete_conf): Om det {r en brevl}da som tas bort
......
......@@ -4,14 +4,16 @@
* All atomic calls that deals with persons.
*/
static char *rcsid = "$Id: person.c,v 0.7 1991/09/05 08:32:46 ceder Exp $";
static char *rcsid = "$Id: person.c,v 0.8 1991/09/11 23:03:48 ceder Exp $";
#include <m-config.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include "lyskomd.h"
#include <kom-types.h>
#include <services.h>
#include <misc.h>
#include "manipulate.h"
#include <kom-errno.h>
#include <server/smalloc.h>
......@@ -37,12 +39,32 @@ static Success
do_set_passwd( Password pwd,
const String new_pwd)
{
#ifdef ENCRYPT_PASSWORDS
char salt[3];
static char crypt_seed[] = ("abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./");
if ( !legal_passwd(new_pwd) )
return FAILURE;
*pwd++ = new_pwd.len; /*** Maybe too easy crypt... */
salt[0] = crypt_seed [rand() % sizeof (crypt_seed)];
salt[1] = crypt_seed [rand() % sizeof (crypt_seed)];
salt[2] = '\0';
strcpy((char *)pwd, (const char *)crypt((char *)new_pwd.string, salt));
#else
/* Compatibility mode... */
if ( !legal_passwd(new_pwd) )
return FAILURE;
*pwd++ = new_pwd.len; /* Indeed too easy crypt... */
strncpy(pwd, (const char *)new_pwd.string,
min( PASSWD_LEN-1, new_pwd.len ));
#endif
return OK;
}
......@@ -281,19 +303,32 @@ do_delete_pers (Pers_no pers_no)
* Check a password
*/
Success
chk_passwd( Password pwd,
const String s )
chk_passwd (Password pwd,
const String try)
{
#ifdef ENCRYPT_PASSWORDS
if (strcmp ((const char *)pwd,
(const char *)crypt((const char *)&try.string[2],
(const char *)try.string)))
return FAILURE;
else
return OK;
#else
int i;
if ( s.len != *pwd )
if ( try.len != *pwd )
return FAILURE;
for ( i = 0; i < s.len; i++ )
if ( pwd[ i + 1 ] != s.string[ i ] )
for ( i = 0; i < try.len; i++ )
if ( pwd[ i + 1 ] != try.string[ i ] )
return FAILURE;
return OK;
#endif
}
......
......@@ -7,7 +7,7 @@
* It has grown! /ceder
*/
static char *rcsid = "$Id: ramkomd.c,v 0.18 1991/09/04 15:39:45 ceder Exp $";
static char *rcsid = "$Id: ramkomd.c,v 0.19 1991/09/11 23:03:46 ceder Exp $";
#include <m-config.h>
......@@ -228,6 +228,10 @@ main (int argc,
/* If we don't have getdtablesize MAX_NO_OF_CONNECTIONS is
set at compile time. */
#ifdef ENCRYPT_PASSWORDS
srand(time(NULL) + getpid());
#endif
s_set_storage_management(string_malloc, string_realloc, string_free);
......
/* $Id: version.incl,v 0.15 1991/09/10 21:44:41 ceder Exp $ */
3109
/* $Id: version.incl,v 0.16 1991/09/11 23:03:44 ceder Exp $ */
3200
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment