/*
- * $Id: uams_passwd.c,v 1.8 2001-05-07 20:05:34 rufustfirefly Exp $
+ * $Id: uams_passwd.c,v 1.9 2001-05-22 19:13:36 rufustfirefly Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
#define PASSWDLEN 8
-#ifdef DIGITAL_UNIX_SECURITY
+#ifdef TRU64
#include <sys/types.h>
#include <sys/security.h>
#include <prot.h>
-#endif /* DIGITAL_UNIX_SECURITY */
+#include <sia.h>
+
+static int c2security = 0;
+#endif /* TRU64 */
/* cleartxt login */
static int passwd_login(void *obj, struct passwd **uam_pwd,
#endif /* SHADOWPW */
char *username, *p;
int len, ulen;
-#ifdef DIGITAL_UNIX_SECURITY
- char *bigcrypt();
- struct pr_passwd *pr;
-#endif /* DIGITAL_UNIX_SECURITY */
*rbuflen = 0;
*uam_pwd = pwd;
-#ifdef DIGITAL_UNIX_SECURITY
- pr = getprpwnam( username );
- if ( pr == NULL )
- return AFPERR_NOTAUTH;
- if ( strcmp ( bigcrypt ( ibuf, pr->ufld.fd_encrypt ),
- pr->ufld.fd_encrypt ) == 0 )
- return AFP_OK;
-#else /* DIGITAL_UNIX_SECURITY */
+#ifdef TRU64
+ if ( c2security == 1 ) {
+ struct pr_passwd *pr = getprpwnam( pwd->pw_name );
+ if ( pr == NULL )
+ return AFPERR_NOTAUTH;
+ if ( strcmp( dispcrypt( rbuf, pr->ufld.fd_encrypt,
+ pr->ufld.fd_oldcrypt ), pr->ufld.fd_encrypt ) == 0 ) {
+ return AFP_OK;
+ }
+ } else {
+ p = crypt( rbuf, pwd->pw_passwd );
+ memset(rbuf, 0, PASSWDLEN);
+ if ( strcmp( p, pwd->pw_passwd ) == 0 ) {
+ return AFP_OK;
+ }
+ }
+#else /* TRU64 */
p = crypt( ibuf, pwd->pw_passwd );
if ( strcmp( p, pwd->pw_passwd ) == 0 )
return AFP_OK;
-#endif /* DIGITAL_UNIX_SECURITY */
+#endif /* TRU64 */
return AFPERR_NOTAUTH;
}
static int uam_setup(const char *path)
{
+#ifdef TRU64
+ FILE *f;
+ char buf[256];
+ char siad[] = "siad_ses_init=";
+
+ if ( access( SIAIGOODFILE, F_OK ) == -1 ) {
+ syslog( LOG_ERR, "clrtxt uam_setup: %s does not exist",
+ SIAIGOODFILE);
+ return -1;
+ }
+
+ if ( ( f = fopen(MATRIX_CONF, "r" ) ) == NULL ) {
+ syslog( LOG_ERR, "clrtxt uam_setup: %s is unreadable",
+ MATRIX_CONF );
+ return -1;
+ }
+
+ while ( fgets( buf, sizeof(buf), f ) != NULL ) {
+ if ( strncmp( buf, siad, sizeof(siad) - 1 ) == 0 ) {
+ if ( strstr( buf, "OSFC2" ) != NULL )
+ c2security = 1;
+ break;
+ }
+ }
+
+ fclose(f);
+
+ syslog( LOG_INFO, "clrtxt uam_setup: security level %s",
+ c2security == 0 ? "BSD" : "OSFC2" );
+#endif /* TRU64 */
+
if (uam_register(UAM_SERVER_LOGIN, path, "Cleartxt Passwrd",
passwd_login, NULL, NULL) < 0)
return -1;