diff --git a/mysql-dbadm.c b/mysql-dbadm.c index b237b2b..a7cb667 100644 --- a/mysql-dbadm.c +++ b/mysql-dbadm.c @@ -98,16 +98,17 @@ usage_editperm() printf("Lines starting with # are ignored.\n"); printf("\n"); printf("The Y/N-values corresponds to the following mysql privileges:\n"); - printf(" Select - Enables use of SELECT\n"); - printf(" Insert - Enables use of INSERT\n"); - printf(" Update - Enables use of UPDATE\n"); - printf(" Delete - Enables use of DELETE\n"); - printf(" Create - Enables use of CREATE TABLE\n"); - printf(" Drop - Enables use of DROP TABLE\n"); - printf(" Alter - Enables use of ALTER TABLE\n"); - printf(" Index - Enables use of CREATE INDEX and DROP INDEX\n"); - printf(" Temp - Enables use of CREATE TEMPORARY TABLE\n"); - printf(" Lock - Enables use of LOCK TABLE\n"); + printf(" Select - Enables use of SELECT\n"); + printf(" Insert - Enables use of INSERT\n"); + printf(" Update - Enables use of UPDATE\n"); + printf(" Delete - Enables use of DELETE\n"); + printf(" Create - Enables use of CREATE TABLE\n"); + printf(" Drop - Enables use of DROP TABLE\n"); + printf(" Alter - Enables use of ALTER TABLE\n"); + printf(" Index - Enables use of CREATE INDEX and DROP INDEX\n"); + printf(" Temp - Enables use of CREATE TEMPORARY TABLE\n"); + printf(" Lock - Enables use of LOCK TABLE\n"); + printf(" References - Enables use of REFERENCES\n"); printf("\n"); printf("Report bugs to orakel@ntnu.no\n"); return 0; @@ -309,7 +310,8 @@ writeperm(FILE *f, MYSQL *pmysql, const char *db) end = strmov(query, "SELECT user,select_priv,insert_priv,update_priv," "delete_priv,create_priv,drop_priv," "alter_priv,index_priv," - "create_tmp_table_priv,lock_tables_priv " + "create_tmp_table_priv,lock_tables_priv," + "References_priv " "FROM db WHERE db = '"); end += mysql_real_escape_string(pmysql, end, db, strlen(db)); *end++ = '\''; @@ -324,18 +326,18 @@ writeperm(FILE *f, MYSQL *pmysql, const char *db) rows = mysql_num_rows(res); fprintf(f, "# User " "Select Insert Update Delete Create Drop Alter Index " - " Temp Lock\n"); + " Temp Lock References\n"); fprintf(f, "# ---------------- " "------ ------ ------ ------ ------ ---- ----- ----- " - " ---- ----\n"); + " ---- ---- ----------\n"); if (rows == 0) fprintf(f, "# (no permissions currently granted to any users)\n"); else { for (i = 0; i < rows; i++) { row = mysql_fetch_row(res); - fprintf(f, " %-16s %-7s %-7s %-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[9], row[10]); + fprintf(f, " %-16s %-7s %-7s %-7s %-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[9], row[10], row[11]); } } mysql_free_result(res); @@ -368,7 +370,7 @@ editperm(MYSQL *pmysql, const char *db) char *cp; /* used to interate through a line */ char *user, *select_priv, *insert_priv, *update_priv, *delete_priv, *create_priv, *drop_priv, *alter_priv, *index_priv, *create_tmp_table_priv, - *lock_tables_priv; + *lock_tables_priv, *References_priv; char query[4096], *end; /* used to build a query */ char *queries[MAX_GRANTS]; /* insert queries */ int lines; /* number of grant lines processed */ @@ -484,6 +486,8 @@ editperm(MYSQL *pmysql, const char *db) CHECK_PRIV(create_tmp_table_priv); STRTOK_WHITESPACE(lock_tables_priv, NULL); CHECK_PRIV(lock_tables_priv); + STRTOK_WHITESPACE(References_priv, NULL); + CHECK_PRIV(References_priv); #undef STRTOK_WHITESPACE #undef CHECK_PRIV @@ -492,7 +496,8 @@ editperm(MYSQL *pmysql, const char *db) "host,db,user,select_priv,insert_priv," "update_priv,delete_priv,create_priv," "drop_priv,alter_priv,index_priv," - "create_tmp_table_priv,lock_tables_priv" + "create_tmp_table_priv,lock_tables_priv," + "References_priv" ") VALUES ("); end = strmov(end, "'%'"); @@ -516,6 +521,7 @@ editperm(MYSQL *pmysql, const char *db) APPEND(index_priv); APPEND(create_tmp_table_priv); APPEND(lock_tables_priv); + APPEND(References_priv); *end++ = ')'; *end = '\0';