Quiet gcc warnings on glibc systems that use warn_unused_result for
write(2) and others.
This commit is contained in:
@@ -216,7 +216,8 @@ update_timestamp(char *timestampdir, char *timestampfile)
|
|||||||
log_error(NO_EXIT|USE_ERRNO, "Can't open %s", timestampfile);
|
log_error(NO_EXIT|USE_ERRNO, "Can't open %s", timestampfile);
|
||||||
else {
|
else {
|
||||||
lock_file(fd, SUDO_LOCK);
|
lock_file(fd, SUDO_LOCK);
|
||||||
write(fd, &tty_info, sizeof(tty_info));
|
if (write(fd, &tty_info, sizeof(tty_info)) != sizeof(tty_info))
|
||||||
|
log_error(NO_EXIT|USE_ERRNO, "Can't write %s", timestampfile);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -452,7 +452,8 @@ send_mail(const char *fmt, ...)
|
|||||||
/* Daemonize - disassociate from session/tty. */
|
/* Daemonize - disassociate from session/tty. */
|
||||||
if (setsid() == -1)
|
if (setsid() == -1)
|
||||||
warning("setsid");
|
warning("setsid");
|
||||||
(void) chdir("/");
|
if (chdir("/") == -1)
|
||||||
|
warning("chdir(/)");
|
||||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0644)) != -1) {
|
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0644)) != -1) {
|
||||||
(void) dup2(fd, STDIN_FILENO);
|
(void) dup2(fd, STDIN_FILENO);
|
||||||
(void) dup2(fd, STDOUT_FILENO);
|
(void) dup2(fd, STDOUT_FILENO);
|
||||||
|
@@ -312,9 +312,12 @@ main(int argc, char *argv[])
|
|||||||
error(1, "unable to open %s", path);
|
error(1, "unable to open %s", path);
|
||||||
cp = NULL;
|
cp = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
getline(&cp, &len, lfile); /* log */
|
/* Pull out command (third line). */
|
||||||
getline(&cp, &len, lfile); /* cwd */
|
if (getline(&cp, &len, lfile) == -1 ||
|
||||||
getline(&cp, &len, lfile); /* command */
|
getline(&cp, &len, lfile) == -1 ||
|
||||||
|
getline(&cp, &len, lfile) == -1) {
|
||||||
|
error(1, "invalid log file %s", path);
|
||||||
|
}
|
||||||
printf("Replaying sudo session: %s", cp);
|
printf("Replaying sudo session: %s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
fclose(lfile);
|
fclose(lfile);
|
||||||
|
@@ -290,7 +290,8 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
|
|||||||
/* Add missing newline at EOF if needed. */
|
/* Add missing newline at EOF if needed. */
|
||||||
if (nread > 0 && buf[nread - 1] != '\n') {
|
if (nread > 0 && buf[nread - 1] != '\n') {
|
||||||
buf[0] = '\n';
|
buf[0] = '\n';
|
||||||
write(tfd, buf, 1);
|
if (write(tfd, buf, 1) != 1)
|
||||||
|
error(1, "write error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) close(tfd);
|
(void) close(tfd);
|
||||||
@@ -483,8 +484,14 @@ install_sudoers(struct sudoersfile *sp, int oldperms)
|
|||||||
if (stat(sp->path, &sb) == -1)
|
if (stat(sp->path, &sb) == -1)
|
||||||
#endif
|
#endif
|
||||||
error(1, "can't stat %s", sp->path);
|
error(1, "can't stat %s", sp->path);
|
||||||
(void) chown(sp->tpath, sb.st_uid, sb.st_gid);
|
if (chown(sp->tpath, sb.st_uid, sb.st_gid) != 0) {
|
||||||
(void) chmod(sp->tpath, sb.st_mode & 0777);
|
warning("unable to set (uid, gid) of %s to (%d, %d)",
|
||||||
|
sp->tpath, sb.st_uid, sb.st_gid);
|
||||||
|
}
|
||||||
|
if (chmod(sp->tpath, sb.st_mode & 0777) != 0) {
|
||||||
|
warning("unable to change mode of %s to 0%o", sp->tpath,
|
||||||
|
(sb.st_mode & 0777));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (chown(sp->tpath, SUDOERS_UID, SUDOERS_GID) != 0) {
|
if (chown(sp->tpath, SUDOERS_UID, SUDOERS_GID) != 0) {
|
||||||
warning("unable to set (uid, gid) of %s to (%d, %d)",
|
warning("unable to set (uid, gid) of %s to (%d, %d)",
|
||||||
@@ -1143,8 +1150,9 @@ quit(int signo)
|
|||||||
{
|
{
|
||||||
cleanup(signo);
|
cleanup(signo);
|
||||||
#define emsg " exiting due to signal.\n"
|
#define emsg " exiting due to signal.\n"
|
||||||
write(STDERR_FILENO, getprogname(), strlen(getprogname()));
|
if (write(STDERR_FILENO, getprogname(), strlen(getprogname())) == -1 ||
|
||||||
write(STDERR_FILENO, emsg, sizeof(emsg) - 1);
|
write(STDERR_FILENO, emsg, sizeof(emsg) - 1) == -1)
|
||||||
|
/* shut up glibc */;
|
||||||
_exit(signo);
|
_exit(signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -639,10 +639,14 @@ pty_close(struct command_status *cstat)
|
|||||||
const char *reason = strsignal(signo);
|
const char *reason = strsignal(signo);
|
||||||
n = io_fds[SFD_USERTTY] != -1 ?
|
n = io_fds[SFD_USERTTY] != -1 ?
|
||||||
io_fds[SFD_USERTTY] : STDOUT_FILENO;
|
io_fds[SFD_USERTTY] : STDOUT_FILENO;
|
||||||
write(n, reason, strlen(reason));
|
if (write(n, reason, strlen(reason)) != -1) {
|
||||||
if (WCOREDUMP(cstat->val))
|
if (WCOREDUMP(cstat->val)) {
|
||||||
write(n, " (core dumped)", 14);
|
if (write(n, " (core dumped)", 14) == -1)
|
||||||
write(n, "\n", 1);
|
/* shut up glibc */;
|
||||||
|
}
|
||||||
|
if (write(n, "\n", 1) == -1)
|
||||||
|
/* shut up glibc */;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -875,7 +879,8 @@ exec_monitor(struct command_details *details, char *argv[], char *envp[],
|
|||||||
exec_pty(details, argv, envp);
|
exec_pty(details, argv, envp);
|
||||||
cstat.type = CMD_ERRNO;
|
cstat.type = CMD_ERRNO;
|
||||||
cstat.val = errno;
|
cstat.val = errno;
|
||||||
write(errpipe[1], &cstat, sizeof(cstat));
|
if (write(errpipe[1], &cstat, sizeof(cstat)) == -1)
|
||||||
|
/* shut up glibc */;
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
close(errpipe[1]);
|
close(errpipe[1]);
|
||||||
|
@@ -67,7 +67,8 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
|
|||||||
|
|
||||||
if (openpty(master, slave, name, NULL, NULL) != 0)
|
if (openpty(master, slave, name, NULL, NULL) != 0)
|
||||||
return(0);
|
return(0);
|
||||||
(void) chown(name, ttyuid, ttygid);
|
if (chown(name, ttyuid, ttygid) != 0)
|
||||||
|
return(0);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -150,8 +150,10 @@ restart:
|
|||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
(void) sigaction(SIGPIPE, &sa, &savepipe);
|
(void) sigaction(SIGPIPE, &sa, &savepipe);
|
||||||
|
|
||||||
if (prompt)
|
if (prompt) {
|
||||||
(void) write(output, prompt, strlen(prompt));
|
if (write(output, prompt, strlen(prompt)) == -1)
|
||||||
|
goto restore;
|
||||||
|
}
|
||||||
|
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
alarm(timeout);
|
alarm(timeout);
|
||||||
@@ -159,9 +161,12 @@ restart:
|
|||||||
alarm(0);
|
alarm(0);
|
||||||
save_errno = errno;
|
save_errno = errno;
|
||||||
|
|
||||||
if (neednl || pass == NULL)
|
if (neednl || pass == NULL) {
|
||||||
(void) write(output, "\n", 1);
|
if (write(output, "\n", 1) == -1)
|
||||||
|
goto restore;
|
||||||
|
}
|
||||||
|
|
||||||
|
restore:
|
||||||
/* Restore old tty settings and signals. */
|
/* Restore old tty settings and signals. */
|
||||||
if (!ISSET(flags, TGP_ECHO))
|
if (!ISSET(flags, TGP_ECHO))
|
||||||
term_restore(input, 1);
|
term_restore(input, 1);
|
||||||
@@ -277,20 +282,23 @@ getln(int fd, char *buf, size_t bufsiz, int feedback)
|
|||||||
if (feedback) {
|
if (feedback) {
|
||||||
if (c == term_kill) {
|
if (c == term_kill) {
|
||||||
while (cp > buf) {
|
while (cp > buf) {
|
||||||
(void) write(fd, "\b \b", 3);
|
if (write(fd, "\b \b", 3) == -1)
|
||||||
|
break;
|
||||||
--cp;
|
--cp;
|
||||||
}
|
}
|
||||||
left = bufsiz;
|
left = bufsiz;
|
||||||
continue;
|
continue;
|
||||||
} else if (c == term_erase) {
|
} else if (c == term_erase) {
|
||||||
if (cp > buf) {
|
if (cp > buf) {
|
||||||
(void) write(fd, "\b \b", 3);
|
if (write(fd, "\b \b", 3) == -1)
|
||||||
|
break;
|
||||||
--cp;
|
--cp;
|
||||||
left++;
|
left++;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
(void) write(fd, "*", 1);
|
if (write(fd, "*", 1) == -1)
|
||||||
|
/* shut up glibc */;
|
||||||
}
|
}
|
||||||
*cp++ = c;
|
*cp++ = c;
|
||||||
}
|
}
|
||||||
@@ -298,7 +306,8 @@ getln(int fd, char *buf, size_t bufsiz, int feedback)
|
|||||||
if (feedback) {
|
if (feedback) {
|
||||||
/* erase stars */
|
/* erase stars */
|
||||||
while (cp > buf) {
|
while (cp > buf) {
|
||||||
(void) write(fd, "\b \b", 3);
|
if (write(fd, "\b \b", 3) == -1)
|
||||||
|
break;
|
||||||
--cp;
|
--cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user