beautifisering (2-space-indent), og tetting av minnehull

This commit is contained in:
Geir Hauge 2006-08-15 11:51:59 +00:00
parent 2e1453ceba
commit 5a1f013a31
2 changed files with 218 additions and 220 deletions

110
common.c
View File

@ -1,5 +1,5 @@
/* /*
* @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.7 2006-08-15 10:32:42 geirha Exp $ * @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.8 2006-08-15 11:51:58 geirha Exp $
* *
* functions used by mysql-dbadm.c and mysql-useradm.c * functions used by mysql-dbadm.c and mysql-useradm.c
* *
@ -22,7 +22,7 @@
char *program_name; char *program_name;
static char *rcsheader = "@(#) " PACKAGE " " VERSION " orakel@ntnu.no $Header: /tmp/cvs/mysql-admutils/common.c,v 1.7 2006-08-15 10:32:42 geirha Exp $"; static char *rcsheader = "@(#) " PACKAGE " " VERSION " orakel@ntnu.no $Header: /tmp/cvs/mysql-admutils/common.c,v 1.8 2006-08-15 11:51:58 geirha Exp $";
int int
@ -38,14 +38,13 @@ wrong_use(char *format, ...)
{ {
va_list ap; va_list ap;
if (format) if (format) {
{ fprintf(stderr, "%s: ", program_name);
fprintf(stderr, "%s: ", program_name); va_start(ap, format);
va_start(ap, format); vfprintf(stderr, format, ap);
vfprintf(stderr, format, ap); va_end(ap);
va_end(ap); putchar('\n');
putchar('\n'); }
}
fprintf(stderr, "Try `%s --help' for more information.\n", program_name); fprintf(stderr, "Try `%s --help' for more information.\n", program_name);
@ -66,14 +65,13 @@ dberror(MYSQL *pmysql, char *format, ...)
va_end(ap); va_end(ap);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
if (pmysql) if (pmysql) {
{ errmsg = mysql_error(pmysql);
errmsg = mysql_error(pmysql); if ((errmsg) && (strcmp(errmsg, "") != 0))
if ((errmsg) && (strcmp(errmsg, "") != 0)) fprintf(stderr, "mysql: %s\n", errmsg);
fprintf(stderr, "mysql: %s\n", errmsg);
mysql_close(pmysql); mysql_close(pmysql);
} }
return 1; return 1;
} }
@ -102,11 +100,10 @@ owner(char *name)
struct passwd *p; struct passwd *p;
p = getpwuid(getuid()); p = getpwuid(getuid());
if (!p) if (!p) {
{ dberror(NULL, "Failed to look up your UNIX username.");
dberror(NULL, "Failed to look up your UNIX username."); exit(1);
exit(1); }
}
if (strcmp(name, p->pw_name) == 0) if (strcmp(name, p->pw_name) == 0)
return 1; /* OK */ return 1; /* OK */
@ -182,8 +179,9 @@ member(char *gr) {
printf("You have access to '%s'\n", gr); printf("You have access to '%s'\n", gr);
#endif #endif
return 1; /* OK */ return 1; /* OK */
} else } else {
*g->gr_mem++; *g->gr_mem++;
}
} }
#if DEBUG #if DEBUG
printf("You have no access to '%s'\n", gr); printf("You have no access to '%s'\n", gr);
@ -192,15 +190,15 @@ member(char *gr) {
// brukeren var ikke med i gruppen, så vi må prøve neste. // brukeren var ikke med i gruppen, så vi må prøve neste.
// finner den siste _-en i navnet. // finner den siste _-en i navnet.
foo = strrchr(group, '_'); foo = strrchr(group, '_');
if (foo == NULL) { if (foo == NULL) {
// hvis vi har kommet helt til bunn, og fremdeles // hvis vi har kommet helt til bunn, og fremdeles
// ikke har blitt avbrutt, fantes det ingen slik gruppe. // ikke har blitt avbrutt, fantes det ingen slik gruppe.
return 0; return 0;
} }
// det som nå er bak siste underscore er passe uinteressant, så // det som nå er bak siste underscore er passe uinteressant, så
// vi flytter slutten av strengen litt framover. // vi flytter slutten av strengen litt framover.
*foo = '\0'; *foo = '\0';
} // while } // while
} }
@ -209,40 +207,40 @@ member(char *gr) {
/* numgroups is the total number of groups found */ /* numgroups is the total number of groups found */
char **get_group_names(int *numgroups) char **get_group_names(int *numgroups)
{ {
char **grouplist; char **grouplist;
gid_t gids[33]; gid_t gids[33];
int real_nr_groups, nr_groups, i; int real_nr_groups, nr_groups, i;
struct group *g; struct group *g;
nr_groups = 0; nr_groups = 0;
nr_groups = getgroups(32, &gids[0]); /* Allow a max of 32 groups */ nr_groups = getgroups(32, &gids[0]); /* Allow a max of 32 groups */
if (nr_groups == -1) { if (nr_groups == -1) {
dberror(NULL, "Error while trying to fetch group info"); dberror(NULL, "Error while trying to fetch group info");
return NULL; return NULL;
} }
grouplist = malloc(sizeof(char *)); grouplist = malloc(sizeof(char *));
real_nr_groups = 0; real_nr_groups = 0;
for (i = 0; i < nr_groups; i++) { for (i = 0; i < nr_groups; i++) {
g = getgrgid(gids[i]); g = getgrgid(gids[i]);
/* Go to next grp if it doesn't have a name */ /* Go to next grp if it doesn't have a name */
if (g != NULL) { if (g != NULL) {
grouplist = (char **) realloc(grouplist, (real_nr_groups+2) * sizeof(char *)); grouplist = (char **) realloc(grouplist, (real_nr_groups+2) * sizeof(char *));
grouplist[real_nr_groups] = strdup(g->gr_name); grouplist[real_nr_groups] = strdup(g->gr_name);
real_nr_groups++; real_nr_groups++;
} else { } else {
fprintf(stderr, "Omitting gid %d, no entry in group-file.\n", gids[i]); fprintf(stderr, "Omitting gid %d, no entry in group-file.\n", gids[i]);
} }
} }
grouplist[real_nr_groups] = NULL; grouplist[real_nr_groups] = NULL;
*numgroups = real_nr_groups; *numgroups = real_nr_groups;
return grouplist; return grouplist;
} }

View File

@ -1,5 +1,5 @@
/* /*
* @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.15 2006-08-15 10:32:42 geirha Exp $ * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.16 2006-08-15 11:51:59 geirha Exp $
* *
* mysql-dbadm.c * mysql-dbadm.c
* *
@ -20,14 +20,14 @@
/* New database names may only use these characters in their identifier */ /* New database names may only use these characters in their identifier */
const char dbname_validchars[] = const char dbname_validchars[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"; "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";
/* Returns true if dbname contains only characters in dbname_validchars. */ /* Returns true if dbname contains only characters in dbname_validchars. */
int dbname_isclean(char* dbname) { int dbname_isclean(char* dbname) {
int reallen, cleanlen; int reallen, cleanlen;
reallen = strlen(dbname); reallen = strlen(dbname);
cleanlen = strspn(dbname, dbname_validchars); cleanlen = strspn(dbname, dbname_validchars);
return (reallen == cleanlen); return (reallen == cleanlen);
} }
char * char *
@ -55,10 +55,8 @@ strtok_whitespace(char *s)
cp = strchr_whitespace(r); cp = strchr_whitespace(r);
if (cp == NULL) if (cp == NULL)
return r; return r;
while ((*cp == ' ') || (*cp == '\t')) while ((*cp == ' ') || (*cp == '\t'))
{ *cp++ = '\0';
*cp++ = '\0';
}
return r; return r;
} }
@ -105,14 +103,14 @@ create(MYSQL *pmysql, char *db)
// går jo dette vanligvis bra. // går jo dette vanligvis bra.
// finner ut om denne finnes fra før. // finner ut om denne finnes fra før.
if (!mysql_select_db(pmysql, db)) { if (!mysql_select_db(pmysql, db)) {
return dberror(pmysql, "Database '%s' already exists.", db); return dberror(pmysql, "Database '%s' already exists.", db);
} }
mysql_select_db(pmysql, "mysql"); mysql_select_db(pmysql, "mysql");
// oppretter databasen. // oppretter databasen.
char query[1024]; char query[1024];
sprintf(query, "create database `%s`", db); sprintf(query, "create database `%s`", db);
if (mysql_query(pmysql, query)) if (mysql_query(pmysql, query))
return dberror(pmysql, "Cannot create database '%s'.", db); return dberror(pmysql, "Cannot create database '%s'.", db);
fprintf(stderr, "Database '%s' created.\n", db); fprintf(stderr, "Database '%s' created.\n", db);
return 0; return 0;
} }
@ -128,8 +126,8 @@ drop(MYSQL *pmysql, char *db)
dberror(pmysql, "Failed to delete permissions for database '%s'.", db); dberror(pmysql, "Failed to delete permissions for database '%s'.", db);
if (mysql_select_db(pmysql, db)) { if (mysql_select_db(pmysql, db)) {
dberror(pmysql, "Database '%s' doesn't exists.", db); dberror(pmysql, "Database '%s' doesn't exists.", db);
return 0; return 0;
} }
mysql_select_db(pmysql, "mysql"); mysql_select_db(pmysql, "mysql");
@ -154,16 +152,15 @@ list(MYSQL *pmysql)
int i, counter; int i, counter;
struct passwd *p; struct passwd *p;
// variabler som brukes til å escape gruppenavnet til mysqlvennlig format. // variabler som brukes til å escape gruppenavnet til mysqlvennlig format.
char escaped_user[64]; char escaped_user[64];
char *cp_kopi; char *cp_kopi;
p = getpwuid(getuid()); p = getpwuid(getuid());
if (!p) if (!p) {
{ dberror(NULL, "Failed to lookup your UNIX username.");
dberror(NULL, "Failed to lookup your UNIX username."); exit(1);
exit(1); }
}
dblist = malloc(2 * sizeof(char*)); /* one for username (if used), rest is done below */ dblist = malloc(2 * sizeof(char*)); /* one for username (if used), rest is done below */
@ -174,7 +171,7 @@ list(MYSQL *pmysql)
cp = usr_groups; cp = usr_groups;
while (*cp) { // itererer over alle grupper en person er med i while (*cp) { // itererer over alle grupper en person er med i
if (*cp == NULL) if (*cp == NULL)
break; break;
#ifdef DEBUG #ifdef DEBUG
printf("cp er %s\n", *cp); printf("cp er %s\n", *cp);
@ -185,13 +182,13 @@ list(MYSQL *pmysql)
// itererer over bokstavene i gruppenavn, og escaper spesialtegn. // itererer over bokstavene i gruppenavn, og escaper spesialtegn.
for(i=0; i<=strlen(cp_kopi); i++) { for(i=0; i<=strlen(cp_kopi); i++) {
// hvis % _ , så skriv \ og så tegn // hvis % _ , så skriv \ og så tegn
if ((cp_kopi[i] == '_') || (cp_kopi[i] == '%')) { if ((cp_kopi[i] == '_') || (cp_kopi[i] == '%')) {
strcat(escaped_user, "\\"); strcat(escaped_user, "\\");
} }
escaped_user[strlen(escaped_user) + 1] = '\0'; escaped_user[strlen(escaped_user) + 1] = '\0';
escaped_user[strlen(escaped_user)] = cp_kopi[i]; escaped_user[strlen(escaped_user)] = cp_kopi[i];
} // for } // for
wild = malloc(strlen(escaped_user)+4); wild = malloc(strlen(escaped_user)+4);
@ -209,47 +206,51 @@ list(MYSQL *pmysql)
dblist = realloc(dblist, (numgroupdbs+2) * sizeof(char *)); dblist = realloc(dblist, (numgroupdbs+2) * sizeof(char *));
for (i = 0; i < rows; i++) for (i = 0; i < rows; i++) {
if ((row = mysql_fetch_row(res))) { if ((row = mysql_fetch_row(res))) {
dblist[counter++] = strdup(row[0]); dblist[counter++] = strdup(row[0]);
} }
}
} }
free(wild); free(wild);
free(res);
free(cp_kopi);
cp++; cp++;
} }
wild = malloc(strlen(p->pw_name) + 4); wild = malloc(strlen(p->pw_name) + 4);
sprintf(wild, "%s\\_%%", p->pw_name); sprintf(wild, "%s\\_%%", p->pw_name);
#ifdef DEBUG #ifdef DEBUG
printf("dbadm: wildcard: '%s'\n", wild); printf("dbadm: wildcard: '%s'\n", wild);
#endif #endif
res = mysql_list_dbs(pmysql, wild); res = mysql_list_dbs(pmysql, wild);
rows = mysql_num_rows(res); rows = mysql_num_rows(res);
dblist = realloc(dblist, (numgroupdbs+rows+2) * sizeof(char *)); dblist = realloc(dblist, (numgroupdbs+rows+2) * sizeof(char *));
if (!dblist) if (!dblist) {
{ dberror(NULL, "Out of memory.\n");
dberror(NULL, "Out of memory.\n"); free(wild);
free(wild); return NULL;
return NULL; }
}
for (i = 0; i < rows; i++) for (i = 0; i < rows; i++) {
if ((row = mysql_fetch_row(res))) if ((row = mysql_fetch_row(res))) {
{ dblist[counter++] = strdup(row[0]);
dblist[counter++] = strdup(row[0]); }
} }
res = mysql_list_dbs(pmysql, p->pw_name); res = mysql_list_dbs(pmysql, p->pw_name);
rows = mysql_num_rows(res); rows = mysql_num_rows(res);
if (rows == 1) if (rows == 1)
dblist[counter++] = strdup(p->pw_name); dblist[counter++] = strdup(p->pw_name);
dblist[counter] = NULL; dblist[counter] = NULL;
free(wild);
free(usr_groups);
return dblist; return dblist;
} }
@ -263,26 +264,27 @@ writeperm(FILE *f, MYSQL *pmysql, const char *db)
MYSQL_ROW row; MYSQL_ROW row;
sprintf(query, "select user,select_priv,insert_priv,update_priv," sprintf(query, "select user,select_priv,insert_priv,update_priv,"
"delete_priv,create_priv,drop_priv,alter_priv,index_priv from db where db='%s'", db); "delete_priv,create_priv,drop_priv,alter_priv,index_priv from db where db='%s'", db);
if (mysql_query(pmysql, query)) if (mysql_query(pmysql, query))
return dberror(pmysql, "Query for permissions failed."); return dberror(pmysql, "Query for permissions failed.");
res = mysql_store_result(pmysql); res = mysql_store_result(pmysql);
rows = mysql_num_rows(res); rows = mysql_num_rows(res);
fprintf(f, "# User " fprintf(f, "# User "
"Select Insert Update Delete Create Drop Alter Index\n"); "Select Insert Update Delete Create Drop Alter Index\n");
fprintf(f, "# ---------------- " fprintf(f, "# ---------------- "
"------ ------ ------ ------ ------ ---- ----- -----\n"); "------ ------ ------ ------ ------ ---- ----- -----\n");
if (rows == 0) if (rows == 0)
fprintf(f, "# (no permissions currently granted to any users)\n"); fprintf(f, "# (no permissions currently granted to any users)\n");
else else {
for (i = 0; i < rows; i++) for (i = 0; i < rows; i++) {
{ row = mysql_fetch_row(res);
row = mysql_fetch_row(res); fprintf(f, " %-16s %-7s %-7s %-7s %-7s %-7s %-7s %-7s %s\n",
fprintf(f, " %-16s %-7s %-7s %-7s %-7s %-7s %-7s %-7s %s\n", row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]);
row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]); }
} }
free(res);
return 0; return 0;
} }
@ -334,76 +336,74 @@ editperm(MYSQL *pmysql, const char *db)
strcpy(cmd, editor); strcpy(cmd, editor);
strcat(cmd, " "); strcat(cmd, " ");
strcat(cmd, fn); strcat(cmd, fn);
if (system(cmd) == -1) if (system(cmd) == -1) {
{ dberror(NULL, "Failed to execute '%s'\n", cmd);
dberror(NULL, "Failed to execute '%s'\n", cmd); perror("system");
perror("system"); return 1;
return 1; }
}
/* parse */ /* parse */
f = fopen(fn, "r"); f = fopen(fn, "r");
lines = 0; lines = 0;
while (fgets(line, sizeof(line), f)) while (fgets(line, sizeof(line), f)) {
{ cp = strchr(line, '\n');
cp = strchr(line, '\n'); if (cp)
if (cp) *cp = '\0';
*cp = '\0';
cp = line; cp = line;
while (*cp && ((*cp == ' ') || (*cp == '\t'))) cp++; while (*cp && ((*cp == ' ') || (*cp == '\t'))) cp++;
if (*cp == '\0') continue; if (*cp == '\0') continue;
if (*cp == '#') continue; if (*cp == '#') continue;
if (*cp == '\n') continue; if (*cp == '\n') continue;
#define STRTOK_WHITESPACE(res, start) \ #define STRTOK_WHITESPACE(res, start) \
{ if (!(res = strtok_whitespace(start))) continue; } { if (!(res = strtok_whitespace(start))) continue; }
STRTOK_WHITESPACE(user, cp); STRTOK_WHITESPACE(user, cp);
if (strlen(user) < 1) if (strlen(user) < 1)
return dberror(NULL, "Invalid user '%s' in grant line %d.", user, return dberror(NULL, "Invalid user '%s' in grant line %d.", user,
lines + 1); lines + 1);
if (strcmp(user, "%") == 0) if (strcmp(user, "%") == 0)
*user = '\0'; /* ugly, but it works... */ *user = '\0'; /* ugly, but it works... */
#define CHECK_PRIV(PRIV) \ #define CHECK_PRIV(PRIV) \
if (!valid_priv(PRIV)) return dberror(NULL, "Invalid value '%s' " \ if (!valid_priv(PRIV)) return dberror(NULL, "Invalid value '%s' " \
"in grant line %d.", PRIV, lines + 1) "in grant line %d.", PRIV, lines + 1)
STRTOK_WHITESPACE(select_priv, NULL); STRTOK_WHITESPACE(select_priv, NULL);
CHECK_PRIV(select_priv); CHECK_PRIV(select_priv);
STRTOK_WHITESPACE(insert_priv, NULL); STRTOK_WHITESPACE(insert_priv, NULL);
CHECK_PRIV(insert_priv); CHECK_PRIV(insert_priv);
STRTOK_WHITESPACE(update_priv, NULL); STRTOK_WHITESPACE(update_priv, NULL);
CHECK_PRIV(update_priv); CHECK_PRIV(update_priv);
STRTOK_WHITESPACE(delete_priv, NULL); STRTOK_WHITESPACE(delete_priv, NULL);
CHECK_PRIV(delete_priv); CHECK_PRIV(delete_priv);
STRTOK_WHITESPACE(create_priv, NULL); STRTOK_WHITESPACE(create_priv, NULL);
CHECK_PRIV(create_priv); CHECK_PRIV(create_priv);
STRTOK_WHITESPACE(drop_priv, NULL); STRTOK_WHITESPACE(drop_priv, NULL);
CHECK_PRIV(drop_priv); CHECK_PRIV(drop_priv);
STRTOK_WHITESPACE(alter_priv, NULL); STRTOK_WHITESPACE(alter_priv, NULL);
CHECK_PRIV(alter_priv); CHECK_PRIV(alter_priv);
STRTOK_WHITESPACE(index_priv, NULL); STRTOK_WHITESPACE(index_priv, NULL);
CHECK_PRIV(index_priv); CHECK_PRIV(index_priv);
#undef STRTOK_WHITESPACE #undef STRTOK_WHITESPACE
#undef CHECK_PRIV #undef CHECK_PRIV
sprintf(query, "insert into db (host, db, user, select_priv, insert_priv, " sprintf(query, "insert into db (host, db, user, select_priv, insert_priv, "
"update_priv, delete_priv, create_priv, drop_priv, alter_priv, index_priv) values " "update_priv, delete_priv, create_priv, drop_priv, alter_priv, index_priv) values "
"('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", "('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
db, user, select_priv, insert_priv, update_priv, delete_priv, db, user, select_priv, insert_priv, update_priv, delete_priv,
create_priv, drop_priv, alter_priv, index_priv); create_priv, drop_priv, alter_priv, index_priv);
queries[lines] = strdup(query); queries[lines] = strdup(query);
lines++; lines++;
if (lines >= MAX_GRANTS) if (lines >= MAX_GRANTS)
{ {
dberror(NULL, "Warning: Maximum of %d grants reached.\n", dberror(NULL, "Warning: Maximum of %d grants reached.\n",
MAX_GRANTS); MAX_GRANTS);
continue; continue;
} }
} /* while fgets ... */ } /* while fgets ... */
unlink(fn); unlink(fn);
fclose(f); fclose(f);
@ -416,14 +416,14 @@ editperm(MYSQL *pmysql, const char *db)
dberror(pmysql, "Failed to delete old grants for '%s'.", db); dberror(pmysql, "Failed to delete old grants for '%s'.", db);
for (i = 0; i < lines; i++) for (i = 0; i < lines; i++)
{ {
#ifdef DEBUG #ifdef DEBUG
puts(queries[i]); puts(queries[i]);
putchar('\n'); putchar('\n');
#endif #endif
if (mysql_query(pmysql, queries[i])) if (mysql_query(pmysql, queries[i]))
dberror(pmysql, "Failed to insert grant line %d.", i + 1); dberror(pmysql, "Failed to insert grant line %d.", i + 1);
} }
return 0; return 0;
} }
@ -480,60 +480,60 @@ main(int argc, char *argv[])
/* connect to the database server and select the mysql database */ /* connect to the database server and select the mysql database */
if (!mysql_real_connect(&mysql, db_server, db_user, db_passwd, db_name, 0, NULL, 0)) if (!mysql_real_connect(&mysql, db_server, db_user, db_passwd, db_name, 0, NULL, 0))
return dberror(&mysql, "Cannot connect to database server '%s'.", return dberror(&mysql, "Cannot connect to database server '%s'.",
db_server); db_server);
if (mysql_select_db(&mysql, db_name)) if (mysql_select_db(&mysql, db_name))
return dberror(&mysql, "Cannot select database '%s'.", db_name); return dberror(&mysql, "Cannot select database '%s'.", db_name);
if ((command == c_show) && (argc == 2)) if ((command == c_show) && (argc == 2)) {
{ dblist = list(&mysql);
dblist = list(&mysql); p = dblist;
p = dblist; while (*p) {
while (*p) show(&mysql, *p);
{ free(*p);
show(&mysql, *p); p++;
free(*p);
p++;
}
free(dblist);
} }
free(*p);
free(dblist);
}
else { else {
db = malloc(64); db = malloc(64);
/* for each supplied database name, perform the requested action */ /* for each supplied database name, perform the requested action */
for (i = 2; i < argc; i++) { for (i = 2; i < argc; i++) {
// HE HE // HE HE
strncpy(db, argv[i], 32); strncpy(db, argv[i], 32);
db[33] = '\0'; db[32] = '\0';
if (! (owner(db) || member(db))) { if (! (owner(db) || member(db))) {
dberror(NULL, "You are not the owner of '%s'. Skipping.", dberror(NULL, "You are not the owner of '%s'. Skipping.",
db); db);
continue; continue;
} }
switch (command) { switch (command) {
case c_create: case c_create:
// We only check newly created databases. Many old ("unclean") databases are still in use. // We only check newly created databases. Many old ("unclean") databases are still in use.
if(dbname_isclean(db)) { if(dbname_isclean(db)) {
create(&mysql, db); create(&mysql, db);
} else { } else {
dberror(NULL, "Database name '%s' contains invalid characters.\n" dberror(NULL, "Database name '%s' contains invalid characters.\n"
"Only A-Z, a-z, 0-9, _ (underscore) and - (dash) permitted. Skipping.", db); "Only A-Z, a-z, 0-9, _ (underscore) and - (dash) permitted. Skipping.", db);
} }
break; break;
case c_drop: case c_drop:
drop(&mysql, db); drop(&mysql, db);
break; break;
case c_editperm: case c_editperm:
editperm(&mysql, db); editperm(&mysql, db);
break; break;
case c_show: case c_show:
show(&mysql, db); show(&mysql, db);
break; break;
default: default:
return dberror(NULL, "This point should never be reached!"); return dberror(NULL, "This point should never be reached!");
} }
} // for } // for
} // else free(db);
} // else
mysql_reload(&mysql); mysql_reload(&mysql);
mysql_close(&mysql); mysql_close(&mysql);