]> arthur.barton.de Git - netatalk.git/commitdiff
Tru64 patch (Burkhard Schmidt)
authorrufustfirefly <rufustfirefly>
Mon, 25 Jun 2001 15:18:00 +0000 (15:18 +0000)
committerrufustfirefly <rufustfirefly>
Mon, 25 Jun 2001 15:18:00 +0000 (15:18 +0000)
ChangeLog
etc/afpd/auth.c
etc/afpd/main.c
etc/afpd/uam.c
etc/uams/uams_dhx_passwd.c
etc/uams/uams_passwd.c
include/atalk/uam.h

index c5d265d360a3d8abf2321caee2274fddd5331bf4..c537672e6ba20a16c4e9f741e75842872ef4bc8c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
-($Id: ChangeLog,v 1.51 2001-06-20 18:33:03 rufustfirefly Exp $)
+($Id: ChangeLog,v 1.52 2001-06-25 15:18:00 rufustfirefly Exp $)
+
+2001-06-25  jeff b  <jeff@univrel.pr.uconn.edu>
+       * etc/afpd/auth.c, etc/afpd/main.c, etc/afpd/uam.c,
+       etc/uams/uams_dhx_passwd.c, etc/uams/uams_passwd.c,
+       include/atalk/uam.h: TRU64 authentication patch to allow
+       any security scheme to be used on the TRU64 side (Burkhard
+       Schmidt)
 
 2001-06-20  jeff b  <jeff@univrel.pr.uconn.edu>
        * configure.in: check for linux/quota.h before enabling
index 083120f49583acb206fc928ce3326671fbf05703..e3d76d18bb29f61fa3e532717db74e42ed9c027a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.15 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: auth.c,v 1.16 2001-06-25 15:18:01 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
 #include <grp.h>
 #include <syslog.h>
 
+#ifdef TRU64
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <sia.h>
+#include <siad.h>
+
+extern void afp_get_cmdline( int *ac, char ***av );
+#endif /* TRU64 */
+
 #include "globals.h"
 #include "auth.h"
 #include "uam_auth.h"
@@ -220,10 +229,47 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void))
     if (admin) syslog( LOG_INFO, "admin login -- %s", pwd->pw_name );
     if (!admin)
 #endif /* DEBUG */
+#ifdef TRU64
+    {
+        struct DSI *dsi = obj->handle;
+        struct hostent *hp;
+        char *clientname;
+        int argc;
+        char **argv;
+        char hostname[256];
+
+        afp_get_cmdline( &argc, &argv );
+
+        hp = gethostbyaddr( (char *) &dsi->client.sin_addr,
+                            sizeof( struct in_addr ),
+                            dsi->client.sin_family );
+
+        if( hp )
+            clientname = hp->h_name;
+        else
+            clientname = inet_ntoa( dsi->client.sin_addr );
+
+        sprintf( hostname, "%s@%s", pwd->pw_name, clientname );
+
+        if( sia_become_user( NULL, argc, argv, hostname, pwd->pw_name,
+                             NULL, FALSE, NULL, NULL,
+                             SIA_BEU_REALLOGIN ) != SIASUCCESS )
+            return AFPERR_BADUAM;
+
+        syslog( LOG_INFO, "session from %s (%s)", hostname,
+                inet_ntoa( dsi->client.sin_addr ) );
+
+        if (setegid( pwd->pw_gid ) < 0 || seteuid( pwd->pw_uid ) < 0) {
+            syslog( LOG_ERR, "login: %m" );
+            return AFPERR_BADUAM;
+        }
+    }
+#else /* TRU64 */
        if (setegid( pwd->pw_gid ) < 0 || seteuid( pwd->pw_uid ) < 0) {
            syslog( LOG_ERR, "login: %m" );
            return AFPERR_BADUAM;
        }
+#endif /* TRU64 */
 
     /* There's probably a better way to do this, but for now, we just 
        play root */
index ca408aca1d34ef6b9fd6d1a5b3cd7bfdfb424c75..434ca5ad173fc58f78e4dc50117975cba36d16d2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.c,v 1.9 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: main.c,v 1.10 2001-06-25 15:18:01 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -52,6 +52,9 @@
 #include <sys/security.h>
 #include <prot.h>
 #include <sia.h>
+
+static int argc = 0;
+static char **argv = NULL;
 #endif /* TRU64 */
 
 #ifdef DID_MTAB
@@ -65,6 +68,14 @@ static AFPConfig *configs;
 static server_child *server_children;
 static fd_set save_rfds;
 
+#ifdef TRU64
+void afp_get_cmdline( int *ac, char ***av)
+{
+  *ac = argc;
+  *av = argv;
+}
+#endif /* TRU64 */
+
 static void afp_exit(const int i)
 {
   server_unlock(default_options.pidfile);
@@ -138,6 +149,8 @@ int main( ac, av )
     sigset_t            sigs;
 
 #ifdef TRU64
+    argc = ac;
+    argv = av;
     set_auth_parameters( ac, av );
 #endif /* TRU64 */
 
index f171d2a1ef2c3c877a196fcb44bfcdc7ab7fc322..0b5dfaf9214286c645bf56204c1ab9ae4a44d01a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uam.c,v 1.9 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: uam.c,v 1.10 2001-06-25 15:18:01 rufustfirefly Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
 #include "auth.h"
 #include "uam_auth.h"
 
+#ifdef TRU64
+#include <netdb.h>
+#include <arpa/inet.h>
+#endif /* TRU64 */
+
 /* --- server uam functions -- */
 
 /* uam_load. uams must have a uam_setup function. */
@@ -330,7 +335,22 @@ int uam_afpserver_option(void *private, const int what, void *option,
   case UAM_OPTION_PROTOCOL:
     *buf = (void *) obj->proto;
     break;
-
+#ifdef TRU64
+  case UAM_OPTION_CLIENTNAME:
+    {
+      struct DSI *dsi = obj->handle;
+      struct hostent *hp;
+
+      hp = gethostbyaddr( (char *) &dsi->client.sin_addr,
+                          sizeof( struct in_addr ),
+                          dsi->client.sin_family );
+      if( hp )
+          *buf = (void *) hp->h_name;
+      else
+          *buf = (void *) inet_ntoa( dsi->client.sin_addr );
+    }
+    break;
+#endif /* TRU64 */
   case UAM_OPTION_COOKIE: 
     /* it's up to the uam to actually store something useful here.
      * this just passes back a handle to the cookie. the uam side
@@ -388,6 +408,13 @@ uam_afp_read_err:
   return len;
 }
 
+#ifdef TRU64
+void uam_afp_getcmdline( int *ac, char ***av )
+{
+    afp_get_cmdline( ac, av );
+}
+#endif /* TRU64 */
+
 /* --- papd-specific functions (just placeholders) --- */
 void append(void *pf, char *data, int len)
 {
index cb2471f701804830166d836149636ebb56da4b64..6e6c1a4bff0edff3ec1a74f20d1d9a942cae9632 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_dhx_passwd.c,v 1.8 2001-05-22 19:13:36 rufustfirefly Exp $
+ * $Id: uams_dhx_passwd.c,v 1.9 2001-06-25 15:18:01 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -57,12 +57,10 @@ static struct passwd *dhxpwd;
 static u_int8_t randbuf[16];
 
 #ifdef TRU64
-#include <sys/types.h>
-#include <sys/security.h>
-#include <prot.h>
 #include <sia.h>
+#include <siad.h>
 
-static int c2security = 0;
+static char *clientname;
 #endif /* TRU64 */
 
 /* dhx passwd */
@@ -93,6 +91,12 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
     if (uam_afpserver_option(obj, UAM_OPTION_USERNAME, (void *) &name, &i) < 0)
       return AFPERR_PARAM;
 
+#ifdef TRU64
+    if( uam_afpserver_option( obj, UAM_OPTION_CLIENTNAME,
+                              (void *) &clientname, NULL ) < 0 )
+        return AFPERR_PARAM;
+#endif /* TRU64 */
+
     len = (unsigned char) *ibuf++;
     if ( len > i ) {
        return( AFPERR_PARAM );
@@ -261,22 +265,21 @@ static int passwd_logincont(void *obj, struct passwd **uam_pwd,
 
     rbuf[PASSWDLEN] = '\0';
 #ifdef TRU64
-    if ( c2security == 1 ) {
-        struct pr_passwd *pr = getprpwnam( dhxpwd->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 ) {
-            *uam_pwd = dhxpwd;
-            return AFP_OK;
-       }
-    } else {
-        p = crypt( rbuf, dhxpwd->pw_passwd );
-        memset(rbuf, 0, PASSWDLEN);
-        if ( strcmp( p, dhxpwd->pw_passwd ) == 0 ) {
-            *uam_pwd = dhxpwd;
-            return AFP_OK;
-        }
+    {
+        int ac;
+        char **av;
+        char hostname[256];
+
+        uam_afp_getcmdline( &ac, &av );
+        sprintf( hostname, "%s@%s", dhxpwd->pw_name, clientname );
+
+        if( sia_validate_user( NULL, ac, av, hostname, dhxpwd->pw_name,
+                               NULL, FALSE, NULL, rbuf ) != SIASUCCESS )
+            return AFPERR_NOTAUTH;
+
+        memset( rbuf, 0, PASSWDLEN );
+        *uam_pwd = dhxpwd;
+        return AFP_OK;
     }
 #else /* TRU64 */
     p = crypt( rbuf, dhxpwd->pw_passwd );
@@ -293,37 +296,6 @@ static int passwd_logincont(void *obj, struct passwd **uam_pwd,
 
 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, "dhx uam_setup: %s does not exist",
-            SIAIGOODFILE);
-        return -1;
-    }
-
-    if ( ( f = fopen(MATRIX_CONF, "r" ) ) == NULL ) {
-        syslog( LOG_ERR, "dhx 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, "dhx uam_setup: security level %s",
-        c2security == 0 ? "BSD" : "OSFC2" );
-#endif /* TRU64 */
-
   if (uam_register(UAM_SERVER_LOGIN, path, "DHCAST128",
                   passwd_login, passwd_logincont, NULL) < 0)
     return -1;
index 94c50cb3d4c409680c7643b9415bae0e672301ca..2896b46f505181b543a2f1c85a6face0d0a28fa4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_passwd.c,v 1.10 2001-05-25 13:23:56 rufustfirefly Exp $
+ * $Id: uams_passwd.c,v 1.11 2001-06-25 15:18:01 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 TRU64
-#include <sys/types.h>
-#include <sys/security.h>
-#include <prot.h>
 #include <sia.h>
+#include <siad.h>
 
-static int c2security = 0;
+static char *clientname;
 #endif /* TRU64 */
 
 /* cleartxt login */
@@ -60,6 +58,12 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
                             (void *) &username, &ulen) < 0)
       return AFPERR_MISC;
 
+#ifdef TRU64
+    if( uam_afpserver_option( obj, UAM_OPTION_CLIENTNAME,
+                              (void *) &clientname, NULL ) < 0 )
+        return AFPERR_MISC;
+#endif /* TRU64 */
+
     len = (unsigned char) *ibuf++;
     if ( len > ulen ) {
        return( AFPERR_PARAM );
@@ -94,18 +98,19 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
     *uam_pwd = pwd;
 
 #ifdef TRU64
-    if ( c2security == 1 ) {
-        struct pr_passwd *pr = getprpwnam( pwd->pw_name );
-        if ( pr == NULL )
+    {
+        int ac;
+        char **av;
+        char hostname[256];
+
+        uam_afp_getcmdline( &ac, &av );
+        sprintf( hostname, "%s@%s", username, clientname );
+
+        if( sia_validate_user( NULL, ac, av, hostname, username,
+                               NULL, FALSE, NULL, ibuf ) != SIASUCCESS )
             return AFPERR_NOTAUTH;
-        if ( strcmp( dispcrypt( ibuf, pr->ufld.fd_encrypt,
-            pr->ufld.fd_oldcrypt ), pr->ufld.fd_encrypt ) == 0 ) {
-            return AFP_OK;
-        }
-    } else {
-        p = crypt( ibuf, pwd->pw_passwd );
-        if ( strcmp( p, pwd->pw_passwd ) == 0 )
-            return AFP_OK;
+
+        return AFP_OK;
     }
 #else /* TRU64 */
     p = crypt( ibuf, pwd->pw_passwd );
@@ -260,37 +265,6 @@ 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;
index 49e6a6f1298bf9df3dcbc1ab08b774686c8b2f41..0345a5485ce25fce600ca3ee5a85b40c9dcb5f64 100644 (file)
@@ -33,6 +33,9 @@
 #define UAM_OPTION_HOSTNAME     (1 << 5) /* get host name */
 #define UAM_OPTION_COOKIE       (1 << 6) /* cookie handle */
 #define UAM_OPTION_PROTOCOL    (1 << 7) /* DSI or ASP */
+#ifdef TRU64
+#define UAM_OPTION_CLIENTNAME   (1 << 8) /* get client IP address */
+#endif /* TRU64 */
 
 /* some password options. you pass these in the length parameter and
  * get back the corresponding option. not all of these are implemented. */
@@ -61,6 +64,9 @@ extern int uam_checkuser __P((const struct passwd *));
 extern int uam_afp_read __P((void *, char *, int *,
                             int (*)(void *, void *, const int)));
 extern int uam_afpserver_option __P((void *, const int, void *, int *));
+#ifdef TRU64
+extern void uam_afp_getcmdline __P((int *, char ***));
+#endif /* TRU64 */
 
 /* switch.c */
 #define UAM_AFPSERVER_PREAUTH  (0)