r2865: Add static and remove unused functions that only cload the blame-game
authorAndrew Bartlett <abartlet@samba.org>
Fri, 8 Oct 2004 13:00:47 +0000 (13:00 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:52:55 +0000 (10:52 -0500)
in finding out who is causing the massive performance problems with
large LDAP directories.

Andrew Bartlett
(This used to be commit f16ed2616a67c412bc9b78354a5faf673e64cf42)

source3/groupdb/mapping.c
source3/rpc_server/srv_util.c

index 6725165c3cfd4c82050213dac0113270b7f7d546..d189f447d08967fd128ac10efee58409b00b9f45 100644 (file)
@@ -957,128 +957,6 @@ BOOL get_group_from_gid(gid_t gid, GROUP_MAP *map)
 }
 
 
-
-
-/****************************************************************************
- Get the member users of a group and
- all the users who have that group as primary.
-            
- give back an array of SIDS
- return the grand number of users
-
-
- TODO: sort the list and remove duplicate. JFM.
-
-****************************************************************************/
-        
-BOOL get_sid_list_of_group(gid_t gid, DOM_SID **sids, int *num_sids)
-{
-       struct group *grp;
-       int i=0;
-       char *gr;
-       DOM_SID *s;
-
-       struct sys_pwent *userlist;
-       struct sys_pwent *user;
-       if(!init_group_mapping()) {
-               DEBUG(0,("failed to initialize group mapping\n"));
-               return(False);
-       }
-
-       *num_sids = 0;
-       *sids=NULL;
-       
-       if ( (grp=getgrgid(gid)) == NULL)
-               return False;
-
-       gr = grp->gr_mem[0];
-       DEBUG(10, ("getting members\n"));
-        
-       while (gr && (*gr != (char)'\0')) {
-               SAM_ACCOUNT *group_member_acct = NULL;
-               BOOL found_user;
-               s = Realloc((*sids), sizeof(**sids)*(*num_sids+1));
-               if (!s) {
-                       DEBUG(0,("get_uid_list_of_group: unable to enlarge SID list!\n"));
-                       return False;
-               }
-               else (*sids) = s;
-
-               if (!NT_STATUS_IS_OK(pdb_init_sam(&group_member_acct))) {
-                       continue;
-               }
-
-               become_root();
-               found_user = pdb_getsampwnam(group_member_acct, gr);
-               unbecome_root();
-       
-               if (found_user) {
-                       sid_copy(&(*sids)[*num_sids], pdb_get_user_sid(group_member_acct));
-                       (*num_sids)++;
-               }
-       
-               pdb_free_sam(&group_member_acct);
-
-               gr = grp->gr_mem[++i];
-       }
-       DEBUG(10, ("got [%d] members\n", *num_sids));
-
-       winbind_off();
-
-       user = userlist = getpwent_list();
-
-       while (user != NULL) {
-
-               SAM_ACCOUNT *group_member_acct = NULL;
-               BOOL found_user;
-
-               if (user->pw_gid != gid) {
-                       user = user->next;
-                       continue;
-               }
-
-               s = Realloc((*sids), sizeof(**sids)*(*num_sids+1));
-               if (!s) {
-                       DEBUG(0,("get_sid_list_of_group: unable to enlarge "
-                                "SID list!\n"));
-                       pwent_free(userlist);
-                       winbind_on();
-                       return False;
-               }
-               else (*sids) = s;
-                       
-               if (!NT_STATUS_IS_OK(pdb_init_sam(&group_member_acct))) {
-                       continue;
-               }
-                       
-               become_root();
-               found_user = pdb_getsampwnam(group_member_acct, user->pw_name);
-               unbecome_root();
-                       
-               if (found_user) {
-                       sid_copy(&(*sids)[*num_sids],
-                                pdb_get_user_sid(group_member_acct));
-                       (*num_sids)++;
-               } else {
-                       DEBUG(4,("get_sid_list_of_group: User %s [uid == %lu] "
-                                "has no samba account\n",
-                                user->pw_name, (unsigned long)user->pw_uid));
-                       if (algorithmic_uid_to_sid(&(*sids)[*num_sids],
-                                                  user->pw_uid))
-                               (*num_sids)++;
-               }
-               pdb_free_sam(&group_member_acct);
-
-               user = user->next;
-       }
-       pwent_free(userlist);
-       DEBUG(10, ("got primary groups, members: [%d]\n", *num_sids));
-
-       winbind_on();
-        return True;
-}
-
 /****************************************************************************
  Create a UNIX group on demand.
 ****************************************************************************/
index 5bb8db4e062507156c8ee1b9dff3ab64c16fbf88..d70054af8c044724a5bade380f2573dd3c9ac646 100644 (file)
@@ -46,7 +46,7 @@
  * and groups.
  */
 
-rid_name builtin_alias_rids[] =
+static const rid_name builtin_alias_rids[] =
 {  
     { BUILTIN_ALIAS_RID_ADMINS       , "Administrators" },
     { BUILTIN_ALIAS_RID_USERS        , "Users" },
@@ -62,7 +62,7 @@ rid_name builtin_alias_rids[] =
 };
 
 /* array lookup of well-known Domain RID users. */
-rid_name domain_user_rids[] =
+static const rid_name domain_user_rids[] =
 {  
     { DOMAIN_USER_RID_ADMIN         , "Administrator" },
     { DOMAIN_USER_RID_GUEST         , "Guest" },
@@ -70,7 +70,7 @@ rid_name domain_user_rids[] =
 };
 
 /* array lookup of well-known Domain RID groups. */
-rid_name domain_group_rids[] =
+static const rid_name domain_group_rids[] =
 {  
     { DOMAIN_GROUP_RID_ADMINS       , "Domain Admins" },
     { DOMAIN_GROUP_RID_USERS        , "Domain Users" },
@@ -414,167 +414,3 @@ NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid,
        return NT_STATUS_OK;
 }
 
-/*******************************************************************
- Look up a local (domain) rid and return a name and type.
- ********************************************************************/
-NTSTATUS local_lookup_group_name(uint32 rid, char *group_name, uint32 *type)
-{
-       int i = 0; 
-       (*type) = SID_NAME_DOM_GRP;
-
-       DEBUG(5,("lookup_group_name: rid: %d", rid));
-
-       while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0)
-       {
-               i++;
-       }
-
-       if (domain_group_rids[i].rid != 0)
-       {
-               fstrcpy(group_name, domain_group_rids[i].name);
-               DEBUG(5,(" = %s\n", group_name));
-               return NT_STATUS_OK;
-       }
-
-       DEBUG(5,(" none mapped\n"));
-       return NT_STATUS_NONE_MAPPED;
-}
-
-/*******************************************************************
- Look up a local alias rid and return a name and type.
- ********************************************************************/
-NTSTATUS local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type)
-{
-       int i = 0; 
-       (*type) = SID_NAME_WKN_GRP;
-
-       DEBUG(5,("lookup_alias_name: rid: %d", rid));
-
-       while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0)
-       {
-               i++;
-       }
-
-       if (builtin_alias_rids[i].rid != 0)
-       {
-               fstrcpy(alias_name, builtin_alias_rids[i].name);
-               DEBUG(5,(" = %s\n", alias_name));
-               return NT_STATUS_OK;
-       }
-
-       DEBUG(5,(" none mapped\n"));
-       return NT_STATUS_NONE_MAPPED;
-}
-
-
-#if 0 /*Nobody uses this function just now*/
-/*******************************************************************
- Look up a local user rid and return a name and type.
- ********************************************************************/
-NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type)
-{
-       SAM_ACCOUNT *sampwd=NULL;
-       int i = 0;
-       BOOL ret;
-       
-       (*type) = SID_NAME_USER;
-
-       DEBUG(5,("lookup_user_name: rid: %d", rid));
-
-       /* look up the well-known domain user rids first */
-       while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0)
-       {
-               i++;
-       }
-
-       if (domain_user_rids[i].rid != 0) {
-               fstrcpy(user_name, domain_user_rids[i].name);
-               DEBUG(5,(" = %s\n", user_name));
-               return NT_STATUS_OK;
-       }
-
-       pdb_init_sam(&sampwd);
-
-       /* ok, it's a user.  find the user account */
-       become_root();
-       ret = pdb_getsampwrid(sampwd, rid);
-       unbecome_root();
-
-       if (ret == True) {
-               fstrcpy(user_name, pdb_get_username(sampwd) );
-               DEBUG(5,(" = %s\n", user_name));
-               pdb_free_sam(&sampwd);
-               return NT_STATUS_OK;
-       }
-
-       DEBUG(5,(" none mapped\n"));
-       pdb_free_sam(&sampwd);
-       return NT_STATUS_NONE_MAPPED;
-}
-
-#endif
-
-/*******************************************************************
- Look up a local (domain) group name and return a rid
- ********************************************************************/
-NTSTATUS local_lookup_group_rid(char *group_name, uint32 *rid)
-{
-       const char *grp_name;
-       int i = -1; /* start do loop at -1 */
-
-       do /* find, if it exists, a group rid for the group name*/
-       {
-               i++;
-               (*rid) = domain_group_rids[i].rid;
-               grp_name = domain_group_rids[i].name;
-
-       } while (grp_name != NULL && !strequal(grp_name, group_name));
-
-       return (grp_name != NULL) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED;
-}
-
-/*******************************************************************
- Look up a local (BUILTIN) alias name and return a rid
- ********************************************************************/
-NTSTATUS local_lookup_alias_rid(const char *alias_name, uint32 *rid)
-{
-       const char *als_name;
-       int i = -1; /* start do loop at -1 */
-
-       do /* find, if it exists, a alias rid for the alias name*/
-       {
-               i++;
-               (*rid) = builtin_alias_rids[i].rid;
-               als_name = builtin_alias_rids[i].name;
-
-       } while (als_name != NULL && !strequal(als_name, alias_name));
-
-       return (als_name != NULL) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED;
-}
-
-/*******************************************************************
- Look up a local user name and return a rid
- ********************************************************************/
-NTSTATUS local_lookup_user_rid(char *user_name, uint32 *rid)
-{
-       SAM_ACCOUNT *sampass=NULL;
-       BOOL ret;
-
-       (*rid) = 0;
-
-       pdb_init_sam(&sampass);
-
-       /* find the user account */
-       become_root();
-       ret = pdb_getsampwnam(sampass, user_name);
-       unbecome_root();
-
-       if (ret == True) {
-               (*rid) = pdb_get_user_rid(sampass);
-               pdb_free_sam(&sampass);
-               return NT_STATUS_OK;
-       }
-
-       pdb_free_sam(&sampass);
-       return NT_STATUS_NONE_MAPPED;
-}