]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_passwd.c
more Tru64 fixes from Burkhard Schmidt <bs@cpfs.mpg.de>
[netatalk.git] / etc / uams / uams_passwd.c
index 55247a53240b953a4f19db6fb678bc2262d81d1c..bb30b3b09edc81ba5beb9868dac5b58575d979d1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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,
@@ -50,10 +53,6 @@ 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;
 
@@ -94,18 +93,27 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
 
     *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;
 }
@@ -254,6 +262,37 @@ static int passwd_printer(start, stop, username, out)
 
 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;