svn commit: samba r19419 - in branches: SAMBA_3_0/source/lib
SAMBA_3_0/source/nsswitch SAMBA_3_0/source/passdb
SAMBA_3_0_23/source/lib SAMBA_3_0_23/source/nsswitch
SAMBA_3_0_23/source/passdb
jerry at samba.org
jerry at samba.org
Thu Oct 19 22:34:59 GMT 2006
Author: jerry
Date: 2006-10-19 22:34:58 +0000 (Thu, 19 Oct 2006)
New Revision: 19419
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19419
Log:
BUG 4109: Patch from Timur Bakeyev. Fix bug causing smbd to turn off
winbindd and fail to disable the _NO_WINBIND environment.
Modified:
branches/SAMBA_3_0/source/lib/system_smbd.c
branches/SAMBA_3_0/source/nsswitch/wb_common.c
branches/SAMBA_3_0/source/passdb/pdb_interface.c
branches/SAMBA_3_0_23/source/lib/system_smbd.c
branches/SAMBA_3_0_23/source/nsswitch/wb_common.c
branches/SAMBA_3_0_23/source/passdb/pdb_interface.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/system_smbd.c
===================================================================
--- branches/SAMBA_3_0/source/lib/system_smbd.c 2006-10-19 22:31:43 UTC (rev 19418)
+++ branches/SAMBA_3_0/source/lib/system_smbd.c 2006-10-19 22:34:58 UTC (rev 19419)
@@ -120,20 +120,16 @@
static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt)
{
int retval;
- char *winbindd_env;
+ BOOL winbind_env;
DEBUG(10,("sys_getgrouplist: user [%s]\n", user));
- /* Save the winbindd state and not just blindly turn it back on */
-
- winbindd_env = getenv(WINBINDD_DONT_ENV);
-
/* This is only ever called for Unix users, remote memberships are
* always determined by the info3 coming back from auth3 or the
* PAC. */
+ winbind_env = winbind_env_set();
+ winbind_off();
- winbind_off() ;
-
#ifdef HAVE_GETGROUPLIST
retval = getgrouplist(user, gid, groups, grpcnt);
#else
@@ -142,9 +138,8 @@
unbecome_root();
#endif
- /* allow winbindd lookups , but only if they were not already disabled */
-
- if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+ /* allow winbindd lookups, but only if they were not already disabled */
+ if (!winbind_env) {
winbind_on();
}
Modified: branches/SAMBA_3_0/source/nsswitch/wb_common.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/wb_common.c 2006-10-19 22:31:43 UTC (rev 19418)
+++ branches/SAMBA_3_0/source/nsswitch/wb_common.c 2006-10-19 22:34:58 UTC (rev 19419)
@@ -525,15 +525,11 @@
NSS_STATUS winbindd_send_request(int req_type, struct winbindd_request *request)
{
struct winbindd_request lrequest;
- char *env;
- int value;
-
+
/* Check for our tricky environment variable */
- if ( (env = getenv(WINBINDD_DONT_ENV)) != NULL ) {
- value = atoi(env);
- if ( value == 1 )
- return NSS_STATUS_NOTFOUND;
+ if (winbind_env_set()) {
+ return NSS_STATUS_NOTFOUND;
}
if (!request) {
@@ -632,3 +628,14 @@
return putenv(s) != -1;
}
+BOOL winbind_env_set( void )
+{
+ char *env;
+
+ if ((env=getenv(WINBINDD_DONT_ENV)) != NULL) {
+ if(strequal(env, "1")) {
+ return True;
+ }
+ }
+ return False;
+}
Modified: branches/SAMBA_3_0/source/passdb/pdb_interface.c
===================================================================
--- branches/SAMBA_3_0/source/passdb/pdb_interface.c 2006-10-19 22:31:43 UTC (rev 19418)
+++ branches/SAMBA_3_0/source/passdb/pdb_interface.c 2006-10-19 22:34:58 UTC (rev 19419)
@@ -1295,27 +1295,25 @@
struct group *grp;
char **gr;
struct passwd *pwd;
- char *winbindd_env;
+ BOOL winbind_env;
*pp_uids = NULL;
*p_num = 0;
/* We only look at our own sam, so don't care about imported stuff */
-
- winbindd_env = getenv(WINBINDD_DONT_ENV);
+ winbind_env = winbind_env_set();
winbind_off();
if ((grp = getgrgid(gid)) == NULL) {
/* allow winbindd lookups, but only if they weren't already disabled */
- if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+ if (!winbind_env) {
winbind_on();
}
-
+
return False;
}
/* Primary group members */
-
setpwent();
while ((pwd = getpwent()) != NULL) {
if (pwd->pw_gid == gid) {
@@ -1326,7 +1324,6 @@
endpwent();
/* Secondary group members */
-
for (gr = grp->gr_mem; (*gr != NULL) && ((*gr)[0] != '\0'); gr += 1) {
struct passwd *pw = getpwnam(*gr);
@@ -1336,11 +1333,10 @@
}
/* allow winbindd lookups, but only if they weren't already disabled */
-
- if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+ if (!winbind_env) {
winbind_on();
}
-
+
return True;
}
Modified: branches/SAMBA_3_0_23/source/lib/system_smbd.c
===================================================================
--- branches/SAMBA_3_0_23/source/lib/system_smbd.c 2006-10-19 22:31:43 UTC (rev 19418)
+++ branches/SAMBA_3_0_23/source/lib/system_smbd.c 2006-10-19 22:34:58 UTC (rev 19419)
@@ -120,20 +120,16 @@
static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt)
{
int retval;
- char *winbindd_env;
+ BOOL winbind_env;
DEBUG(10,("sys_getgrouplist: user [%s]\n", user));
- /* Save the winbindd state and not just blindly turn it back on */
-
- winbindd_env = getenv(WINBINDD_DONT_ENV);
-
/* This is only ever called for Unix users, remote memberships are
* always determined by the info3 coming back from auth3 or the
* PAC. */
+ winbind_env = winbind_env_set();
+ winbind_off();
- winbind_off() ;
-
#ifdef HAVE_GETGROUPLIST
retval = getgrouplist(user, gid, groups, grpcnt);
#else
@@ -142,9 +138,8 @@
unbecome_root();
#endif
- /* allow winbindd lookups , but only if they were not already disabled */
-
- if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+ /* allow winbindd lookups, but only if they were not already disabled */
+ if (!winbind_env) {
winbind_on();
}
Modified: branches/SAMBA_3_0_23/source/nsswitch/wb_common.c
===================================================================
--- branches/SAMBA_3_0_23/source/nsswitch/wb_common.c 2006-10-19 22:31:43 UTC (rev 19418)
+++ branches/SAMBA_3_0_23/source/nsswitch/wb_common.c 2006-10-19 22:34:58 UTC (rev 19419)
@@ -525,15 +525,11 @@
NSS_STATUS winbindd_send_request(int req_type, struct winbindd_request *request)
{
struct winbindd_request lrequest;
- char *env;
- int value;
-
+
/* Check for our tricky environment variable */
- if ( (env = getenv(WINBINDD_DONT_ENV)) != NULL ) {
- value = atoi(env);
- if ( value == 1 )
- return NSS_STATUS_NOTFOUND;
+ if (winbind_env_set()) {
+ return NSS_STATUS_NOTFOUND;
}
if (!request) {
@@ -632,3 +628,14 @@
return putenv(s) != -1;
}
+BOOL winbind_env_set( void )
+{
+ char *env;
+
+ if ((env=getenv(WINBINDD_DONT_ENV)) != NULL) {
+ if(strequal(env, "1")) {
+ return True;
+ }
+ }
+ return False;
+}
Modified: branches/SAMBA_3_0_23/source/passdb/pdb_interface.c
===================================================================
--- branches/SAMBA_3_0_23/source/passdb/pdb_interface.c 2006-10-19 22:31:43 UTC (rev 19418)
+++ branches/SAMBA_3_0_23/source/passdb/pdb_interface.c 2006-10-19 22:34:58 UTC (rev 19419)
@@ -1327,27 +1327,25 @@
struct group *grp;
char **gr;
struct passwd *pwd;
- char *winbindd_env;
+ BOOL winbind_env;
*pp_uids = NULL;
*p_num = 0;
/* We only look at our own sam, so don't care about imported stuff */
-
- winbindd_env = getenv(WINBINDD_DONT_ENV);
+ winbind_env = winbind_env_set();
winbind_off();
if ((grp = getgrgid(gid)) == NULL) {
/* allow winbindd lookups, but only if they weren't already disabled */
- if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+ if (!winbind_env) {
winbind_on();
}
-
+
return False;
}
/* Primary group members */
-
setpwent();
while ((pwd = getpwent()) != NULL) {
if (pwd->pw_gid == gid) {
@@ -1358,7 +1356,6 @@
endpwent();
/* Secondary group members */
-
for (gr = grp->gr_mem; (*gr != NULL) && ((*gr)[0] != '\0'); gr += 1) {
struct passwd *pw = getpwnam(*gr);
@@ -1368,11 +1365,10 @@
}
/* allow winbindd lookups, but only if they weren't already disabled */
-
- if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+ if (!winbind_env) {
winbind_on();
}
-
+
return True;
}
More information about the samba-cvs
mailing list