]> arthur.barton.de Git - netatalk.git/commitdiff
allow login using extended characters in usernamei, add obj parameter to uam_getname...
authorbfernhomberg <bfernhomberg>
Thu, 11 Sep 2003 23:49:30 +0000 (23:49 +0000)
committerbfernhomberg <bfernhomberg>
Thu, 11 Sep 2003 23:49:30 +0000 (23:49 +0000)
12 files changed:
etc/afpd/auth.c
etc/afpd/uam.c
etc/papd/uam.c
etc/uams/uams_dhx_pam.c
etc/uams/uams_dhx_passwd.c
etc/uams/uams_gss.c
etc/uams/uams_krb4/uams_krb4.c
etc/uams/uams_pam.c
etc/uams/uams_passwd.c
etc/uams/uams_pgp.c
etc/uams/uams_randnum.c
include/atalk/uam.h

index afa85645bd7d64364ce0e88291a09cadcd47836a..230d46efb2860202269ffec2d0c58c1d70e917e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.44.2.3 2003-07-21 05:50:53 didg Exp $
+ * $Id: auth.c,v 1.44.2.3.2.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -744,7 +744,7 @@ int         ibuflen, *rbuflen;
 
     LOG(log_info, logtype_afpd, "changing password for <%s>", username);
 
-    if (( pwd = uam_getname( username, sizeof(username))) == NULL )
+    if (( pwd = uam_getname( obj, username, sizeof(username))) == NULL )
         return AFPERR_PARAM;
 
     /* send it off to the uam. we really don't use ibuflen right now. */
index 08ba1cdac08a767d8c4a9a6218a7739dcf2171c0..d73c36f3ab0d9b1b382a092e19d6f9360391d977 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uam.c,v 1.24 2003-04-16 22:45:11 samnoble Exp $
+ * $Id: uam.c,v 1.24.6.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -56,6 +56,12 @@ char *strchr (), *strrchr ();
 #include "auth.h"
 #include "uam_auth.h"
 
+#ifdef AFP3x
+#define utf8_encoding() (afp_version >= 30)
+#else
+#define utf8_encoding() (0)
+#endif
+
 #ifdef TRU64
 #include <netdb.h>
 #include <sia.h>
@@ -287,29 +293,44 @@ void uam_unregister(const int type, const char *name)
 
 /* --- helper functions for plugin uams --- */
 
-struct passwd *uam_getname(char *name, const int len)
+struct passwd *uam_getname(void *private, char *name, const int len)
 {
+    AFPObj *obj = private;
     struct passwd *pwent;
-    char *user;
-    int i;
+    static char username[256];
+    static char user[256];
+    static char pwname[256];
+    char *p;
+    size_t ulen;
+    u_int16_t flags = CONV_PRECOMPOSE;
 
     if ((pwent = getpwnam(name)))
         return pwent;
 
 #ifndef NO_REAL_USER_NAME
-    for (i = 0; i < len; i++)
-        name[i] = tolower(name[i]);
+
+    if ( (size_t) -1 == (ulen = convert_charset((utf8_encoding())?CH_UTF8_MAC:obj->options.maccharset, 0, 
+                               CH_UCS2, name, len, username, 256, &flags)))
+       return NULL;
 
     setpwent();
     while ((pwent = getpwent())) {
-        if ((user = strchr(pwent->pw_gecos, ',')))
-            *user = '\0';
-        user = pwent->pw_gecos;
+        if ((p = strchr(pwent->pw_gecos, ',')))
+            *p = '\0';
+
+       if ((size_t)-1 == ( ulen = convert_string(obj->options.unixcharset, CH_UCS2, 
+                               pwent->pw_gecos, strlen(pwent->pw_gecos), user, 256)) )
+               continue;
+       if ((size_t)-1 == ( ulen = convert_string(obj->options.unixcharset, CH_UCS2, 
+                               pwent->pw_name, strlen(pwent->pw_name), pwname, 256)) )
+               continue;
+
 
         /* check against both the gecos and the name fields. the user
          * might have just used a different capitalization. */
-        if ((strncasecmp(user, name, len) == 0) ||
-                (strncasecmp(pwent->pw_name, name, len) == 0)) {
+
+       if ( (strncasecmp_w((ucs2_t*)user, (ucs2_t*)username, len) == 0) || 
+               ( strncasecmp_w ( (ucs2_t*) pwname, (ucs2_t*) username, len) == 0)) {
             strncpy(name, pwent->pw_name, len);
             name[len - 1] = '\0';
             break;
@@ -471,6 +492,14 @@ AFPObj *obj = private;
         if (len)
             *len = strlen(obj->options.k5service);
        break;
+    case UAM_OPTION_MACCHARSET:
+        *((int *) option) = obj->options.maccharset;
+        *len = sizeof(obj->options.maccharset);
+        break;
+    case UAM_OPTION_UNIXCHARSET:
+        *((int *) option) = obj->options.unixcharset;
+        *len = sizeof(obj->options.unixcharset);
+        break;
     default:
         return -1;
         break;
index 0e5b9a4e706823a899c8be479a8a4a9fd494e4c0..394d192754dd2154d2aabf000bc1dd2c5f4ed54c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uam.c,v 1.9 2003-02-17 01:35:57 srittau Exp $
+ * $Id: uam.c,v 1.9.6.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -191,7 +191,7 @@ int uam_afpserver_option(void *private, const int what, void *option,
 
 /* --- helper functions for plugin uams --- */
 
-struct passwd *uam_getname(char *name, const int len)
+struct passwd *uam_getname(void *dummy, char *name, const int len)
 {
   struct passwd *pwent;
   char *user;
index fe88c06bebaac1d2cd947f74bb24c885f5730e79..c421356b0bb41e67ac490c5133df66342f1b2bc0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_dhx_pam.c,v 1.24.6.1 2003-09-09 16:42:20 didg Exp $
+ * $Id: uams_dhx_pam.c,v 1.24.6.2 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -37,7 +37,6 @@
 
 #include <atalk/afp.h>
 #include <atalk/uam.h>
-#include <atalk/unicode.h>
 
 #define KEYSIZE 16
 #define PASSWDLEN 64
@@ -313,7 +312,7 @@ static int login(void *obj, char *username, int ulen,  struct passwd **uam_pwd,
                     char *ibuf, int ibuflen,
                     char *rbuf, int *rbuflen)
 {
-    if (( dhxpwd = uam_getname(username, ulen)) == NULL ) {
+    if (( dhxpwd = uam_getname(obj, username, ulen)) == NULL ) {
         LOG(log_info, logtype_uams, "uams_dhx_pam.c: unknown username");
        return AFPERR_PARAM;
     }
@@ -352,7 +351,6 @@ static int pam_login(void *obj, struct passwd **uam_pwd,
     memcpy(username, ibuf, len );
     ibuf += len;
     username[ len ] = '\0';
-    len = convert_charset(CH_MAC, CH_UNIX, username, len, username, ulen, 0);
 
     if ((unsigned long) ibuf & 1) /* pad to even boundary */
       ++ibuf;
@@ -391,7 +389,6 @@ static int pam_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
     }
     memcpy(username, uname +2, len );
     username[ len ] = '\0';
-    len = convert_charset(CH_UTF8_MAC, CH_UNIX, username, len, username, ulen, 0);
 
     return (login(obj, username, ulen, uam_pwd, ibuf, ibuflen, rbuf, rbuflen));
 }
index eb25e642d9dbc9e294faff3d60d0dc0a7bb6dc8e..4ad9d77973d18efa1473b316d399b90fb84da3ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_dhx_passwd.c,v 1.18 2003-02-11 16:41:56 didg Exp $
+ * $Id: uams_dhx_passwd.c,v 1.18.6.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -93,7 +93,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
         return AFPERR_PARAM;
 #endif /* TRU64 */
 
-    if (( dhxpwd = uam_getname(username, ulen)) == NULL ) {
+    if (( dhxpwd = uam_getname(obj, username, ulen)) == NULL ) {
        return AFPERR_PARAM;
     }
     
@@ -235,7 +235,7 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
  * uname format :
     byte      3
     2 bytes   len (network order)
-    len bytes unicode name
+    len bytes utf8 name
 */
 static int passwd_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
                        char *ibuf, int ibuflen,
index f54bbc934099f31d04ce50f302ec903b523cbfa1..1d29d9faa27c6f31f20868147c4dc8fa4bb5b3c9 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * $Id: uams_gss.c,v 1.2.2.1 2003-09-09 16:42:20 didg Exp $\r
+ * $Id: uams_gss.c,v 1.2.2.2 2003-09-11 23:49:30 bfernhomberg Exp $\r
  *\r
  * Copyright (c) 1990,1993 Regents of The University of Michigan.\r
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) \r
@@ -340,7 +340,7 @@ static int gss_logincont(void *obj, struct passwd **uam_pwd,
        // Chop off the realm name\r
        if (at)\r
            *at = '\0';\r
-       if((pwd = uam_getname( username, userlen )) == NULL) {\r
+       if((pwd = uam_getname( obj, username, userlen )) == NULL) {\r
            LOG(log_info, logtype_uams, "uam_getname() failed for %s", username);\r
            return AFPERR_PARAM;\r
        }\r
index 59d58efc37feaf898848d6f1db4757efcc070b4d..447673822ee7e6e832321661578ab96d52fe4bac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_krb4.c,v 1.6 2002-01-04 04:45:48 sibaz Exp $
+ * $Id: uams_krb4.c,v 1.6.10.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -190,7 +190,7 @@ static int krb4_login(void *obj, struct passwd **uam_pwd,
            *p = KRB4RPL_DONE;  /* XXX */
            *rbuflen = 1;
 
-           if (( pwd = uam_getname( ad.pname, strlen(ad.pname) )) == NULL ) {
+           if (( pwd = uam_getname( obj, ad.pname, strlen(ad.pname) )) == NULL ) {
                return AFPERR_PARAM;
            }
 /*
@@ -337,7 +337,7 @@ static int krb4_logincont(void *obj, struct passwd **uam_pwd,
            *p = KRB4RPL_DONE;  /* XXX */
            *rbuflen = 1;
 
-           if (( pwd = uam_getname( username, strlen(username) ) ) == NULL ) {
+           if (( pwd = uam_getname( obj, username, strlen(username) ) ) == NULL ) {
                return( AFPERR_NOTAUTH );
            }
 /*
@@ -385,7 +385,7 @@ static int krb4_logincont(void *obj, struct passwd **uam_pwd,
                    *p = KRB4RPL_DONE;  /* XXX */
                    *rbuflen = 1;
 
-                   if (( pwd = uam_getname( ad.pname, strlen(ad.pname) )) 
+                   if (( pwd = uam_getname( obj, ad.pname, strlen(ad.pname) )) 
                        == NULL ) {
                        return( AFPERR_PARAM );
                    }
@@ -454,7 +454,7 @@ static int krb4_logincont(void *obj, struct passwd **uam_pwd,
                    *p = KRB4RPL_DONE;  /* XXX */
                    *rbuflen = 1;
 
-                   if (( pwd = uam_getname( ad.pname, strlen(ad.pname) )) 
+                   if (( pwd = uam_getname( obj, ad.pname, strlen(ad.pname) )) 
                        == NULL ) {
                        return( AFPERR_PARAM );
                    }
@@ -746,7 +746,7 @@ static int afskrb_logincont(void *obj, struct passwd *uam_pwd,
        return ( AFPERR_BADUAM );
     }
 
-    if (( pwd = uam_getname( username )) == NULL ) {
+    if (( pwd = uam_getname( obj, username, strlen(username) )) == NULL ) {
        return ( AFPERR_PARAM );
     }
 
index 7f374253cef6ffa8eab2da5cdb3840a17a15d2bf..bd2c6ac11d73670a7379197268a4cc547455a1e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_pam.c,v 1.15.2.1.2.1 2003-09-09 16:42:20 didg Exp $
+ * $Id: uams_pam.c,v 1.15.2.1.2.2 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -35,7 +35,6 @@ char *strchr (), *strrchr ();
 #include <atalk/logger.h>
 
 #include <security/pam_appl.h>
-#include <atalk/unicode.h>
 
 #include <atalk/afp.h>
 #include <atalk/uam.h>
@@ -149,7 +148,7 @@ static int login(void *obj, char *username, int ulen,  struct passwd **uam_pwd,
     
     ibuf[ PASSWDLEN ] = '\0';
 
-    if (( pwd = uam_getname(username, ulen)) == NULL ) {
+    if (( pwd = uam_getname(obj, username, ulen)) == NULL ) {
        return AFPERR_PARAM;
     }
 
@@ -230,9 +229,6 @@ static int pam_login(void *obj, struct passwd **uam_pwd,
 
     username[ len ] = '\0';
 
-    len = convert_charset(CH_MAC, CH_UNIX, username, len, username, ulen, 0);
-
-
     if ((unsigned long) ibuf & 1)  /* pad character */
       ++ibuf;
     return (login(obj, username, ulen, uam_pwd, ibuf, ibuflen, rbuf, rbuflen));
@@ -264,8 +260,6 @@ static int pam_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
     memcpy(username, uname +2, len );
     username[ len ] = '\0';
     
-    len = convert_charset(CH_UTF8_MAC, CH_UNIX, username, len, username, ulen, 0);
-
     return (login(obj, username, ulen, uam_pwd, ibuf, ibuflen, rbuf, rbuflen));
 }
 
@@ -390,7 +384,7 @@ int pam_printer(start, stop, username, out)
     /* Done copying username and password, clean up */
     free(data);
 
-    if (( pwd = uam_getname(username, strlen(username))) == NULL ) {
+    if (( pwd = uam_getname(NULL, username, strlen(username))) == NULL ) {
         LOG(log_info, logtype_uams, "Bad Login ClearTxtUAM: ( %s ) not found ",
             username);
         return(-1);
index fc0052f473062f37d23b439b813d3fefa2357463..2ebb30193b3abfd15e5201e50cdb0471d6eabede 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_passwd.c,v 1.19.2.1 2003-09-03 20:40:50 didg Exp $
+ * $Id: uams_passwd.c,v 1.19.2.1.2.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -85,7 +85,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
     }
     ibuf[ PASSWDLEN ] = '\0';
 
-    if (( pwd = uam_getname(username, ulen)) == NULL ) {
+    if (( pwd = uam_getname(obj, username, ulen)) == NULL ) {
         return AFPERR_PARAM;
     }
 
@@ -311,7 +311,7 @@ struct papfile      *out;
 
     ulen = strlen(username);
 
-    if (( pwd = uam_getname(username, ulen)) == NULL ) {
+    if (( pwd = uam_getname(NULL, username, ulen)) == NULL ) {
         LOG(log_info, logtype_uams, "Bad Login ClearTxtUAM: ( %s ) not found ",
             username);
         return(-1);
index f81f885ebdfc2b2ba599aedceb3662dc841b8ba4..452bd78588136f89550ac0122578a0fb5847acd2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_pgp.c,v 1.9 2003-01-26 16:54:46 srittau Exp $
+ * $Id: uams_pgp.c,v 1.9.6.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -78,7 +78,7 @@ static int pgp_login(void *obj, struct passwd **uam_pwd,
     if ((unsigned long) ibuf & 1) /* padding */
       ++ibuf;
 
-    if (( pgppwd = uam_getname(name, i)) == NULL ) {
+    if (( pgppwd = uam_getname(obj, name, i)) == NULL ) {
       return AFPERR_PARAM;
     }
 
index abc0f4586976dc0468fa96761419f920e3e3e435..d1225d88f584e383c162074f75c591606e470157 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: uams_randnum.c,v 1.12 2003-01-21 16:31:39 srittau Exp $
+ * $Id: uams_randnum.c,v 1.12.6.1 2003-09-11 23:49:30 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -331,7 +331,7 @@ static int randnum_login(void *obj, struct passwd **uam_pwd,
   if ((unsigned long) ibuf & 1) /* padding */
     ++ibuf;
   
-  if (( randpwd = uam_getname(username, ulen)) == NULL )
+  if (( randpwd = uam_getname(obj, username, ulen)) == NULL )
     return AFPERR_PARAM; /* unknown user */
   
   LOG(log_info, logtype_uams, "randnum/rand2num login: %s", username);
index 948613a8da5ee01fc9250d951b3216bc0cb2ccf0..0197e18d841bf2dcfaf86d30de24859e8fc3e95a 100644 (file)
@@ -41,6 +41,8 @@
 #define UAM_OPTION_PROTOCOL    (1 << 7) /* DSI or ASP */
 #define UAM_OPTION_CLIENTNAME   (1 << 8) /* get client IP address */
 #define UAM_OPTION_KRB5SERVICE  (1 << 9) /* service name for krb5 principal */
+#define UAM_OPTION_MACCHARSET   (1 << 10) /* mac charset handle */
+#define UAM_OPTION_UNIXCHARSET  (1 << 11) /* unix charset handle */
 
 /* some password options. you pass these in the length parameter and
  * get back the corresponding option. not all of these are implemented. */
@@ -65,7 +67,7 @@ extern int uam_register __P((const int, const char *, const char *, ...));
 extern void uam_unregister __P((const int, const char *));
 
 /* helper functions */
-extern struct passwd *uam_getname __P((char *, const int));
+extern struct passwd *uam_getname __P((void*, char *, const int));
 extern int uam_checkuser __P((const struct passwd *));
 
 /* afp helper functions */