mysql-admutils/mysql-dbadm.patch
Knut Petter Svendsen ff52786682 With alter table patches and the undocumented feature for administering
mysql users and databases with same name as unix groups for the user.
2002-02-27 08:49:48 +00:00

72 lines
2.9 KiB
Diff

--- mysql/mysql-dbadm.c Wed Feb 2 20:51:53 2000
+++ src-0.3-local/mysql-dbadm.c Thu Feb 17 21:29:49 2000
@@ -168,24 +168,24 @@
MYSQL_ROW row;
sprintf(query, "select user,select_priv,insert_priv,update_priv,"
- "delete_priv,create_priv,drop_priv from db where db='%s'", db);
+ "delete_priv,create_priv,drop_priv,alter_priv from db where db='%s'", db);
if (mysql_query(pmysql, query))
return dberror(pmysql, "Query for permissions failed.");
res = mysql_store_result(pmysql);
rows = mysql_num_rows(res);
fprintf(f, "# User "
- "Select Insert Update Delete Create Drop\n");
+ "Select Insert Update Delete Create Drop Alter\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 %s\n",
- row[0], row[1], row[2], row[3], row[4], row[5], row[6]);
+ fprintf(f, " %-16s %-7s %-7s %-7s %-7s %-7s %-7s %s\n",
+ row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7]);
}
return 0;
}
@@ -215,7 +215,7 @@
char line[1024]; /* buffer to hold one line */
char *cp; /* used to interate through a line */
char *user, *select_priv, *insert_priv, *update_priv, *delete_priv,
- *create_priv, *drop_priv;
+ *create_priv, *drop_priv, *alter_priv;
char query[1024]; /* used to build a query */
char *queries[MAX_GRANTS]; /* insert queries */
int lines; /* number of grant lines processed */
@@ -285,15 +285,17 @@
CHECK_PRIV(create_priv);
STRTOK_WHITESPACE(drop_priv, NULL);
CHECK_PRIV(drop_priv);
+ STRTOK_WHITESPACE(alter_priv, NULL);
+ CHECK_PRIV(alter_priv);
#undef STRTOK_WHITESPACE
#undef CHECK_PRIV
sprintf(query, "insert into db (host, db, user, select_priv, insert_priv, "
- "update_priv, delete_priv, create_priv, drop_priv) values "
- "('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+ "update_priv, delete_priv, create_priv, drop_priv, alter_priv) values "
+ "('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
db, user, select_priv, insert_priv, update_priv, delete_priv,
- create_priv, drop_priv);
+ create_priv, drop_priv, alter_priv);
queries[lines] = strdup(query);
lines++;
if (lines >= MAX_GRANTS)
@@ -391,7 +393,7 @@
/* for each supplied database name, perform the requested action */
for (i = 2; i < argc; i++)
{
- if (! owner(argv[i]))
+ if (! (owner(argv[i]) || member(argv[i])))
{
dberror(NULL, "You are not the owner of '%s'. Skipping.",
argv[i]);