From 05db606260ea15c3990870421276da70e56946a5 Mon Sep 17 00:00:00 2001 From: Lasse Karstensen Date: Tue, 8 Apr 2003 18:31:53 +0000 Subject: [PATCH] mysql-dbadm sanitychecks groupnames. configline updated with diff for static linking. y --- configline | 36 +++++++++++++++++++++++++- mysql-dbadm.c | 70 +++++++++++++++++++++++---------------------------- 2 files changed, 66 insertions(+), 40 deletions(-) diff --git a/configline b/configline index 614f7af..49f7a3f 100644 --- a/configline +++ b/configline @@ -5,6 +5,40 @@ vanlig, p vi burde kanskje komplisere med libmysqlclient statisk, sånn at vi slipper avhengigheter mot en spesiell rpmpakke. -$Id: configline,v 1.1 2003-04-07 16:23:25 lkarsten Exp $ + +elefant:~/mysql-admutils$ diff -u ../Makefile.org Makefile +--- ../Makefile.org Tue Apr 8 20:20:00 2003 ++++ Makefile Tue Apr 8 20:22:27 2003 +@@ -62,8 +62,8 @@ + LEX = flex + MAKEINFO = makeinfo + MYSQL_INCLUDE = -I/store/include/mysql +-MYSQL_LFLAGS = -L/store/lib/mysql +-MYSQL_LIBS = -lmysqlclient ++MYSQL_LFLAGS = ++MYSQL_LIBS = + PACKAGE = mysql-admutils + SYSCONFDIR = + VERSION = 0.43 +@@ -76,8 +76,8 @@ + BUILT_SOURCES = pwyacc.c pwyacc.h pwlex.c + YFLAGS = -d + INCLUDES = -I/store/include/mysql -DSYSCONFDIR=\"$(sysconfdir)\" +-LDADD = -lmysqlclient -lfl +-LDFLAGS = -L/store/lib/mysql ++LDADD = /store/lib/mysql/libmysqlclient.a -lfl ++LDFLAGS = + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 + mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs + CONFIG_HEADER = config.h + + + + + + + + +$Id: configline,v 1.2 2003-04-08 18:31:53 lkarsten Exp $ $Source: /tmp/cvs/mysql-admutils/configline,v $ diff --git a/mysql-dbadm.c b/mysql-dbadm.c index 1a087eb..6d299e1 100644 --- a/mysql-dbadm.c +++ b/mysql-dbadm.c @@ -1,5 +1,5 @@ /* - * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.10 2003-04-07 16:21:36 lkarsten Exp $ + * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.11 2003-04-08 18:31:53 lkarsten Exp $ * * mysql-dbadm.c * @@ -123,7 +123,10 @@ list(MYSQL *pmysql) char **dblist; int i, counter; struct passwd *p; - char *escaped_user; + +// variabler som brukes til å escape gruppenavnet til mysqlvennlig format. + char escaped_user[64]; + char *cp_kopi; p = getpwuid(getuid()); if (!p) @@ -139,48 +142,30 @@ list(MYSQL *pmysql) usr_groups = get_group_names(&numgroups); cp = usr_groups; - while (*cp) { -// ettersom _ og % er wildcards i sql, må vi escape -// eventuelle slike i gruppenavnet. "kall_s" f.eks, bør -// bli til "kall\_s" før det går til databasen. - int i, j; - char* user_start; - char* cp_kopi; - - cp_kopi = *cp; - - escaped_user = (char*)malloc(64 * sizeof(char)); - user_start = escaped_user; - + while (*cp) { // itererer over alle grupper en person er med i if (*cp == NULL) break; +#ifdef DEBUG printf("cp er %s\n", *cp); +#endif - for(i=j=0; i