The branch, v4-2-test has been updated via ec9437d winbind3: Fix pwent variable substitution via 4393649 nss_winbind: add getgroupmembership for FreeBSD via aac155a lib: uid_wrapper: Fix setgroups and syscall detection on a system without native uid_wrapper library. from dcfa1a1 WHATSNEW: vfs_fruit
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-2-test - Log ----------------------------------------------------------------- commit ec9437d920bf987716bf53e667789c0dba1ca511 Author: Justin Maggard <jmaggar...@gmail.com> Date: Thu Oct 2 17:21:06 2014 -0700 winbind3: Fix pwent variable substitution Commit 0ce46318 (winbind3: Simplify fillup_pw_field) broke variable substitution by copying from the wrong (unsubstituted) buffer. Fix it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10852 Signed-off-by: Justin Maggard <jmaggar...@gmail.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Richard Sharpe <rsha...@samba.org> (cherry picked from commit 902086d0d4c688236ad4a8248a50de8639e1e524) Autobuild-User(v4-2-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-2-test): Sun Oct 26 23:58:23 CET 2014 on sn-devel-104 commit 43936492797f27fdeaca6f41314da0ea207aeff3 Author: Björn Jacke <b...@sernet.de> Date: Sun Oct 19 15:48:45 2014 +0200 nss_winbind: add getgroupmembership for FreeBSD The getgroupmembership call on FreeBSD is needed for "winbind expand groups=0" (the new default in 4.2) to work. Thanks to Timur I. Bakeyev for the enhancement patch. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10835 Signed-off-by: Bjoern Jacke <b...@sernet.de> Reviewed-by: Volker Lendecke <v...@samba.org> (cherry picked from commit 8ccf5f66691e2bbf0883afa658282ef2ac60b015) commit aac155a72f28210ba64ea2fe1948db4cbf4474ed Author: Jeremy Allison <j...@samba.org> Date: Fri Oct 3 17:18:34 2014 -0700 lib: uid_wrapper: Fix setgroups and syscall detection on a system without native uid_wrapper library. Originally from youzh...@gmail.com. https://bugzilla.samba.org/show_bug.cgi?id=10851 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 7366204845fda07ee4a83a1a63875f643d0a5794) Signed-off-by: Andreas Schneider <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: lib/uid_wrapper/wscript | 7 ++++ nsswitch/winbind_nss_freebsd.c | 74 +++++++++++++++++++++++++++++++++++++- source3/winbindd/wb_fill_pwent.c | 2 +- 3 files changed, 81 insertions(+), 2 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/uid_wrapper/wscript b/lib/uid_wrapper/wscript index 3e73e83..6b58595 100644 --- a/lib/uid_wrapper/wscript +++ b/lib/uid_wrapper/wscript @@ -49,6 +49,13 @@ def configure(conf): 'HAVE_FUNCTION_ATTRIBUTE_FORMAT', addmain=False, msg='Checking for printf format validation support') + # Prototype checks + conf.CHECK_C_PROTOTYPE('setgroups', + 'int setgroups(int ngroups, const gid_t *grouplist)', + define='HAVE_SETGROUPS_INT', headers='unistd.h sys/types.h') + conf.CHECK_C_PROTOTYPE('syscall', + 'int syscall(int number, ...)', + define='HAVE_SYSCALL_INT', headers='unistd.h sys/syscall.h') # Create full path to uid_wrapper srcdir = os.path.realpath(conf.srcdir) diff --git a/nsswitch/winbind_nss_freebsd.c b/nsswitch/winbind_nss_freebsd.c index 5fcd557..476349f 100644 --- a/nsswitch/winbind_nss_freebsd.c +++ b/nsswitch/winbind_nss_freebsd.c @@ -5,6 +5,7 @@ routines against Samba winbind/Windows NT Domain Copyright (C) Aaron Collins 2003 + Copyright (C) Timur I. Bakeyev 2013 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,7 +24,6 @@ #include "winbind_client.h" /* Make sure that the module gets registered needed by freebsd 5.1 */ - extern enum nss_status _nss_winbind_getgrent_r(struct group *, char *, size_t, int *); extern enum nss_status _nss_winbind_getgrnam_r(const char *, struct group *, @@ -32,6 +32,8 @@ extern enum nss_status _nss_winbind_getgrgid_r(gid_t gid, struct group *, char * size_t, int *); extern enum nss_status _nss_winbind_setgrent(void); extern enum nss_status _nss_winbind_endgrent(void); +extern enum nss_status _nss_winbind_initgroups_dyn(char *, gid_t, long int *, + long int *, gid_t **, long int , int *); extern enum nss_status _nss_winbind_getpwent_r(struct passwd *, char *, size_t, int *); @@ -41,6 +43,7 @@ extern enum nss_status _nss_winbind_getpwuid_r(gid_t gid, struct passwd *, char size_t, int *); extern enum nss_status _nss_winbind_setpwent(void); extern enum nss_status _nss_winbind_endpwent(void); +ns_mtab *nss_module_register(const char *, unsigned int *, nss_module_unregister_fn *); NSS_METHOD_PROTOTYPE(__nss_compat_getgrnam_r); NSS_METHOD_PROTOTYPE(__nss_compat_getgrgid_r); @@ -53,6 +56,9 @@ NSS_METHOD_PROTOTYPE(__nss_compat_getpwuid_r); NSS_METHOD_PROTOTYPE(__nss_compat_getpwent_r); NSS_METHOD_PROTOTYPE(__nss_compat_setpwent); NSS_METHOD_PROTOTYPE(__nss_compat_endpwent); +NSS_METHOD_PROTOTYPE(__nss_compat_endpwent); + +NSS_METHOD_PROTOTYPE(__freebsd_getgroupmembership); static ns_mtab methods[] = { { NSDB_GROUP, "getgrnam_r", __nss_compat_getgrnam_r, _nss_winbind_getgrnam_r }, @@ -60,6 +66,7 @@ static ns_mtab methods[] = { { NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, _nss_winbind_getgrent_r }, { NSDB_GROUP, "setgrent", __nss_compat_setgrent, _nss_winbind_setgrent }, { NSDB_GROUP, "endgrent", __nss_compat_endgrent, _nss_winbind_endgrent }, +{ NSDB_GROUP, "getgroupmembership", __freebsd_getgroupmembership, NULL }, { NSDB_PASSWD, "getpwnam_r", __nss_compat_getpwnam_r, _nss_winbind_getpwnam_r }, { NSDB_PASSWD, "getpwuid_r", __nss_compat_getpwuid_r, _nss_winbind_getpwuid_r }, @@ -69,6 +76,71 @@ static ns_mtab methods[] = { }; +/* Taken from libc */ +static int +gr_addgid(gid_t gid, gid_t *groups, int maxgrp, int *grpcnt) +{ + int ret, dupc; + + /* skip duplicates */ + for (dupc = 0; dupc < MIN(maxgrp, *grpcnt); dupc++) { + if (groups[dupc] == gid) + return 1; + } + + ret = 1; + if (*grpcnt < maxgrp) /* add this gid */ + groups[*grpcnt] = gid; + else + ret = 0; + + (*grpcnt)++; + + return ret; +} + +/* + rv = _nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership", + defaultsrc, uname, agroup, groups, maxgrp, grpcnt); +*/ + +int +__freebsd_getgroupmembership(void *retval, void *mdata, va_list ap) +{ + const char *uname = va_arg(ap, const char *); + gid_t group = va_arg(ap, gid_t); + gid_t *groups = va_arg(ap, gid_t *); + int maxgrp = va_arg(ap, int); + int *groupc = va_arg(ap, int *); + + NSS_STATUS ret; + long int lcount, lsize; + int i, errnop; + gid_t *tmpgroups; + + /* Can be realloc() inside _nss_winbind_initgroups_dyn() */ + if ((tmpgroups=calloc(maxgrp, sizeof(gid_t))) == NULL) { + errno = ENOMEM; + return NS_TRYAGAIN; + } + + lcount = 0; + lsize = maxgrp; + /* insert primary membership(possibly already there) */ + gr_addgid(group, groups, maxgrp, groupc); + /* Don't limit number of groups, we want to know total size */ + ret = _nss_winbind_initgroups_dyn(uname, group, &lcount, &lsize, + &tmpgroups, 0, &errnop); + if (ret == NSS_STATUS_SUCCESS) { + /* lcount potentially can be bigger than maxgrp, so would groupc */ + for (i = 0; i < lcount; i++) + gr_addgid(tmpgroups[i], groups, maxgrp, groupc); + } + free(tmpgroups); + /* Let following nsswitch backend(s) add more groups(?) */ + return NSS_STATUS_NOTFOUND; +} + ns_mtab * nss_module_register(const char *source, unsigned int *mtabsize, nss_module_unregister_fn *unreg) diff --git a/source3/winbindd/wb_fill_pwent.c b/source3/winbindd/wb_fill_pwent.c index 206827c..1135ef3 100644 --- a/source3/winbindd/wb_fill_pwent.c +++ b/source3/winbindd/wb_fill_pwent.c @@ -240,7 +240,7 @@ static bool fillup_pw_field(const char *lp_template, return False; } - fstrcpy(out, templ); + fstrcpy(out, result); TALLOC_FREE(result); return True; -- Samba Shared Repository