v0.42 - Liten bugfiks som gjør det mulig å være medlem i grupper uten navn
uten at mysql-util'ene seg.faulter. :)
This commit is contained in:
31
common.c
31
common.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.3 2002-03-06 17:05:05 tlan Exp $
|
||||
* @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.4 2002-06-05 08:01:31 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.3 2002-03-06 17:05:05 tlan Exp $";
|
||||
static char *rcsheader = "@(#) " PACKAGE " " VERSION " ljosa@initio.no $Header: /tmp/cvs/mysql-admutils/common.c,v 1.4 2002-06-05 08:01:31 tlan Exp $";
|
||||
|
||||
|
||||
int
|
||||
@ -193,7 +193,7 @@ char **get_group_names(int *numgroups)
|
||||
{
|
||||
char **grouplist;
|
||||
gid_t gids[33];
|
||||
int nr_groups, i;
|
||||
int real_nr_groups, nr_groups, i;
|
||||
struct group *g;
|
||||
|
||||
nr_groups = 0;
|
||||
@ -204,16 +204,25 @@ char **get_group_names(int *numgroups)
|
||||
dberror(NULL, "Error while trying to fetch group info");
|
||||
return NULL;
|
||||
}
|
||||
*numgroups = nr_groups;
|
||||
|
||||
grouplist = malloc((nr_groups+1) * sizeof(char *));
|
||||
grouplist = malloc(sizeof(char *));
|
||||
real_nr_groups = 0;
|
||||
|
||||
for (i = 0; i < nr_groups; i++) {
|
||||
g = getgrgid(gids[i]);
|
||||
for (i = 0; i < nr_groups; i++) {
|
||||
g = getgrgid(gids[i]);
|
||||
|
||||
grouplist[i] = strdup(g->gr_name);
|
||||
}
|
||||
grouplist[i] = NULL;
|
||||
/* Go to next grp if it doesn't have a name */
|
||||
if (g != NULL) {
|
||||
grouplist = (char **) realloc(grouplist, (real_nr_groups+1) * sizeof(char *));
|
||||
grouplist[real_nr_groups] = strdup(g->gr_name);
|
||||
real_nr_groups++;
|
||||
} else {
|
||||
fprintf(stderr, "Omitting gid %d, no entry in group-file.\n", gids[i]);
|
||||
}
|
||||
}
|
||||
grouplist[real_nr_groups] = NULL;
|
||||
|
||||
*numgroups = real_nr_groups;
|
||||
|
||||
return grouplist;
|
||||
}
|
||||
@ -224,5 +233,3 @@ reload(MYSQL *pmysql)
|
||||
{
|
||||
return mysql_reload(pmysql);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user