summaryrefslogtreecommitdiff
path: root/source3/lib/util.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-10-13 01:59:14 +0000
committerJeremy Allison <jra@samba.org>2000-10-13 01:59:14 +0000
commit330d678fbad70fabd9712c56ad15bd215f950255 (patch)
treedf834b65049fb3c675119cf6acfefa167cb96376 /source3/lib/util.c
parenta7f8d8b6362f4c2970fee63130963734528bcb6e (diff)
downloadsamba-330d678fbad70fabd9712c56ad15bd215f950255.tar.gz
samba-330d678fbad70fabd9712c56ad15bd215f950255.tar.bz2
samba-330d678fbad70fabd9712c56ad15bd215f950255.zip
Fix to allow smbd to call winbindd if it is running for all group enumeration,
falling back to the UNIX calls on error. This should fix all problems with smbd enumerating all users in all groups in all trusted domains via winbindd. Also changed GETDC to query 1C name rather than 1b name as only the PDC registers 1b. Jeremy. (This used to be commit 5b0038a2afd8abbd6fd4a58f5477a40d1926d498)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r--source3/lib/util.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index aced56bc2f..0aef60082f 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1099,60 +1099,80 @@ BOOL process_exists(pid_t pid)
/*******************************************************************
-turn a uid into a user name
+ Convert a uid into a user name.
********************************************************************/
+
char *uidtoname(uid_t uid)
{
- static char name[40];
- struct passwd *pass = sys_getpwuid(uid);
- if (pass) return(pass->pw_name);
- slprintf(name, sizeof(name) - 1, "%d",(int)uid);
- return(name);
+ static fstring name;
+ struct passwd *pass;
+
+ if (winbind_uidtoname(name, uid))
+ return name;
+
+ pass = sys_getpwuid(uid);
+ if (pass) return(pass->pw_name);
+ slprintf(name, sizeof(name) - 1, "%d",(int)uid);
+ return(name);
}
/*******************************************************************
-turn a gid into a group name
+ Convert a gid into a group name.
********************************************************************/
char *gidtoname(gid_t gid)
{
- static char name[40];
- struct group *grp = getgrgid(gid);
+ static fstring name;
+ struct group *grp;
+
+ if (winbind_gidtoname(name, gid))
+ return name;
+
+ grp = getgrgid(gid);
if (grp) return(grp->gr_name);
slprintf(name,sizeof(name) - 1, "%d",(int)gid);
return(name);
}
/*******************************************************************
-turn a user name into a uid
+ Convert a user name into a uid. If winbindd is present uses this.
********************************************************************/
-uid_t nametouid(const char *name)
+
+uid_t nametouid(char *name)
{
struct passwd *pass;
char *p;
uid_t u;
- u = strtol(name, &p, 0);
+ u = (uid_t)strtol(name, &p, 0);
if (p != name) return u;
+ if (winbind_nametouid(&u, name))
+ return u;
+
pass = sys_getpwnam(name);
if (pass) return(pass->pw_uid);
return (uid_t)-1;
}
/*******************************************************************
-turn a group name into a gid
+ Convert a name to a gid_t if possible. Return -1 if not a group. If winbindd
+ is present does a shortcut lookup...
********************************************************************/
-gid_t nametogid(const char *name)
+
+gid_t nametogid(char *name)
{
struct group *grp;
char *p;
gid_t g;
- g = strtol(name, &p, 0);
+ g = (gid_t)strtol(name, &p, 0);
if (p != name) return g;
+ if (winbind_nametogid(&g, name))
+ return g;
+
grp = getgrnam(name);
if (grp) return(grp->gr_gid);
return (gid_t)-1;