From e7f365764627ec016fce484f71d1727d377b28dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lang=C3=A5s?= Date: Wed, 6 Mar 2002 02:28:27 +0000 Subject: [PATCH] index_priv funker i dbadm nuh --- mysql-dbadm.c | 22 +++--- pwyacc.c | 183 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 138 insertions(+), 67 deletions(-) diff --git a/mysql-dbadm.c b/mysql-dbadm.c index 6295fe1..17f412c 100644 --- a/mysql-dbadm.c +++ b/mysql-dbadm.c @@ -1,5 +1,5 @@ /* - * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.2 2002-02-27 08:49:48 knutpett Exp $ + * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.3 2002-03-06 02:28:27 tlan Exp $ * * mysql-dbadm.c * @@ -168,24 +168,24 @@ writeperm(FILE *f, MYSQL *pmysql, const char *db) MYSQL_ROW row; sprintf(query, "select user,select_priv,insert_priv,update_priv," - "delete_priv,create_priv,drop_priv,alter_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)) 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 Alter\n"); + "Select Insert Update Delete Create Drop Alter Index\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 %s\n", - row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7]); + 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]); } return 0; } @@ -215,7 +215,7 @@ editperm(MYSQL *pmysql, const char *db) 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, *alter_priv; + *create_priv, *drop_priv, *alter_priv, *index_priv; char query[1024]; /* used to build a query */ char *queries[MAX_GRANTS]; /* insert queries */ int lines; /* number of grant lines processed */ @@ -287,15 +287,17 @@ editperm(MYSQL *pmysql, const char *db) CHECK_PRIV(drop_priv); STRTOK_WHITESPACE(alter_priv, NULL); CHECK_PRIV(alter_priv); + STRTOK_WHITESPACE(index_priv, NULL); + CHECK_PRIV(index_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, alter_priv) values " - "('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", + "update_priv, delete_priv, create_priv, drop_priv, alter_priv, index_priv) values " + "('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", db, user, select_priv, insert_priv, update_priv, delete_priv, - create_priv, drop_priv, alter_priv); + create_priv, drop_priv, alter_priv, index_priv); queries[lines] = strdup(query); lines++; if (lines >= MAX_GRANTS) diff --git a/pwyacc.c b/pwyacc.c index 56df5bd..80c5cc6 100644 --- a/pwyacc.c +++ b/pwyacc.c @@ -1,15 +1,15 @@ /* A Bison parser, made from pwyacc.y - by GNU Bison version 1.25 + by GNU Bison version 1.27 */ #define YYBISON 1 /* Identify Bison output. */ -#define SET 258 -#define HOST 259 -#define USER 260 -#define PASSWORD 261 -#define STRING 262 +#define SET 257 +#define HOST 258 +#define USER 259 +#define PASSWORD 260 +#define STRING 261 #line 8 "pwyacc.y" @@ -33,7 +33,7 @@ int config_set_string_var(int var, const char *value); #define YYFLAG -32768 #define YYNTBASE 9 -#define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 12) +#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 12) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -61,8 +61,8 @@ static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, - 6, 7 + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7 }; #if YYDEBUG != 0 @@ -130,6 +130,7 @@ static const short yycheck[] = { 4, }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/store/share/bison.simple" +/* This file comes from bison-1.27. */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. @@ -146,47 +147,67 @@ static const short yycheck[] = { 4, You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) -#include -#else /* not sparc */ -#if defined (MSDOS) && !defined (__TURBOC__) -#include -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -#include - #pragma alloca -#else /* not MSDOS, __TURBOC__, or _AIX */ -#ifdef __hpux -#ifdef __cplusplus -extern "C" { -void *alloca (unsigned int); -}; -#else /* not __cplusplus */ -void *alloca (); -#endif /* not __cplusplus */ -#endif /* __hpux */ -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc. */ -#endif /* not GNU C. */ -#endif /* alloca not defined. */ - /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + /* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */ @@ -195,8 +216,8 @@ void *alloca (); #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 -#define YYACCEPT return(0) -#define YYABORT return(1) +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the @@ -277,12 +298,12 @@ int yydebug; /* nonzero means print parse trace */ #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -int yyparse (void); -#endif +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ @@ -294,7 +315,7 @@ static void __yy_memcpy (to, from, count) char *to; char *from; - int count; + unsigned int count; { register char *f = from; register char *t = to; @@ -309,10 +330,10 @@ __yy_memcpy (to, from, count) /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void -__yy_memcpy (char *to, char *from, int count) +__yy_memcpy (char *to, char *from, unsigned int count) { - register char *f = from; register char *t = to; + register char *f = from; register int i = count; while (i-- > 0) @@ -322,7 +343,7 @@ __yy_memcpy (char *to, char *from, int count) #endif #endif -#line 196 "/store/share/bison.simple" +#line 216 "/store/share/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. @@ -343,6 +364,15 @@ __yy_memcpy (char *to, char *from, int count) #define YYPARSE_PARAM_DECL #endif /* not YYPARSE_PARAM */ +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + int yyparse(YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL @@ -371,6 +401,7 @@ yyparse(YYPARSE_PARAM_ARG) #endif int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; #ifdef YYPURE int yychar; @@ -455,18 +486,32 @@ yynewstate: if (yystacksize >= YYMAXDEPTH) { yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } return 2; } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; - yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); - yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); #ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); #endif #endif /* no yyoverflow */ @@ -638,7 +683,7 @@ case 6: break;} } /* the action file gets copied in in place of this dollarsign */ -#line 498 "/store/share/bison.simple" +#line 542 "/store/share/bison.simple" yyvsp -= yylen; yyssp -= yylen; @@ -833,6 +878,30 @@ yyerrhandle: yystate = yyn; goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; } #line 32 "pwyacc.y"