of defeating gcc's warn_unused_result attribute.
iov[0].iov_len = 16;
/* Write message in a single syscall */
- (void) writev(sudo_debug_fd, iov, iovcnt);
+ ignore_result(writev(sudo_debug_fd, iov, iovcnt));
break;
}
}
# endif /* HAVE_ST_MTIMESPEC */
#endif /* HAVE_ST_MTIM */
+#ifdef __GNUC__
+# define ignore_result(x) do { \
+ __typeof__(x) y = (x); \
+ (void)y; \
+} while(0)
+#else
+# define ignore_result(x) (void)(x)
+#endif
+
/* GNU stow needs /etc/sudoers to be a symlink. */
#ifdef USE_STOW
# define stat_sudoers stat
static int
io_log_input(const char *buf, unsigned int len)
{
- fwrite(buf, len, 1, input);
+ ignore_result(fwrite(buf, len, 1, input));
return true;
}
static int
io_log_output(const char *buf, unsigned int len)
{
- fwrite(buf, len, 1, output);
+ ignore_result(fwrite(buf, len, 1, output));
return true;
}
#ifdef HAVE_ZLIB_H
if (iolog_compress)
- gzwrite(io_fds[idx].g, (const voidp)buf, len);
+ ignore_result(gzwrite(io_fds[idx].g, (const voidp)buf, len));
else
#endif
- fwrite(buf, 1, len, io_fds[idx].f);
+ ignore_result(fwrite(buf, 1, len, io_fds[idx].f));
delay.tv_sec = now.tv_sec;
delay.tv_usec = now.tv_usec;
timevalsub(&delay, &last_time);
return (n); \
} while (0)
+#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout))
+
#define push_include(_p) (_push_include((_p), false))
#define push_includedir(_p) (_push_include((_p), true))
#define YY_NO_INPUT 1
#define INSTR 5
-#line 1523 "lex.yy.c"
+#line 1525 "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 131 "toke.l"
+#line 133 "toke.l"
-#line 1679 "lex.yy.c"
+#line 1681 "lex.yy.c"
if ( yy_init )
{
case 1:
YY_RULE_SETUP
-#line 132 "toke.l"
+#line 134 "toke.l"
{
LEXTRACE(", ");
LEXRETURN(',');
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 137 "toke.l"
+#line 139 "toke.l"
BEGIN STARTDEFS;
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 139 "toke.l"
+#line 141 "toke.l"
{
BEGIN INDEFS;
LEXTRACE("DEFVAR ");
case 4:
YY_RULE_SETUP
-#line 148 "toke.l"
+#line 150 "toke.l"
{
BEGIN STARTDEFS;
LEXTRACE(", ");
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 154 "toke.l"
+#line 156 "toke.l"
{
LEXTRACE("= ");
LEXRETURN('=');
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 159 "toke.l"
+#line 161 "toke.l"
{
LEXTRACE("+= ");
LEXRETURN('+');
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 164 "toke.l"
+#line 166 "toke.l"
{
LEXTRACE("-= ");
LEXRETURN('-');
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 169 "toke.l"
+#line 171 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 176 "toke.l"
+#line 178 "toke.l"
{
LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng))
case 10:
YY_RULE_SETUP
-#line 185 "toke.l"
+#line 187 "toke.l"
{
/* Line continuation char followed by newline. */
sudolineno++;
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 191 "toke.l"
+#line 193 "toke.l"
{
LEXTRACE("ENDSTR ");
BEGIN prev_state;
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 223 "toke.l"
+#line 225 "toke.l"
{
LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng))
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 229 "toke.l"
+#line 231 "toke.l"
{
LEXTRACE("STRBODY ");
if (!append(yytext, yyleng))
case 14:
YY_RULE_SETUP
-#line 237 "toke.l"
+#line 239 "toke.l"
{
/* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 245 "toke.l"
+#line 247 "toke.l"
{
/* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR ");
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 253 "toke.l"
+#line 255 "toke.l"
{
BEGIN INITIAL;
yyless(0);
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 259 "toke.l"
+#line 261 "toke.l"
{
LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace))
case 18:
YY_RULE_SETUP
-#line 267 "toke.l"
+#line 269 "toke.l"
{
char *path;
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 285 "toke.l"
+#line 287 "toke.l"
{
char *path;
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 306 "toke.l"
+#line 308 "toke.l"
{
char deftype;
int n;
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 346 "toke.l"
+#line 348 "toke.l"
{
int n;
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 372 "toke.l"
+#line 374 "toke.l"
{
/* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD ");
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 378 "toke.l"
+#line 380 "toke.l"
{
/* cmnd requires passwd for this user */
LEXTRACE("PASSWD ");
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 384 "toke.l"
+#line 386 "toke.l"
{
LEXTRACE("NOEXEC ");
LEXRETURN(NOEXEC);
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 389 "toke.l"
+#line 391 "toke.l"
{
LEXTRACE("EXEC ");
LEXRETURN(EXEC);
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 394 "toke.l"
+#line 396 "toke.l"
{
LEXTRACE("SETENV ");
LEXRETURN(SETENV);
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 399 "toke.l"
+#line 401 "toke.l"
{
LEXTRACE("NOSETENV ");
LEXRETURN(NOSETENV);
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 404 "toke.l"
+#line 406 "toke.l"
{
LEXTRACE("LOG_OUTPUT ");
LEXRETURN(LOG_OUTPUT);
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 409 "toke.l"
+#line 411 "toke.l"
{
LEXTRACE("NOLOG_OUTPUT ");
LEXRETURN(NOLOG_OUTPUT);
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 414 "toke.l"
+#line 416 "toke.l"
{
LEXTRACE("LOG_INPUT ");
LEXRETURN(LOG_INPUT);
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 419 "toke.l"
+#line 421 "toke.l"
{
LEXTRACE("NOLOG_INPUT ");
LEXRETURN(NOLOG_INPUT);
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 424 "toke.l"
+#line 426 "toke.l"
{
/* empty group or netgroup */
LEXTRACE("ERROR ");
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 430 "toke.l"
+#line 432 "toke.l"
{
/* netgroup */
if (!fill(yytext, yyleng))
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 438 "toke.l"
+#line 440 "toke.l"
{
/* group */
if (!fill(yytext, yyleng))
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 446 "toke.l"
+#line 448 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 453 "toke.l"
+#line 455 "toke.l"
{
if (!fill(yytext, yyleng))
yyterminate();
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 460 "toke.l"
+#line 462 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 471 "toke.l"
+#line 473 "toke.l"
{
if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR ");
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 482 "toke.l"
+#line 484 "toke.l"
{
LEXTRACE("ALL ");
LEXRETURN(ALL);
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 488 "toke.l"
+#line 490 "toke.l"
{
#ifdef HAVE_SELINUX
LEXTRACE("ROLE ");
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 497 "toke.l"
+#line 499 "toke.l"
{
#ifdef HAVE_SELINUX
LEXTRACE("TYPE ");
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 506 "toke.l"
+#line 508 "toke.l"
{
#ifndef HAVE_SELINUX
got_alias:
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 516 "toke.l"
+#line 518 "toke.l"
{
/* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng))
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 524 "toke.l"
+#line 526 "toke.l"
{
BEGIN GOTCMND;
LEXTRACE("COMMAND ");
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 531 "toke.l"
+#line 533 "toke.l"
{
/* directories can't have args... */
if (yytext[yyleng - 1] == '/') {
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 546 "toke.l"
+#line 548 "toke.l"
{
LEXTRACE("BEGINSTR ");
yylval.string = NULL;
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 553 "toke.l"
+#line 555 "toke.l"
{
/* a word */
if (!fill(yytext, yyleng))
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 561 "toke.l"
+#line 563 "toke.l"
{
LEXTRACE("( ");
LEXRETURN('(');
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 566 "toke.l"
+#line 568 "toke.l"
{
LEXTRACE(") ");
LEXRETURN(')');
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 571 "toke.l"
+#line 573 "toke.l"
{
LEXTRACE(", ");
LEXRETURN(',');
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 576 "toke.l"
+#line 578 "toke.l"
{
LEXTRACE("= ");
LEXRETURN('=');
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 581 "toke.l"
+#line 583 "toke.l"
{
LEXTRACE(": ");
LEXRETURN(':');
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 586 "toke.l"
+#line 588 "toke.l"
{
if (yyleng & 1) {
LEXTRACE("!");
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 593 "toke.l"
+#line 595 "toke.l"
{
if (YY_START == INSTR) {
LEXTRACE("ERROR ");
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 605 "toke.l"
+#line 607 "toke.l"
{ /* throw away space/tabs */
sawspace = true; /* but remember for fill_args */
}
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 609 "toke.l"
+#line 611 "toke.l"
{
sawspace = true; /* remember for fill_args */
sudolineno++;
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 615 "toke.l"
+#line 617 "toke.l"
{
BEGIN INITIAL;
sudolineno++;
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 623 "toke.l"
+#line 625 "toke.l"
{
LEXTRACE("ERROR ");
LEXRETURN(ERROR);
case YY_STATE_EOF(STARTDEFS):
case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR):
-#line 628 "toke.l"
+#line 630 "toke.l"
{
if (YY_START != INITIAL) {
BEGIN INITIAL;
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 638 "toke.l"
+#line 640 "toke.l"
ECHO;
YY_BREAK
-#line 2455 "lex.yy.c"
+#line 2457 "lex.yy.c"
case YY_END_OF_BUFFER:
{
return 0;
}
#endif
-#line 638 "toke.l"
+#line 640 "toke.l"
struct path_list {
char *path;
return (n); \
} while (0)
+#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout))
+
#define push_include(_p) (_push_include((_p), false))
#define push_includedir(_p) (_push_include((_p), true))
%}
(void) unlink(sp->tpath);
if (!oldperms && fstat(sp->fd, &sb) != -1) {
if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID)
- (void) chown(sp->path, SUDOERS_UID, SUDOERS_GID);
+ ignore_result(chown(sp->path, SUDOERS_UID, SUDOERS_GID));
if ((sb.st_mode & 0777) != SUDOERS_MODE)
- (void) chmod(sp->path, SUDOERS_MODE);
+ ignore_result(chmod(sp->path, SUDOERS_MODE));
}
rval = true;
goto done;
#define emsg " exiting due to signal: "
myname = getprogname();
signame = strsignal(signo);
- if (write(STDERR_FILENO, myname, strlen(myname)) == -1 ||
- write(STDERR_FILENO, emsg, sizeof(emsg) - 1) == -1 ||
- write(STDERR_FILENO, signame, strlen(signame)) == -1 ||
- write(STDERR_FILENO, "\n", 1) == -1)
- /* shut up glibc */;
+ ignore_result(write(STDERR_FILENO, myname, strlen(myname)));
+ ignore_result(write(STDERR_FILENO, emsg, sizeof(emsg) - 1));
+ ignore_result(write(STDERR_FILENO, signame, strlen(signame)));
+ ignore_result(write(STDERR_FILENO, "\n", 1));
_exit(signo);
}
return val;
}
+typedef char * (*sudo_fn_getenv_t)(const char *);
+
char *
getenv(const char *name)
{
return NULL;
default: {
#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
- char * (*fn)(const char *);
+ sudo_fn_getenv_t fn;
- fn = dlsym(RTLD_NEXT, "getenv");
+ fn = (sudo_fn_getenv_t)dlsym(RTLD_NEXT, "getenv");
if (fn != NULL)
return fn(name);
#endif /* HAVE_DLOPEN && RTLD_NEXT */
return 0;
}
+typedef int (*sudo_fn_putenv_t)(PUTENV_CONST char *);
+
int
putenv(PUTENV_CONST char *string)
{
return -1;
default: {
#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
- int (*fn)(PUTENV_CONST char *);
+ sudo_fn_putenv_t fn;
- fn = dlsym(RTLD_NEXT, "putenv");
+ fn = (sudo_fn_putenv_t)dlsym(RTLD_NEXT, "putenv");
if (fn != NULL)
return fn(string);
#endif /* HAVE_DLOPEN && RTLD_NEXT */
return rpl_putenv(envstr);
}
+typedef int (*sudo_fn_setenv_t)(const char *, const char *, int);
+
int
setenv(const char *var, const char *val, int overwrite)
{
return -1;
default: {
#if defined(HAVE_SETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
- int (*fn)(const char *, const char *, int);
+ sudo_fn_setenv_t fn;
- fn = dlsym(RTLD_NEXT, "setenv");
+ fn = (sudo_fn_setenv_t)dlsym(RTLD_NEXT, "setenv");
if (fn != NULL)
return fn(var, val, overwrite);
#endif /* HAVE_SETENV && HAVE_DLOPEN && RTLD_NEXT */
#endif
}
+#ifdef UNSETENV_VOID
+typedef void (*sudo_fn_unsetenv_t)(const char *);
+#else
+typedef int (*sudo_fn_unsetenv_t)(const char *);
+#endif
+
#ifdef UNSETENV_VOID
void
unsetenv(const char *var)
return -1;
default: {
#if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
- void (*fn)(const char *);
+ sudo_fn_unsetenv_t fn;
- fn = dlsym(RTLD_NEXT, "unsetenv");
+ fn = (sudo_fn_unsetenv_t)dlsym(RTLD_NEXT, "unsetenv");
if (fn != NULL)
fn(var);
else
return -1;
default: {
#if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
- int (*fn)(const char *);
+ sudo_fn_unsetenv_t fn;
- fn = dlsym(RTLD_NEXT, "unsetenv");
+ fn = (sudo_fn_unsetenv_t)dlsym(RTLD_NEXT, "unsetenv");
if (fn != NULL)
return fn(var);
#endif /* HAVE_UNSETENV && HAVE_DLOPEN && RTLD_NEXT */
* The pipe is non-blocking, if we overflow the kernel's pipe
* buffer we drop the signal. This is not a problem in practice.
*/
- if (write(signal_pipe[1], &signo, sizeof(signo)) == -1)
- /* shut up glibc */;
+ ignore_result(write(signal_pipe[1], &signo, sizeof(signo)));
}
#ifdef SA_SIGINFO
* The pipe is non-blocking, if we overflow the kernel's pipe
* buffer we drop the signal. This is not a problem in practice.
*/
- if (write(signal_pipe[1], &signo, sizeof(signo)) == -1)
- /* shut up glibc */;
+ ignore_result(write(signal_pipe[1], &signo, sizeof(signo)));
}
}
#endif /* SA_SIGINFO */
io_fds[SFD_USERTTY] : STDOUT_FILENO;
if (write(n, reason, strlen(reason)) != -1) {
if (WCOREDUMP(cstat->val)) {
- if (write(n, " (core dumped)", 14) == -1)
- /* shut up glibc */;
+ ignore_result(write(n, " (core dumped)", 14));
}
- if (write(n, "\n", 1) == -1)
- /* shut up glibc */;
+ ignore_result(write(n, "\n", 1));
}
}
}
exec_pty(details, &errpipe[1]);
cstat.type = CMD_ERRNO;
cstat.val = errno;
- if (write(errpipe[1], &cstat, sizeof(cstat)) == -1)
- /* shut up glibc */;
+ ignore_result(write(errpipe[1], &cstat, sizeof(cstat)));
_exit(1);
}
close(errpipe[1]);
}
continue;
}
- if (write(fd, "*", 1) == -1)
- /* shut up glibc */;
+ ignore_result(write(fd, "*", 1));
}
*cp++ = c;
}