summaryrefslogtreecommitdiffstats
path: root/source/nsswitch/wb_common.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-11-02 16:22:28 +0000
committerTim Potter <tpot@samba.org>2003-11-02 16:22:28 +0000
commita8b487c4cb5d181e59755f49063512b2729bccb5 (patch)
treefc16359f4c0bff31ed7da985bcb6ca96e151eb6d /source/nsswitch/wb_common.c
parenteaf69b1ae7883573830244664cb0a81661541d92 (diff)
downloadsamba-a8b487c4cb5d181e59755f49063512b2729bccb5.tar.gz
samba-a8b487c4cb5d181e59755f49063512b2729bccb5.tar.xz
samba-a8b487c4cb5d181e59755f49063512b2729bccb5.zip
Use putenv() instead of setenv() in the winbind_{off,on}() functions. Some
platforms don't have setenv().
Diffstat (limited to 'source/nsswitch/wb_common.c')
-rw-r--r--source/nsswitch/wb_common.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/source/nsswitch/wb_common.c b/source/nsswitch/wb_common.c
index f146391653a..793d4a30b8a 100644
--- a/source/nsswitch/wb_common.c
+++ b/source/nsswitch/wb_common.c
@@ -472,17 +472,44 @@ NSS_STATUS winbindd_request(int req_type,
}
/*************************************************************************
- A couple of simple jfunctions to disable winbindd lookups and re-
+ A couple of simple functions to disable winbindd lookups and re-
enable them
************************************************************************/
+/* Use putenv() instead of setenv() as not all environments have the
+ latter. */
+
+static int set_winbind_dont_env(char value)
+{
+ int len = strlen(WINBINDD_DONT_ENV) + 3; /* len("_NO_WINBINDD=1\0") */
+ char *s = malloc(len);
+ int result;
+
+ if (s == NULL)
+ return -1;
+
+ /* It's OK to use strcpy here as we have allocated the correct
+ buffer size and no user or network data is used. */
+
+ strcpy(s, WINBINDD_DONT_ENV);
+
+ s[strlen(WINBINDD_DONT_ENV)] = '=';
+ s[strlen(WINBINDD_DONT_ENV) + 1] = value;
+ s[strlen(WINBINDD_DONT_ENV) + 2] = '\0';
+
+ result = putenv(s);
+
+ free(s);
+ return result;
+}
+
BOOL winbind_off( void )
{
- return (setenv( WINBINDD_DONT_ENV, "1", 1 ) != -1);
+ return set_winbind_dont_env('1') != -1;
}
BOOL winbind_on( void )
{
- return (setenv( WINBINDD_DONT_ENV, "0", 1 ) != -1);
+ return set_winbind_dont_env('0') != -1;
}