Use _PATH_DEV consistently
This commit is contained in:
4
configure
vendored
4
configure
vendored
@@ -6679,11 +6679,13 @@ if test "${enable_devsearch+set}" = set; then :
|
|||||||
$as_echo "$as_me: WARNING: Ignoring attempt to disable the device search path" >&2;}
|
$as_echo "$as_me: WARNING: Ignoring attempt to disable the device search path" >&2;}
|
||||||
;;
|
;;
|
||||||
*) devsearch="$enableval"
|
*) devsearch="$enableval"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ds="`echo \"$devsearch\"|sed 's@/dev/*\([^:]*:*\)@_PATH_DEV \"\1\" @g'`"
|
||||||
cat >>confdefs.h <<EOF
|
cat >>confdefs.h <<EOF
|
||||||
#define _PATH_SUDO_DEVSEARCH "$devsearch"
|
#define _PATH_SUDO_DEVSEARCH $ds
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1541,8 +1541,10 @@ AC_ARG_ENABLE(devsearch,
|
|||||||
no) AC_MSG_WARN([Ignoring attempt to disable the device search path])
|
no) AC_MSG_WARN([Ignoring attempt to disable the device search path])
|
||||||
;;
|
;;
|
||||||
*) devsearch="$enableval"
|
*) devsearch="$enableval"
|
||||||
|
;;
|
||||||
esac])
|
esac])
|
||||||
SUDO_DEFINE_UNQUOTED(_PATH_SUDO_DEVSEARCH, "$devsearch")
|
ds="`echo \"$devsearch\"|sed 's@/dev/*\([[^:]]*:*\)@_PATH_DEV \"\1\" @g'`"
|
||||||
|
SUDO_DEFINE_UNQUOTED(_PATH_SUDO_DEVSEARCH, $ds)
|
||||||
|
|
||||||
AC_ARG_WITH(selinux, [AS_HELP_STRING([--with-selinux], [enable SELinux support])],
|
AC_ARG_WITH(selinux, [AS_HELP_STRING([--with-selinux], [enable SELinux support])],
|
||||||
[case $with_selinux in
|
[case $with_selinux in
|
||||||
|
@@ -103,7 +103,7 @@ sudo_closefrom(int lowfd)
|
|||||||
|
|
||||||
/* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */
|
/* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */
|
||||||
# if defined(__FreeBSD__) || defined(__APPLE__)
|
# if defined(__FreeBSD__) || defined(__APPLE__)
|
||||||
path = "/dev/fd";
|
path = _PATH_DEV "fd";
|
||||||
# else
|
# else
|
||||||
path = "/proc/self/fd";
|
path = "/proc/self/fd";
|
||||||
# endif
|
# endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2003, 2004, 2008-2011, 2013, 2015
|
* Copyright (c) 2001, 2003, 2004, 2008-2011, 2013, 2015, 2017
|
||||||
* Todd C. Miller <Todd.Miller@courtesan.com>
|
* Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
|
#include "pathnames.h"
|
||||||
|
|
||||||
#define MKTEMP_FILE 1
|
#define MKTEMP_FILE 1
|
||||||
#define MKTEMP_DIR 2
|
#define MKTEMP_DIR 2
|
||||||
@@ -83,7 +84,7 @@ seed_random(void)
|
|||||||
/*
|
/*
|
||||||
* Seed from /dev/urandom if possible.
|
* Seed from /dev/urandom if possible.
|
||||||
*/
|
*/
|
||||||
fd = open("/dev/urandom", O_RDONLY);
|
fd = open(_PATH_DEV "urandom", O_RDONLY);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
|
||||||
|
@@ -36,11 +36,11 @@
|
|||||||
#endif /* _PATH_DEV */
|
#endif /* _PATH_DEV */
|
||||||
|
|
||||||
#ifndef _PATH_TTY
|
#ifndef _PATH_TTY
|
||||||
# define _PATH_TTY "/dev/tty"
|
# define _PATH_TTY _PATH_DEV "tty"
|
||||||
#endif /* _PATH_TTY */
|
#endif /* _PATH_TTY */
|
||||||
|
|
||||||
#ifndef _PATH_DEVNULL
|
#ifndef _PATH_DEVNULL
|
||||||
# define _PATH_DEVNULL "/dev/null"
|
# define _PATH_DEVNULL _PATH_DEV "null"
|
||||||
#endif /* _PATH_DEVNULL */
|
#endif /* _PATH_DEVNULL */
|
||||||
|
|
||||||
#ifndef _PATH_DEFPATH
|
#ifndef _PATH_DEFPATH
|
||||||
|
@@ -145,8 +145,9 @@ pty_setup(uid_t uid, const char *tty)
|
|||||||
if (utmp_user != NULL)
|
if (utmp_user != NULL)
|
||||||
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
|
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: /dev/tty fd %d, pty master fd %d, pty slave fd %d", __func__,
|
"%s: %s fd %d, pty master fd %d, pty slave fd %d",
|
||||||
io_fds[SFD_USERTTY], io_fds[SFD_MASTER], io_fds[SFD_SLAVE]);
|
__func__, _PATH_TTY, io_fds[SFD_USERTTY], io_fds[SFD_MASTER],
|
||||||
|
io_fds[SFD_SLAVE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_return;
|
debug_return;
|
||||||
@@ -1581,7 +1582,7 @@ safe_close(int fd)
|
|||||||
/* Avoid closing /dev/tty or std{in,out,err}. */
|
/* Avoid closing /dev/tty or std{in,out,err}. */
|
||||||
if (fd < 3 || fd == io_fds[SFD_USERTTY]) {
|
if (fd < 3 || fd == io_fds[SFD_USERTTY]) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: not closing fd %d (/dev/tty)", __func__, fd);
|
"%s: not closing fd %d (%s)", __func__, fd, _PATH_TTY);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
debug_return_int(-1);
|
debug_return_int(-1);
|
||||||
}
|
}
|
||||||
|
@@ -99,9 +99,9 @@ posix_openpt(int oflag)
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
# ifdef _AIX
|
# ifdef _AIX
|
||||||
fd = open("/dev/ptc", oflag);
|
fd = open(_PATH_DEV "ptc", oflag);
|
||||||
# else
|
# else
|
||||||
fd = open("/dev/ptmx", oflag);
|
fd = open(_PATH_DEV "ptmx", oflag);
|
||||||
# endif
|
# endif
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ done:
|
|||||||
|
|
||||||
#else /* Old-style BSD ptys */
|
#else /* Old-style BSD ptys */
|
||||||
|
|
||||||
static char line[] = "/dev/ptyXX";
|
static char line[] = _PATH_DEV "ptyXX";
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
|
get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
|
||||||
@@ -160,16 +160,16 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
|
|||||||
ttygid = gr->gr_gid;
|
ttygid = gr->gr_gid;
|
||||||
|
|
||||||
for (bank = "pqrs"; *bank != '\0'; bank++) {
|
for (bank = "pqrs"; *bank != '\0'; bank++) {
|
||||||
line[sizeof("/dev/ptyX") - 2] = *bank;
|
line[sizeof(_PATH_DEV "ptyX") - 2] = *bank;
|
||||||
for (cp = "0123456789abcdef"; *cp != '\0'; cp++) {
|
for (cp = "0123456789abcdef"; *cp != '\0'; cp++) {
|
||||||
line[sizeof("/dev/ptyXX") - 2] = *cp;
|
line[sizeof(_PATH_DEV "ptyXX") - 2] = *cp;
|
||||||
*master = open(line, O_RDWR|O_NOCTTY, 0);
|
*master = open(line, O_RDWR|O_NOCTTY, 0);
|
||||||
if (*master == -1) {
|
if (*master == -1) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
goto done; /* out of ptys */
|
goto done; /* out of ptys */
|
||||||
continue; /* already in use */
|
continue; /* already in use */
|
||||||
}
|
}
|
||||||
line[sizeof("/dev/p") - 2] = 't';
|
line[sizeof(_PATH_DEV "p") - 2] = 't';
|
||||||
(void) chown(line, ttyuid, ttygid);
|
(void) chown(line, ttyuid, ttygid);
|
||||||
(void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
|
(void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
|
||||||
# ifdef HAVE_REVOKE
|
# ifdef HAVE_REVOKE
|
||||||
|
@@ -142,9 +142,9 @@ sudo_ttyname_dev(dev_t tdev, char *name, size_t namelen)
|
|||||||
* Device nodes to ignore.
|
* Device nodes to ignore.
|
||||||
*/
|
*/
|
||||||
static const char *ignore_devs[] = {
|
static const char *ignore_devs[] = {
|
||||||
"/dev/stdin",
|
_PATH_DEV "stdin",
|
||||||
"/dev/stdout",
|
_PATH_DEV "stdout",
|
||||||
"/dev/stderr",
|
_PATH_DEV "stderr",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ sudo_ttyname_dev(dev_t rdev, char *buf, size_t buflen)
|
|||||||
/*
|
/*
|
||||||
* First, check /dev/console.
|
* First, check /dev/console.
|
||||||
*/
|
*/
|
||||||
ret = sudo_dev_check(rdev, "/dev/console", buf, buflen);
|
ret = sudo_dev_check(rdev, _PATH_DEV "console", buf, buflen);
|
||||||
if (ret != NULL)
|
if (ret != NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
@@ -326,14 +326,14 @@ sudo_ttyname_dev(dev_t rdev, char *buf, size_t buflen)
|
|||||||
memcpy(path, cp, len);
|
memcpy(path, cp, len);
|
||||||
path[len] = '\0';
|
path[len] = '\0';
|
||||||
|
|
||||||
if (strcmp(path, "/dev/pts") == 0) {
|
if (strcmp(path, _PATH_DEV "pts") == 0) {
|
||||||
/* Special case /dev/pts */
|
/* Special case /dev/pts */
|
||||||
len = (size_t)snprintf(path, sizeof(path), "/dev/pts/%u",
|
len = (size_t)snprintf(path, sizeof(path), "%spts/%u",
|
||||||
(unsigned int)minor(rdev));
|
_PATH_DEV, (unsigned int)minor(rdev));
|
||||||
if (len >= sizeof(path)) {
|
if (len >= sizeof(path)) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"devsearch entry /dev/pts/%u too long",
|
"devsearch entry %spts/%u too long",
|
||||||
(unsigned int)minor(rdev));
|
_PATH_DEV, (unsigned int)minor(rdev));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = sudo_dev_check(rdev, path, buf, buflen);
|
ret = sudo_dev_check(rdev, path, buf, buflen);
|
||||||
|
Reference in New Issue
Block a user