Reduce name space pollution in libsudo_util.so

This commit is contained in:
Todd C. Miller
2014-06-26 16:21:19 -06:00
parent 9b3c19cc36
commit d36846a699
8 changed files with 47 additions and 46 deletions

View File

@@ -163,13 +163,13 @@ __dso_public void initprogname(const char *);
__dso_public int sudo_setgroups(int ngids, const GETGROUPS_T *gids);
/* term.c */
__dso_public bool term_cbreak(int);
__dso_public bool term_copy(int, int);
__dso_public bool term_noecho(int);
__dso_public bool term_raw(int, int);
__dso_public bool term_restore(int, bool);
__dso_public bool sudo_term_cbreak(int);
__dso_public bool sudo_term_copy(int, int);
__dso_public bool sudo_term_noecho(int);
__dso_public bool sudo_term_raw(int, int);
__dso_public bool sudo_term_restore(int, bool);
/* ttysize.c */
__dso_public void get_ttysize(int *rowp, int *colp);
__dso_public void sudo_get_ttysize(int *rowp, int *colp);
#endif /* _SUDO_UTIL_H */

View File

@@ -69,15 +69,16 @@ static struct termios term, oterm;
static int changed;
/* tgetpass() needs to know the erase and kill chars for cbreak mode. */
__dso_public int term_erase;
__dso_public int term_kill;
__dso_public int sudo_term_erase;
__dso_public int sudo_term_kill;
static volatile sig_atomic_t got_sigttou;
/*
* SIGTTOU signal handler for term_restore that just sets a flag.
*/
static void sigttou(int signo)
static void
sigttou(int signo)
{
got_sigttou = 1;
}
@@ -116,7 +117,7 @@ tcsetattr_nobg(int fd, int flags, struct termios *tp)
* Returns true on success or false on failure.
*/
bool
term_restore(int fd, bool flush)
sudo_term_restore(int fd, bool flush)
{
debug_decl(term_restore, SUDO_DEBUG_UTIL)
@@ -134,7 +135,7 @@ term_restore(int fd, bool flush)
* Returns true on success or false on failure.
*/
bool
term_noecho(int fd)
sudo_term_noecho(int fd)
{
debug_decl(term_noecho, SUDO_DEBUG_UTIL)
@@ -163,7 +164,7 @@ again:
* Returns true on success or false on failure.
*/
bool
term_raw(int fd, int isig)
sudo_term_raw(int fd, int isig)
{
struct termios term;
debug_decl(term_raw, SUDO_DEBUG_UTIL)
@@ -197,7 +198,7 @@ again:
* Returns true on success or false on failure.
*/
bool
term_cbreak(int fd)
sudo_term_cbreak(int fd)
{
debug_decl(term_cbreak, SUDO_DEBUG_UTIL)
@@ -216,8 +217,8 @@ again:
term.c_cc[VSTATUS] = _POSIX_VDISABLE;
#endif
if (tcsetattr_nobg(fd, TCSADRAIN|TCSASOFT, &term) == 0) {
term_erase = term.c_cc[VERASE];
term_kill = term.c_cc[VKILL];
sudo_term_erase = term.c_cc[VERASE];
sudo_term_kill = term.c_cc[VKILL];
changed = 1;
debug_return_bool(true);
}
@@ -234,7 +235,7 @@ again:
* Returns true on success or false on failure.
*/
bool
term_copy(int src, int dst)
sudo_term_copy(int src, int dst)
{
struct termios tt;
debug_decl(term_copy, SUDO_DEBUG_UTIL)

View File

@@ -71,9 +71,9 @@ get_ttysize_ioctl(int *rowp, int *colp)
#endif /* TIOCGWINSZ */
void
get_ttysize(int *rowp, int *colp)
sudo_get_ttysize(int *rowp, int *colp)
{
debug_decl(fork_cmnd, SUDO_DEBUG_EXEC)
debug_decl(sudo_get_ttysize, SUDO_DEBUG_EXEC)
if (get_ttysize_ioctl(rowp, colp) == -1) {
char *p;

View File

@@ -40,7 +40,6 @@ fatal_callback_deregister
fatal_callback_register
fatal_nodebug
fatalx_nodebug
get_ttysize
getprogname
initprogname
isblank
@@ -99,6 +98,7 @@ sudo_fnmatch
sudo_freeaddrinfo
sudo_futimes
sudo_gai_strerror
sudo_get_ttysize
sudo_getaddrinfo
sudo_getcwd
sudo_getgrouplist
@@ -132,16 +132,16 @@ sudo_strlcat
sudo_strlcpy
sudo_strsignal
sudo_strtonum
sudo_term_cbreak
sudo_term_copy
sudo_term_erase
sudo_term_kill
sudo_term_noecho
sudo_term_raw
sudo_term_restore
sudo_utimes
sudo_vasprintf
sudo_vsnprintf
term_cbreak
term_copy
term_erase
term_kill
term_noecho
term_raw
term_restore
vfatal_nodebug
vfatalx_nodebug
vwarning_nodebug

View File

@@ -352,7 +352,7 @@ main(int argc, char *argv[])
printf(_("Replaying sudo session: %s\n"), li->cmd);
/* Make sure the terminal is large enough. */
get_ttysize(&rows, &cols);
sudo_get_ttysize(&rows, &cols);
if (li->rows != 0 && li->cols != 0) {
if (li->rows > rows) {
printf(_("Warning: your terminal is too small to properly replay the log.\n"));
@@ -367,7 +367,7 @@ main(int argc, char *argv[])
/* Replay session corresponding to io_log_files[]. */
replay_session(max_wait, decimal);
term_restore(STDIN_FILENO, 1);
sudo_term_restore(STDIN_FILENO, 1);
done:
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, exitcode);
exit(exitcode);
@@ -410,7 +410,7 @@ replay_session(const double max_wait, const char *decimal)
idx = fcntl(STDIN_FILENO, F_GETFL, 0);
if (idx != -1)
(void) fcntl(STDIN_FILENO, F_SETFL, idx | O_NONBLOCK);
if (!term_raw(STDIN_FILENO, 1))
if (!sudo_term_raw(STDIN_FILENO, 1))
fatal(U_("unable to set tty to raw mode"));
}
@@ -1260,7 +1260,7 @@ help(void)
static void
sudoreplay_cleanup(void)
{
term_restore(STDIN_FILENO, 0);
sudo_term_restore(STDIN_FILENO, 0);
}
/*
@@ -1270,6 +1270,6 @@ sudoreplay_cleanup(void)
static void
sudoreplay_handler(int signo)
{
term_restore(STDIN_FILENO, 0);
sudo_term_restore(STDIN_FILENO, 0);
kill(getpid(), signo);
}

View File

@@ -116,7 +116,7 @@ pty_cleanup(void)
debug_decl(cleanup, SUDO_DEBUG_EXEC);
if (!TAILQ_EMPTY(&io_plugins) && io_fds[SFD_USERTTY] != -1)
term_restore(io_fds[SFD_USERTTY], 0);
sudo_term_restore(io_fds[SFD_USERTTY], 0);
#ifdef HAVE_SELINUX
selinux_restore_tty();
#endif
@@ -328,7 +328,7 @@ check_foreground(void)
if (io_fds[SFD_USERTTY] != -1) {
foreground = tcgetpgrp(io_fds[SFD_USERTTY]) == ppgrp;
if (foreground && !tty_initialized) {
if (term_copy(io_fds[SFD_USERTTY], io_fds[SFD_SLAVE])) {
if (sudo_term_copy(io_fds[SFD_USERTTY], io_fds[SFD_SLAVE])) {
tty_initialized = true;
sync_ttysize(io_fds[SFD_USERTTY], io_fds[SFD_SLAVE]);
}
@@ -363,7 +363,7 @@ suspend_parent(int signo)
if (foreground) {
if (ttymode != TERM_RAW) {
do {
n = term_raw(io_fds[SFD_USERTTY], 0);
n = sudo_term_raw(io_fds[SFD_USERTTY], 0);
} while (!n && errno == EINTR);
ttymode = TERM_RAW;
}
@@ -378,7 +378,7 @@ suspend_parent(int signo)
/* Restore original tty mode before suspending. */
if (ttymode != TERM_COOKED)
term_restore(io_fds[SFD_USERTTY], 0);
sudo_term_restore(io_fds[SFD_USERTTY], 0);
if (sig2str(signo, signame) == -1)
snprintf(signame, sizeof(signame), "%d", signo);
@@ -413,7 +413,7 @@ suspend_parent(int signo)
if (foreground) {
/* Foreground process, set tty to raw mode. */
do {
n = term_raw(io_fds[SFD_USERTTY], 0);
n = sudo_term_raw(io_fds[SFD_USERTTY], 0);
} while (!n && errno == EINTR);
ttymode = TERM_RAW;
} else {
@@ -727,7 +727,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
if (foreground) {
/* Copy terminal attrs from user tty -> pty slave. */
if (term_copy(io_fds[SFD_USERTTY], io_fds[SFD_SLAVE])) {
if (sudo_term_copy(io_fds[SFD_USERTTY], io_fds[SFD_SLAVE])) {
tty_initialized = true;
sync_ttysize(io_fds[SFD_USERTTY], io_fds[SFD_SLAVE]);
}
@@ -736,7 +736,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
if (!pipeline && !ISSET(details->flags, CD_EXEC_BG)) {
ttymode = TERM_RAW;
do {
n = term_raw(io_fds[SFD_USERTTY], 0);
n = sudo_term_raw(io_fds[SFD_USERTTY], 0);
} while (!n && errno == EINTR);
if (!n)
fatal(U_("unable to set terminal to raw mode"));
@@ -823,7 +823,7 @@ pty_close(struct command_status *cstat)
/* Restore terminal settings. */
if (io_fds[SFD_USERTTY] != -1)
term_restore(io_fds[SFD_USERTTY], 0);
sudo_term_restore(io_fds[SFD_USERTTY], 0);
/* If child was signalled, write the reason to stdout like the shell. */
if (cstat->type == CMD_WSTATUS && WIFSIGNALED(cstat->val)) {

View File

@@ -513,7 +513,7 @@ get_user_info(struct user_details *ud)
fatal(NULL);
ud->host = user_info[i] + sizeof("host=") - 1;
get_ttysize(&ud->ts_lines, &ud->ts_cols);
sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols);
easprintf(&user_info[++i], "lines=%d", ud->ts_lines);
easprintf(&user_info[++i], "cols=%d", ud->ts_cols);

View File

@@ -119,9 +119,9 @@ restart:
*/
if (!ISSET(flags, TGP_ECHO)) {
if (ISSET(flags, TGP_MASK))
neednl = term_cbreak(input);
neednl = sudo_term_cbreak(input);
else
neednl = term_noecho(input);
neednl = sudo_term_noecho(input);
}
/*
@@ -164,7 +164,7 @@ restart:
restore:
/* Restore old tty settings and signals. */
if (!ISSET(flags, TGP_ECHO))
term_restore(input, 1);
sudo_term_restore(input, 1);
(void) sigaction(SIGALRM, &savealrm, NULL);
(void) sigaction(SIGINT, &saveint, NULL);
(void) sigaction(SIGHUP, &savehup, NULL);
@@ -261,7 +261,7 @@ sudo_askpass(const char *askpass, const char *prompt)
debug_return_str_masked(pass);
}
extern int term_erase, term_kill;
extern int sudo_term_erase, sudo_term_kill;
static char *
getln(int fd, char *buf, size_t bufsiz, int feedback)
@@ -282,7 +282,7 @@ getln(int fd, char *buf, size_t bufsiz, int feedback)
if (nr != 1 || c == '\n' || c == '\r')
break;
if (feedback) {
if (c == term_kill) {
if (c == sudo_term_kill) {
while (cp > buf) {
if (write(fd, "\b \b", 3) == -1)
break;
@@ -290,7 +290,7 @@ getln(int fd, char *buf, size_t bufsiz, int feedback)
}
left = bufsiz;
continue;
} else if (c == term_erase) {
} else if (c == sudo_term_erase) {
if (cp > buf) {
if (write(fd, "\b \b", 3) == -1)
break;