Undo the new --enable-developer flags that caused breakage on gcc != 3.2, and
[garming/samba-autobuild/.git] / source3 / lib / util_getent.c
index 81b36effcb48143055308c7844e1d5cd7951d0b8..6699ce3e92393ebfab01a37210c730a2e5eb9f34 100644 (file)
@@ -1,6 +1,5 @@
 /*
-   Unix SMB/Netbios implementation.
-   Version 3.0
+   Unix SMB/CIFS implementation.
    Samba utility functions
    Copyright (C) Simo Sorce 2001
    Copyright (C) Jeremy Allison 2001
 
 #include "includes.h"
 
-#if 0
-static void print_grent_list(struct sys_grent *glist)
-{
-       DEBUG(100, ("print_grent_list: %x\n", glist ));
-       while (glist) {
-               DEBUG(100,("glist: %x ", glist));
-               if (glist->gr_name)
-                       DEBUG(100,(": gr_name = (%x) %s ", glist->gr_name, glist->gr_name));
-               if (glist->gr_passwd)
-                       DEBUG(100,(": gr_passwd = (%x) %s ", glist->gr_passwd, glist->gr_passwd));
-               if (glist->gr_mem) {
-                       int i;
-                       for (i = 0; glist->gr_mem[i]; i++)
-                               DEBUG(100,(" : gr_mem[%d] = (%x) %s ", i, glist->gr_mem[i], glist->gr_mem[i]));
-               }
-               DEBUG(100,(": gr_next = %x\n", glist->next ));
-               glist = glist->next;
-       }
-       DEBUG(100,("FINISHED !\n\n"));
-}
-#endif
 
 /****************************************************************
  Returns a single linked list of group entries.
@@ -273,19 +251,29 @@ struct sys_userlist *get_users_in_group(const char *gname)
 {
        struct sys_userlist *list_head = NULL;
        struct group *gptr;
+       fstring domain;
+       fstring groupname;
+       DOM_SID sid;
+       enum SID_NAME_USE name_type;
 
-       /*
-        * If we're doing this via winbindd, don't do the
-        * entire group list enumeration as we know this is
-        * pointless (and slow).
-        */
+       /* No point using winbind if we can't split it in the
+          first place */
+       if (split_domain_and_name(gname, domain, groupname)) {
 
-       if (strchr(gname,*lp_winbind_separator())) {
-               if ((gptr = (struct group *)getgrnam(gname)) == NULL)
-                       return NULL;
-               return add_members_to_userlist(list_head, gptr);
+               /*
+                * If we're doing this via winbindd, don't do the
+                * entire group list enumeration as we know this is
+                * pointless (and slow).
+                */
+               
+               if (winbind_lookup_name(domain, groupname, &sid, &name_type) 
+                   && name_type == SID_NAME_DOM_GRP) {
+                       if ((gptr = (struct group *)getgrnam(gname)) == NULL)
+                               return NULL;
+                       return add_members_to_userlist(list_head, gptr);
+               }
        }
-
+       
        setgrent();
        while((gptr = getgrent()) != NULL) {
                if (strequal(gname, gptr->gr_name)) {