/*
- * $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.
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 */
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
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;
}
/*
- * $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.
/*
- * $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.
#endif
#define MACFILELEN 31
+#define MAXUSERLEN 256
#define OPTION_DEBUG (1 << 0)
#define OPTION_USERVOLFIRST (1 << 1)
#ifdef ADMIN_GRP
gid_t admingid;
#endif /* ADMIN_GRP */
+
+ /* default value for winbind authentication */
+ char *ntdomain, *ntseparator;
+
};
#define AFPOBJ_TMPSIZ (MAXPATHLEN)
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);
/*
- * $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.
/*
- * $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.
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)
{
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,
/*
- * $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.
} 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;
char path[ MAXPATHLEN + 1];
char *vol_uname;
char *vol_mname;
+ char *volname_tmp;
ibuf += 2;
memcpy(&bitmap, ibuf, sizeof( bitmap ));
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){