]> arthur.barton.de Git - netatalk.git/commitdiff
add a ntdomain option to user name, from exanet
authordidg <didg>
Mon, 3 Dec 2007 14:50:38 +0000 (14:50 +0000)
committerdidg <didg>
Mon, 3 Dec 2007 14:50:38 +0000 (14:50 +0000)
etc/afpd/afp_options.c
etc/afpd/auth.c
etc/afpd/globals.h
etc/afpd/quota.c
etc/afpd/uam.c
etc/afpd/volume.c

index d6566dfdd0096f5943d63231db3fbb6046bd0f7d..c275544a816d3bfba0de3591128ba75b4341dbf0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_options.c,v 1.35 2005-04-28 20:49:39 bfernhomberg Exp $
+ * $Id: afp_options.c,v 1.36 2007-12-03 14:50:38 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -147,6 +147,11 @@ void afp_options_free(struct afp_options *opt,
        free(opt->unixcodepage);
     if (opt->maccodepage && (opt->maccodepage != save->maccodepage))
        free(opt->maccodepage);
+
+    if (opt->ntdomain && (opt->ntdomain != save->ntdomain))
+       free(opt->ntdomain);
+    if (opt->ntseparator && (opt->ntseparator != save->ntseparator))
+       free(opt->ntseparator);
 }
 
 /* initialize options */
@@ -181,6 +186,9 @@ void afp_options_init(struct afp_options *options)
     options->unixcodepage = "LOCALE";
     options->maccharset = CH_MAC;
     options->maccodepage = "MAC_ROMAN";
+
+    options->ntdomain = NULL;
+    options->ntseparator = NULL;
 }
 
 /* parse an afpd.conf line. i'm doing it this way because it's
@@ -517,6 +525,12 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         options->closevol= 1;
     }
 
+    if ((c = getoption(buf, "-ntdomain")) && (opt = strdup(c)))
+       options->ntdomain = opt;
+
+    if ((c = getoption(buf, "-ntseparator")) && (opt = strdup(c)))
+       options->ntseparator = opt;
+     
     return 1;
 }
 
index ef0f3c9023fe7567d1d3870d2c6fae5df918b0ee..a0b05b48d788da63a444d1216d2340f026bd60e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.50 2007-05-16 18:38:21 didg Exp $
+ * $Id: auth.c,v 1.51 2007-12-03 14:50:38 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
index 0dd634157a6aa9f28763f26e54d5261aee80f589..e1c3bf41483b291fbd4a337a7e079bc067140174 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: globals.h,v 1.21 2005-04-28 20:49:43 bfernhomberg Exp $
+ * $Id: globals.h,v 1.22 2007-12-03 14:50:38 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -32,6 +32,7 @@
 #endif
 
 #define MACFILELEN 31
+#define MAXUSERLEN 256
 
 #define OPTION_DEBUG         (1 << 0)
 #define OPTION_USERVOLFIRST  (1 << 1)
@@ -82,6 +83,10 @@ struct afp_options {
 #ifdef ADMIN_GRP
     gid_t admingid;
 #endif /* ADMIN_GRP */
+
+    /* default value for winbind authentication */
+    char *ntdomain, *ntseparator;
+
 };
 
 #define AFPOBJ_TMPSIZ (MAXPATHLEN)
@@ -91,7 +96,7 @@ typedef struct AFPObj {
     void *handle, *config;
     struct afp_options options;
     char *Obj, *Type, *Zone;
-    char username[MACFILELEN + 1];
+    char username[MAXUSERLEN];
     void (*logout)(void), (*exit)(int);
     int (*reply)(void *, int);
     int (*attention)(void *, AFPUserBytes);
index 24e802f90fba1089a02dae2c9f47ab82cc092ee4..e5051671e9393bd678d670888926cb95749a3523 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: quota.c,v 1.28 2007-12-03 11:39:14 didg Exp $
+ * $Id: quota.c,v 1.29 2007-12-03 14:50:39 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
index c7d3eb91c71c140709c689143a615901b3aed078..cdf8526a37b97f6d324823c26ec913c8c5e35167 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uam.c,v 1.25 2005-04-28 20:49:44 bfernhomberg Exp $
+ * $Id: uam.c,v 1.26 2007-12-03 14:50:39 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -291,7 +291,10 @@ void uam_unregister(const int type, const char *name)
     free(uam);
 }
 
-/* --- helper functions for plugin uams --- */
+/* --- helper functions for plugin uams --- 
+ * name: user name
+ * len:  size of name buffer.
+*/
 
 struct passwd *uam_getname(void *private, char *name, const int len)
 {
@@ -305,7 +308,29 @@ struct passwd *uam_getname(void *private, char *name, const int len)
 
     if ((pwent = getpwnam(name)))
         return pwent;
-
+        
+    /* if we have a NT domain name try with it */
+    if (obj->options.ntdomain && obj->options.ntseparator) {
+        /* FIXME What about charset ? */
+        size_t ulen = strlen(obj->options.ntdomain) + strlen(obj->options.ntseparator) + strlen(name);
+        if ((p = malloc(ulen +1))) {
+            strcpy(p, obj->options.ntdomain);
+            strcat(p, obj->options.ntseparator);
+            strcat(p, name);
+            pwent = getpwnam(p);
+            free(p);
+            if (pwent) {
+                int len = strlen(pwent->pw_name);              
+                if (len < MAXUSERLEN) {
+                    strncpy(name,pwent->pw_name, MAXUSERLEN);  
+                }else{
+                    LOG(log_error, logtype_uams, "MAJOR:The name %s is longer than %d",pwent->pw_name,MAXUSERLEN);
+                }
+
+                return pwent;
+            }
+        }
+    }
 #ifndef NO_REAL_USER_NAME
 
     if ( (size_t) -1 == (namelen = convert_string((utf8_encoding())?CH_UTF8_MAC:obj->options.maccharset,
index 9c5272458c9b108fee8834aeaa3c4fe2c974978a..5c9babc49857ed142e5b107bbd965374f7c4bd87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.68 2006-09-29 09:39:16 didg Exp $
+ * $Id: volume.c,v 1.69 2007-12-03 14:50:39 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -315,7 +315,11 @@ static char *volxlate(AFPObj *obj, char *dest, size_t destlen,
             } else
                 q = obj->options.hostname;
         } else if (is_var(p, "$u")) {
-            q = obj->username;
+            char* sep = NULL;
+            if ( obj->options.ntseparator && (sep = strchr(obj->username, obj->options.ntseparator[0])) != NULL)
+                q = sep+1;
+            else
+                q = obj->username;
         } else if (is_var(p, "$v")) {
             if (volname) {
                 q = volname;
@@ -1599,6 +1603,7 @@ int       ibuflen _U_, *rbuflen;
     char        path[ MAXPATHLEN + 1];
     char        *vol_uname;
     char        *vol_mname;
+    char        *volname_tmp;
 
     ibuf += 2;
     memcpy(&bitmap, ibuf, sizeof( bitmap ));
@@ -1611,6 +1616,10 @@ int      ibuflen _U_, *rbuflen;
 
     len = (unsigned char)*ibuf++;
     volname = obj->oldtmp;
+
+    if ((volname_tmp = strchr(volname,'+')) != NULL)
+        volname = volname_tmp+1;
+
     namelen = convert_string( (utf8_encoding()?CH_UTF8_MAC:obj->options.maccharset), CH_UCS2,
                               ibuf, len, volname, sizeof(obj->oldtmp));
     if ( namelen <= 0){