Flyttet noe kode inn i common.c

Nå kan man også se alle brukere som gruppene man er medlem i, har
This commit is contained in:
2002-03-06 17:05:05 +00:00
parent fe7ad3f488
commit e237f94b3f
4 changed files with 52 additions and 38 deletions

@ -1,5 +1,5 @@
/*
* @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.2 2002-02-27 08:49:48 knutpett Exp $
* @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.3 2002-03-06 17:05:05 tlan Exp $
*
* functions used by mysql-dbadm.c and mysql-useradm.c
*
@ -22,7 +22,7 @@
char *program_name;
static char *rcsheader = "@(#) " PACKAGE " " VERSION " ljosa@initio.no $Header: /tmp/cvs/mysql-admutils/common.c,v 1.2 2002-02-27 08:49:48 knutpett Exp $";
static char *rcsheader = "@(#) " PACKAGE " " VERSION " ljosa@initio.no $Header: /tmp/cvs/mysql-admutils/common.c,v 1.3 2002-03-06 17:05:05 tlan Exp $";
int
@ -187,6 +187,37 @@ member(char *gr) {
}
/* return a list of the user's groupnames */
/* numgroups is the total number of groups found */
char **get_group_names(int *numgroups)
{
char **grouplist;
gid_t gids[33];
int nr_groups, i;
struct group *g;
nr_groups = 0;
nr_groups = getgroups(32, &gids[0]); /* Allow a max of 32 groups */
if (nr_groups == -1) {
dberror(NULL, "Error while trying to fetch group info");
return NULL;
}
*numgroups = nr_groups;
grouplist = malloc((nr_groups+1) * sizeof(char *));
for (i = 0; i < nr_groups; i++) {
g = getgrgid(gids[i]);
grouplist[i] = strdup(g->gr_name);
}
grouplist[i] = NULL;
return grouplist;
}
int
reload(MYSQL *pmysql)