#include "sudo.h"
#include "parse.h"
#include "redblack.h"
+#include <gram.h>
#ifndef lint
__unused static const char rcsid[] = "$Sudo$";
a->seqno = 0;
list2tq(&a->members, members);
if (rbinsert(aliases, a)) {
- efree(a);
+ alias_free(a);
snprintf(errbuf, sizeof(errbuf), "Alias `%s' already defined", name);
return(errbuf);
}
{
struct alias *a = (struct alias *)v;
struct member *m;
+ struct sudo_command *c;
void *next;
+ efree(a->name);
for (m = a->members.first; m != NULL; m = next) {
next = m->next;
+ if (m->type == COMMAND) {
+ c = (struct sudo_command *) m->name;
+ efree(c->cmnd);
+ efree(c->args);
+ }
efree(m->name);
efree(m);
}
struct userspec *us;
struct privilege *priv;
struct cmndspec *cs;
+ struct sudo_command *c;
while ((us = tq_pop(&userspecs)) != NULL) {
while ((m = tq_pop(&us->users)) != NULL) {
efree(m);
}
}
+ if (cs->cmnd->type == COMMAND) {
+ c = (struct sudo_command *) cs->cmnd->name;
+ efree(c->cmnd);
+ efree(c->args);
+ }
efree(cs->cmnd->name);
efree(cs->cmnd);
efree(cs);
if (tq_last(&d->binding) != binding) {
binding = tq_last(&d->binding);
while ((m = tq_pop(&d->binding)) != NULL) {
+ if (m->type == COMMAND) {
+ c = (struct sudo_command *) m->name;
+ efree(c->cmnd);
+ efree(c->args);
+ }
efree(m->name);
efree(m);
}
sudolineno = 1;
verbose = !quiet;
}
-#line 745 "y.tab.c"
+#line 756 "y.tab.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
#if defined(__cplusplus) || defined(__STDC__)
static int yygrowstack(void)
yyval.member = new_member(yyvsp[0].string, WORD);
}
break;
-#line 1482 "y.tab.c"
+#line 1493 "y.tab.c"
}
yyssp -= yym;
yystate = *yyssp;
struct userspec *us;
struct privilege *priv;
struct cmndspec *cs;
+ struct sudo_command *c;
while ((us = tq_pop(&userspecs)) != NULL) {
while ((m = tq_pop(&us->users)) != NULL) {
efree(m);
}
}
+ if (cs->cmnd->type == COMMAND) {
+ c = (struct sudo_command *) cs->cmnd->name;
+ efree(c->cmnd);
+ efree(c->args);
+ }
efree(cs->cmnd->name);
efree(cs->cmnd);
efree(cs);
if (tq_last(&d->binding) != binding) {
binding = tq_last(&d->binding);
while ((m = tq_pop(&d->binding)) != NULL) {
+ if (m->type == COMMAND) {
+ c = (struct sudo_command *) m->name;
+ efree(c->cmnd);
+ efree(c->args);
+ }
efree(m->name);
efree(m);
}
int n;
for (n = 0; isblank((unsigned char)yytext[n]); n++)
continue;
- if (!fill(yytext + n, yyleng - n))
- yyterminate();
switch (yytext[n]) {
case 'H':
LEXTRACE("HOSTALIAS ");
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 279 "toke.l"
+#line 277 "toke.l"
{
/* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD ");
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 285 "toke.l"
+#line 283 "toke.l"
{
/* cmnd requires passwd for this user */
LEXTRACE("PASSWD ");
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 291 "toke.l"
+#line 289 "toke.l"
{
LEXTRACE("NOEXEC ");
return(NOEXEC);
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 296 "toke.l"
+#line 294 "toke.l"
{
LEXTRACE("EXEC ");
return(EXEC);
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 301 "toke.l"
+#line 299 "toke.l"
{
LEXTRACE("SETENV ");
return(SETENV);
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 306 "toke.l"
+#line 304 "toke.l"
{
LEXTRACE("NOSETENV ");
return(NOSETENV);
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 311 "toke.l"
+#line 309 "toke.l"
{
/* netgroup */
if (!fill(yytext, yyleng))
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 319 "toke.l"
+#line 317 "toke.l"
{
/* UN*X group */
if (!fill(yytext, yyleng))
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 327 "toke.l"
+#line 325 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 334 "toke.l"
+#line 332 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 341 "toke.l"
+#line 339 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 352 "toke.l"
+#line 350 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 363 "toke.l"
+#line 361 "toke.l"
{
if (strcmp(yytext, "ALL") == 0) {
LEXTRACE("ALL ");
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 385 "toke.l"
+#line 383 "toke.l"
{
/* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng))
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 393 "toke.l"
+#line 391 "toke.l"
{
BEGIN GOTCMND;
LEXTRACE("COMMAND ");
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 400 "toke.l"
+#line 398 "toke.l"
{
/* directories can't have args... */
if (yytext[yyleng - 1] == '/') {
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 415 "toke.l"
+#line 413 "toke.l"
{
/* a word */
if (!fill(yytext, yyleng))
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 423 "toke.l"
+#line 421 "toke.l"
{
LEXTRACE("( ");
return ('(');
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 428 "toke.l"
+#line 426 "toke.l"
{
LEXTRACE(") ");
return(')');
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 433 "toke.l"
+#line 431 "toke.l"
{
LEXTRACE(", ");
return(',');
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 438 "toke.l"
+#line 436 "toke.l"
{
LEXTRACE("= ");
return('=');
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 443 "toke.l"
+#line 441 "toke.l"
{
LEXTRACE(": ");
return(':');
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 448 "toke.l"
+#line 446 "toke.l"
{
if (yyleng % 2 == 1)
return('!'); /* return '!' */
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 453 "toke.l"
+#line 451 "toke.l"
{
BEGIN INITIAL;
++sudolineno;
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 460 "toke.l"
+#line 458 "toke.l"
{ /* throw away space/tabs */
sawspace = TRUE; /* but remember for fill_args */
}
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 464 "toke.l"
+#line 462 "toke.l"
{
sawspace = TRUE; /* remember for fill_args */
++sudolineno;
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 470 "toke.l"
+#line 468 "toke.l"
{
BEGIN INITIAL;
++sudolineno;
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 477 "toke.l"
+#line 475 "toke.l"
{
LEXTRACE("ERROR ");
return(ERROR);
case YY_STATE_EOF(STARTDEFS):
case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR):
-#line 482 "toke.l"
+#line 480 "toke.l"
{
if (YY_START != INITIAL) {
BEGIN INITIAL;
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 492 "toke.l"
+#line 490 "toke.l"
ECHO;
YY_BREAK
-#line 2183 "lex.yy.c"
+#line 2181 "lex.yy.c"
case YY_END_OF_BUFFER:
{
return 0;
}
#endif
-#line 492 "toke.l"
+#line 490 "toke.l"
static int
_fill(src, len, olen)
int n;
for (n = 0; isblank((unsigned char)yytext[n]); n++)
continue;
- if (!fill(yytext + n, yyleng - n))
- yyterminate();
switch (yytext[n]) {
case 'H':
LEXTRACE("HOSTALIAS ");