summaryrefslogtreecommitdiffstats
path: root/source/nsswitch/wb_client.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-11-13 21:28:31 +0000
committerJeremy Allison <jra@samba.org>2001-11-13 21:28:31 +0000
commit86b7cf7f85840316052ff29115bf55c04dc17486 (patch)
tree0aba51a9c3a5c44919f9655fadcf0d3ff061fbb8 /source/nsswitch/wb_client.c
parent98b9ff2dd89d2a12178b08f86f846b0875c7c150 (diff)
downloadsamba-86b7cf7f85840316052ff29115bf55c04dc17486.tar.gz
samba-86b7cf7f85840316052ff29115bf55c04dc17486.tar.xz
samba-86b7cf7f85840316052ff29115bf55c04dc17486.zip
Fix winbind client code so that winbind calls are not made if the
requested name does not have a winbind separator character. This makes the intent explicit. Tim, contact me if this is not what you indended. Jeremy.
Diffstat (limited to 'source/nsswitch/wb_client.c')
-rw-r--r--source/nsswitch/wb_client.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/source/nsswitch/wb_client.c b/source/nsswitch/wb_client.c
index 9b720e5ea42..92fdd62b15a 100644
--- a/source/nsswitch/wb_client.c
+++ b/source/nsswitch/wb_client.c
@@ -34,11 +34,8 @@ NSS_STATUS winbindd_request(int req_type,
static void parse_domain_user(char *domuser, fstring domain, fstring user)
{
- char *p;
- char *sep = lp_winbind_separator();
- if (!sep) sep = "\\";
- p = strchr(domuser,*sep);
- if (!p) p = strchr(domuser,'\\');
+ char *p = strchr(domuser,*lp_winbind_separator());
+
if (!p) {
fstrcpy(domain,"");
fstrcpy(user, domuser);
@@ -63,6 +60,13 @@ BOOL winbind_lookup_name(const char *name, DOM_SID *sid,
if (!sid || !name_type)
return False;
+ /*
+ * Don't do the lookup if the name has no separator.
+ */
+
+ if (!strchr(name, *lp_winbind_separator()))
+ return False;
+
/* Send off request */
ZERO_STRUCT(request);
@@ -285,13 +289,10 @@ int winbind_initgroups(char *user, gid_t gid)
{
gid_t *tgr, *groups = NULL;
int result;
- char *sep;
/* Call normal initgroups if we are a local user */
- sep = lp_winbind_separator();
-
- if (!strchr(user, *sep)) {
+ if (!strchr(user, *lp_winbind_separator())) {
return initgroups(user, gid);
}
@@ -362,11 +363,19 @@ int winbind_getgroups(const char *user, int size, gid_t *list)
gid_t *groups = NULL;
int result, i;
+ /*
+ * Don't do the lookup if the name has no separator.
+ */
+
+ if (!strchr(user, *lp_winbind_separator()))
+ return -1;
+
/* Fetch list of groups */
result = wb_getgroups(user, &groups);
- if (size == 0) goto done;
+ if (size == 0)
+ goto done;
if (result > size) {
result = -1;
@@ -422,7 +431,7 @@ BOOL winbind_gidtoname(fstring name, gid_t gid)
if (!winbind_lookup_sid(&sid, dom_name, group_name, &name_type))
return False;
- if (name_type != SID_NAME_USER)
+ if (name_type != SID_NAME_DOM_GRP)
return False;
slprintf(name, sizeof(fstring)-1, "%s%s%s", dom_name,
@@ -438,9 +447,8 @@ BOOL winbind_nametouid(uid_t *puid, const char *name)
DOM_SID sid;
enum SID_NAME_USE name_type;
- if (!winbind_lookup_name(name, &sid, &name_type)) {
+ if (!winbind_lookup_name(name, &sid, &name_type))
return False;
- }
if (name_type != SID_NAME_USER)
return False;
@@ -455,9 +463,8 @@ BOOL winbind_nametogid(gid_t *pgid, const char *gname)
DOM_SID g_sid;
enum SID_NAME_USE name_type;
- if (!winbind_lookup_name(gname, &g_sid, &name_type)) {
+ if (!winbind_lookup_name(gname, &g_sid, &name_type))
return False;
- }
if (name_type != SID_NAME_DOM_GRP)
return False;