summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-02-11 18:35:58 +0100
committerStefan Metzmacher <metze@samba.org>2008-02-13 10:44:52 +0100
commit5f623f54a919cc687d0ff16c16038c05a501008d (patch)
tree4eebcd7ccea88aa0fd74dfbf4db895ccfb0b2e22
parent26d012dd3de8ec146eb22656f1ed8eef110e4be6 (diff)
downloadsamba-5f623f54a919cc687d0ff16c16038c05a501008d.tar.gz
samba-5f623f54a919cc687d0ff16c16038c05a501008d.tar.xz
samba-5f623f54a919cc687d0ff16c16038c05a501008d.zip
nsswitch: convert winbind_env_set(), winbind_on() and winbind_off() into macros
metze
-rw-r--r--source/lib/system_smbd.c4
-rw-r--r--source/nsswitch/wb_common.c27
-rw-r--r--source/nsswitch/winbind_client.h11
-rw-r--r--source/passdb/pdb_interface.c4
-rw-r--r--source/winbindd/idmap_nss.c8
5 files changed, 16 insertions, 38 deletions
diff --git a/source/lib/system_smbd.c b/source/lib/system_smbd.c
index 9d3eb95664c..1f5dd3172f3 100644
--- a/source/lib/system_smbd.c
+++ b/source/lib/system_smbd.c
@@ -125,7 +125,7 @@ static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grp
* always determined by the info3 coming back from auth3 or the
* PAC. */
winbind_env = winbind_env_set();
- winbind_off();
+ (void)winbind_off();
#ifdef HAVE_GETGROUPLIST
retval = getgrouplist(user, gid, groups, grpcnt);
@@ -137,7 +137,7 @@ static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grp
/* allow winbindd lookups, but only if they were not already disabled */
if (!winbind_env) {
- winbind_on();
+ (void)winbind_on();
}
return retval;
diff --git a/source/nsswitch/wb_common.c b/source/nsswitch/wb_common.c
index 49a2935bffb..b113fc3336e 100644
--- a/source/nsswitch/wb_common.c
+++ b/source/nsswitch/wb_common.c
@@ -538,18 +538,6 @@ int winbindd_read_reply(struct winbindd_response *response)
return result1 + result2;
}
-bool winbind_env_set(void)
-{
- char *env;
-
- if ((env=getenv(WINBINDD_DONT_ENV)) != NULL) {
- if(strcmp(env, "1") == 0) {
- return true;
- }
- }
- return false;
-}
-
/*
* send simple types of requests
*/
@@ -663,21 +651,6 @@ NSS_STATUS winbindd_priv_request_response(int req_type,
}
/*************************************************************************
- A couple of simple functions to disable winbindd lookups and re-
- enable them
- ************************************************************************/
-
-bool winbind_off(void)
-{
- return setenv(WINBINDD_DONT_ENV, "1", 1) != -1;
-}
-
-bool winbind_on(void)
-{
- return setenv(WINBINDD_DONT_ENV, "0", 1) != -1;
-}
-
-/*************************************************************************
************************************************************************/
const char *nss_err_str(NSS_STATUS ret)
diff --git a/source/nsswitch/winbind_client.h b/source/nsswitch/winbind_client.h
index 2a3956e1fd4..757f5869e90 100644
--- a/source/nsswitch/winbind_client.h
+++ b/source/nsswitch/winbind_client.h
@@ -14,9 +14,14 @@ NSS_STATUS winbindd_priv_request_response(int req_type,
struct winbindd_response *response);
int winbindd_read_reply(struct winbindd_response *response);
-bool winbind_env_set(void);
-bool winbind_off(void);
-bool winbind_on(void);
+#define winbind_env_set() \
+ (strcmp(getenv(WINBINDD_DONT_ENV)?getenv(WINBINDD_DONT_ENV):"0","1") == 0)
+
+#define winbind_off() \
+ (setenv(WINBINDD_DONT_ENV, "1", 1) == 0)
+
+#define winbind_on() \
+ (setenv(WINBINDD_DONT_ENV, "0", 1) == 0)
int winbind_write_sock(void *buffer, int count, int recursing, int need_priv);
int winbind_read_sock(void *buffer, int count);
diff --git a/source/passdb/pdb_interface.c b/source/passdb/pdb_interface.c
index fbba8bcaee4..cd34c89bfc5 100644
--- a/source/passdb/pdb_interface.c
+++ b/source/passdb/pdb_interface.c
@@ -1349,7 +1349,7 @@ static bool get_memberuids(TALLOC_CTX *mem_ctx, gid_t gid, uid_t **pp_uids, size
/* We only look at our own sam, so don't care about imported stuff */
winbind_env = winbind_env_set();
- winbind_off();
+ (void)winbind_off();
if ((grp = getgrgid(gid)) == NULL) {
/* allow winbindd lookups, but only if they weren't already disabled */
@@ -1385,7 +1385,7 @@ static bool get_memberuids(TALLOC_CTX *mem_ctx, gid_t gid, uid_t **pp_uids, size
/* allow winbindd lookups, but only if they weren't already disabled */
if (!winbind_env) {
- winbind_on();
+ (void)winbind_on();
}
return ret;
diff --git a/source/winbindd/idmap_nss.c b/source/winbindd/idmap_nss.c
index 46c24d7fcb9..e4acd9ce65a 100644
--- a/source/winbindd/idmap_nss.c
+++ b/source/winbindd/idmap_nss.c
@@ -87,10 +87,10 @@ static NTSTATUS idmap_nss_unixids_to_sids(struct idmap_domain *dom, struct id_ma
/* by default calls to winbindd are disabled
the following call will not recurse so this is safe */
- winbind_on();
+ (void)winbind_on();
/* Lookup name from PDC using lsa_lookup_names() */
ret = winbind_lookup_name(dom->name, name, ids[i]->sid, &type);
- winbind_off();
+ (void)winbind_off();
if (!ret) {
/* TODO: how do we know if the name is really not mapped,
@@ -153,9 +153,9 @@ static NTSTATUS idmap_nss_sids_to_unixids(struct idmap_domain *dom, struct id_ma
/* by default calls to winbindd are disabled
the following call will not recurse so this is safe */
- winbind_on();
+ (void)winbind_on();
ret = winbind_lookup_sid(ctx, ids[i]->sid, &dom_name, &name, &type);
- winbind_off();
+ (void)winbind_off();
if (!ret) {
/* TODO: how do we know if the name is really not mapped,