fiks triks
This commit is contained in:
parent
e237f94b3f
commit
3a55d01113
|
@ -283,7 +283,6 @@ distdir: $(DISTFILES)
|
||||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||||
|| cp -p $$d/$$file $(distdir)/$$file; \
|
|| cp -p $$d/$$file $(distdir)/$$file; \
|
||||||
done
|
done
|
||||||
|
|
||||||
info:
|
info:
|
||||||
dvi:
|
dvi:
|
||||||
check: all
|
check: all
|
||||||
|
|
86
common.patch
86
common.patch
|
@ -1,86 +0,0 @@
|
||||||
--- mysql/common.c Wed Feb 2 22:59:21 2000
|
|
||||||
+++ src-0.3-local/common.c Thu Feb 17 21:20:24 2000
|
|
||||||
@@ -17,6 +17,7 @@
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
+#include <grp.h>
|
|
||||||
#include "mysql-admutils.h"
|
|
||||||
|
|
||||||
char *program_name;
|
|
||||||
@@ -115,6 +116,75 @@
|
|
||||||
return 1; /* OK */
|
|
||||||
|
|
||||||
return 0; /* not owner if we get as far as this */
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Decides if the user is member of a group. The Unix group can't contain any
|
|
||||||
+ * '_'. i.e 'fidi_s' won't be accepted.
|
|
||||||
+ */
|
|
||||||
+int
|
|
||||||
+member(char *gr) {
|
|
||||||
+ char *username;
|
|
||||||
+
|
|
||||||
+ char *group;
|
|
||||||
+ struct group *g;
|
|
||||||
+
|
|
||||||
+ struct passwd *p;
|
|
||||||
+ char *foo;
|
|
||||||
+
|
|
||||||
+ /* size_t i = 0; */
|
|
||||||
+
|
|
||||||
+ /* Get username */
|
|
||||||
+ p = getpwuid(getuid());
|
|
||||||
+ if (!p) {
|
|
||||||
+ fprintf(stderr, "Failed to look up your UNIX username.");
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
+ username = p->pw_name;
|
|
||||||
+
|
|
||||||
+ /* Copy string, but cut at '_' */
|
|
||||||
+ group = strdup(gr);
|
|
||||||
+ if (group == NULL) {
|
|
||||||
+ fprintf(stderr, "Couldn't allocate memory. Terminating.");
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ foo = strchr(group, '_');
|
|
||||||
+ if (foo) {
|
|
||||||
+#if DEBUG
|
|
||||||
+ printf("gr = %s, group = %s, foo = %s\n", gr, group, foo);
|
|
||||||
+#endif
|
|
||||||
+ *foo = '\0';
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* Get group */
|
|
||||||
+ g = getgrnam(group);
|
|
||||||
+ if (g == NULL) {
|
|
||||||
+ fprintf(stderr, "No such group: %s\n", group);
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* Check if user is member of group */
|
|
||||||
+ while(*g->gr_mem != NULL) {
|
|
||||||
+ char * member = *g->gr_mem;
|
|
||||||
+#if DEBUG
|
|
||||||
+ printf("Medlem: %s\n", *g->gr_mem);
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+ if (strcmp(member,username) == 0) {
|
|
||||||
+#if DEBUG
|
|
||||||
+ printf("You have access to '%s'\n", gr);
|
|
||||||
+#endif
|
|
||||||
+ return 1; /* OK */
|
|
||||||
+ } else
|
|
||||||
+ *g->gr_mem++;
|
|
||||||
+ }
|
|
||||||
+#if DEBUG
|
|
||||||
+ printf("You have no access to '%s'\n", gr);
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -702,7 +702,7 @@ fi
|
||||||
|
|
||||||
PACKAGE=mysql-admutils
|
PACKAGE=mysql-admutils
|
||||||
|
|
||||||
VERSION=0.3
|
VERSION=0.4
|
||||||
|
|
||||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||||
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
|
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
AC_INIT(mysql-dbadm.c)
|
AC_INIT(mysql-dbadm.c)
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
AM_INIT_AUTOMAKE(mysql-admutils, 0.3)
|
AM_INIT_AUTOMAKE(mysql-admutils, 0.4)
|
||||||
AM_SANITY_CHECK
|
AM_SANITY_CHECK
|
||||||
|
|
||||||
dnl Checks for programs.
|
dnl Checks for programs.
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
--- 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]);
|
|
|
@ -1,11 +0,0 @@
|
||||||
--- mysql/mysql-useradm.c Wed Feb 2 20:51:53 2000
|
|
||||||
+++ src-0.3-local/mysql-useradm.c Thu Feb 17 21:22:31 2000
|
|
||||||
@@ -269,7 +269,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]);
|
|
Loading…
Reference in New Issue