#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
# include <malloc.h>
#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
#include <ctype.h>
-#include <dirent.h>
#include "sudo.h"
#include "parse.h"
#include <gram.h>
#define INSTR 5
-#line 1427 "lex.yy.c"
+#line 1442 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
register char *yy_cp, *yy_bp;
register int yy_act;
-#line 116 "toke.l"
+#line 131 "toke.l"
-#line 1583 "lex.yy.c"
+#line 1598 "lex.yy.c"
if ( yy_init )
{
case 1:
YY_RULE_SETUP
-#line 117 "toke.l"
+#line 132 "toke.l"
BEGIN STARTDEFS;
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 119 "toke.l"
+#line 134 "toke.l"
{
BEGIN INDEFS;
LEXTRACE("DEFVAR ");
case 3:
YY_RULE_SETUP
-#line 128 "toke.l"
+#line 143 "toke.l"
{
BEGIN STARTDEFS;
LEXTRACE(", ");
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 134 "toke.l"
+#line 149 "toke.l"
{
LEXTRACE("= ");
return('=');
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 139 "toke.l"
+#line 154 "toke.l"
{
LEXTRACE("+= ");
return('+');
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 144 "toke.l"
+#line 159 "toke.l"
{
LEXTRACE("-= ");
return('-');
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 149 "toke.l"
+#line 164 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 155 "toke.l"
+#line 170 "toke.l"
{
LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng))
case 9:
YY_RULE_SETUP
-#line 164 "toke.l"
+#line 179 "toke.l"
{
/* Line continuation char followed by newline. */
++sudolineno;
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 170 "toke.l"
+#line 185 "toke.l"
{
LEXTRACE("ENDSTR ");
BEGIN INDEFS;
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 176 "toke.l"
+#line 191 "toke.l"
{
LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng))
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 182 "toke.l"
+#line 197 "toke.l"
{
LEXTRACE("STRBODY ");
if (!append(yytext, yyleng))
case 13:
YY_RULE_SETUP
-#line 190 "toke.l"
+#line 205 "toke.l"
{
/* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 198 "toke.l"
+#line 213 "toke.l"
{
/* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 206 "toke.l"
+#line 221 "toke.l"
{
BEGIN INITIAL;
yyless(0);
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 212 "toke.l"
+#line 227 "toke.l"
{
LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace))
case 17:
YY_RULE_SETUP
-#line 220 "toke.l"
+#line 235 "toke.l"
{
char *path;
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 233 "toke.l"
+#line 248 "toke.l"
{
char *path;
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 246 "toke.l"
+#line 261 "toke.l"
{
int n;
for (n = 0; isblank((unsigned char)yytext[n]); n++)
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 275 "toke.l"
+#line 290 "toke.l"
{
int n;
for (n = 0; isblank((unsigned char)yytext[n]); n++)
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 295 "toke.l"
+#line 310 "toke.l"
{
/* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD ");
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 301 "toke.l"
+#line 316 "toke.l"
{
/* cmnd requires passwd for this user */
LEXTRACE("PASSWD ");
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 307 "toke.l"
+#line 322 "toke.l"
{
LEXTRACE("NOEXEC ");
return(NOEXEC);
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 312 "toke.l"
+#line 327 "toke.l"
{
LEXTRACE("EXEC ");
return(EXEC);
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 317 "toke.l"
+#line 332 "toke.l"
{
LEXTRACE("SETENV ");
return(SETENV);
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 322 "toke.l"
+#line 337 "toke.l"
{
LEXTRACE("NOSETENV ");
return(NOSETENV);
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 327 "toke.l"
+#line 342 "toke.l"
{
/* netgroup */
if (!fill(yytext, yyleng))
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 335 "toke.l"
+#line 350 "toke.l"
{
/* UN*X group */
if (!fill(yytext, yyleng))
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 343 "toke.l"
+#line 358 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 350 "toke.l"
+#line 365 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 357 "toke.l"
+#line 372 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 368 "toke.l"
+#line 383 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 379 "toke.l"
+#line 394 "toke.l"
{
if (strcmp(yytext, "ALL") == 0) {
LEXTRACE("ALL ");
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 401 "toke.l"
+#line 416 "toke.l"
{
/* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng))
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 409 "toke.l"
+#line 424 "toke.l"
{
BEGIN GOTCMND;
LEXTRACE("COMMAND ");
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 416 "toke.l"
+#line 431 "toke.l"
{
/* directories can't have args... */
if (yytext[yyleng - 1] == '/') {
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 431 "toke.l"
+#line 446 "toke.l"
{
/* a word */
if (!fill(yytext, yyleng))
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 439 "toke.l"
+#line 454 "toke.l"
{
LEXTRACE("( ");
return ('(');
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 444 "toke.l"
+#line 459 "toke.l"
{
LEXTRACE(") ");
return(')');
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 449 "toke.l"
+#line 464 "toke.l"
{
LEXTRACE(", ");
return(',');
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 454 "toke.l"
+#line 469 "toke.l"
{
LEXTRACE("= ");
return('=');
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 459 "toke.l"
+#line 474 "toke.l"
{
LEXTRACE(": ");
return(':');
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 464 "toke.l"
+#line 479 "toke.l"
{
if (yyleng % 2 == 1)
return('!'); /* return '!' */
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 469 "toke.l"
+#line 484 "toke.l"
{
BEGIN INITIAL;
++sudolineno;
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 476 "toke.l"
+#line 491 "toke.l"
{ /* throw away space/tabs */
sawspace = TRUE; /* but remember for fill_args */
}
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 480 "toke.l"
+#line 495 "toke.l"
{
sawspace = TRUE; /* remember for fill_args */
++sudolineno;
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 486 "toke.l"
+#line 501 "toke.l"
{
BEGIN INITIAL;
++sudolineno;
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 493 "toke.l"
+#line 508 "toke.l"
{
LEXTRACE("ERROR ");
return(ERROR);
case YY_STATE_EOF(STARTDEFS):
case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR):
-#line 498 "toke.l"
+#line 513 "toke.l"
{
if (YY_START != INITIAL) {
BEGIN INITIAL;
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 508 "toke.l"
+#line 523 "toke.l"
ECHO;
YY_BREAK
-#line 2214 "lex.yy.c"
+#line 2229 "lex.yy.c"
case YY_END_OF_BUFFER:
{
return 0;
}
#endif
-#line 508 "toke.l"
+#line 523 "toke.l"
static int
_fill(src, len, olen)
}
while ((dent = readdir(dir))) {
/* Ignore files that end in '~' or have a '.' in them. */
- if (dent->d_namlen == 0 || dent->d_name[dent->d_namlen - 1] == '~'
+ if (dent->d_name[0] == '\0' || dent->d_name[NAMLEN(dent) - 1] == '~'
|| strchr(dent->d_name, '.') != NULL) {
continue;
}
#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
# include <malloc.h>
#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
#include <ctype.h>
-#include <dirent.h>
#include "sudo.h"
#include "parse.h"
#include <gram.h>
}
while ((dent = readdir(dir))) {
/* Ignore files that end in '~' or have a '.' in them. */
- if (dent->d_namlen == 0 || dent->d_name[dent->d_namlen - 1] == '~'
+ if (dent->d_name[0] == '\0' || dent->d_name[NAMLEN(dent) - 1] == '~'
|| strchr(dent->d_name, '.') != NULL) {
continue;
}