$as_echo "$as_me: WARNING: Ignoring attempt to disable the device search path" >&2;}
;;
*) devsearch="$enableval"
+ ;;
esac
fi
+ds="`echo \"$devsearch\"|sed 's@/dev/*\([^:]*:*\)@_PATH_DEV \"\1\" @g'`"
cat >>confdefs.h <<EOF
-#define _PATH_SUDO_DEVSEARCH "$devsearch"
+#define _PATH_SUDO_DEVSEARCH $ds
EOF
no) AC_MSG_WARN([Ignoring attempt to disable the device search path])
;;
*) devsearch="$enableval"
+ ;;
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])],
[case $with_selinux in
/* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */
# if defined(__FreeBSD__) || defined(__APPLE__)
- path = "/dev/fd";
+ path = _PATH_DEV "fd";
# else
path = "/proc/self/fd";
# endif
/*
- * 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>
*
* Permission to use, copy, modify, and distribute this software for any
#endif
#include "sudo_compat.h"
+#include "pathnames.h"
#define MKTEMP_FILE 1
#define MKTEMP_DIR 2
/*
* Seed from /dev/urandom if possible.
*/
- fd = open("/dev/urandom", O_RDONLY);
+ fd = open(_PATH_DEV "urandom", O_RDONLY);
if (fd != -1) {
ssize_t nread;
#endif /* _PATH_DEV */
#ifndef _PATH_TTY
-# define _PATH_TTY "/dev/tty"
+# define _PATH_TTY _PATH_DEV "tty"
#endif /* _PATH_TTY */
#ifndef _PATH_DEVNULL
-# define _PATH_DEVNULL "/dev/null"
+# define _PATH_DEVNULL _PATH_DEV "null"
#endif /* _PATH_DEVNULL */
#ifndef _PATH_DEFPATH
if (utmp_user != NULL)
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
sudo_debug_printf(SUDO_DEBUG_INFO,
- "%s: /dev/tty fd %d, pty master fd %d, pty slave fd %d", __func__,
- io_fds[SFD_USERTTY], io_fds[SFD_MASTER], io_fds[SFD_SLAVE]);
+ "%s: %s fd %d, pty master fd %d, pty slave fd %d",
+ __func__, _PATH_TTY, io_fds[SFD_USERTTY], io_fds[SFD_MASTER],
+ io_fds[SFD_SLAVE]);
}
debug_return;
/* Avoid closing /dev/tty or std{in,out,err}. */
if (fd < 3 || fd == io_fds[SFD_USERTTY]) {
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;
debug_return_int(-1);
}
int fd;
# ifdef _AIX
- fd = open("/dev/ptc", oflag);
+ fd = open(_PATH_DEV "ptc", oflag);
# else
- fd = open("/dev/ptmx", oflag);
+ fd = open(_PATH_DEV "ptmx", oflag);
# endif
return fd;
}
#else /* Old-style BSD ptys */
-static char line[] = "/dev/ptyXX";
+static char line[] = _PATH_DEV "ptyXX";
bool
get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
ttygid = gr->gr_gid;
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++) {
- line[sizeof("/dev/ptyXX") - 2] = *cp;
+ line[sizeof(_PATH_DEV "ptyXX") - 2] = *cp;
*master = open(line, O_RDWR|O_NOCTTY, 0);
if (*master == -1) {
if (errno == ENOENT)
goto done; /* out of ptys */
continue; /* already in use */
}
- line[sizeof("/dev/p") - 2] = 't';
+ line[sizeof(_PATH_DEV "p") - 2] = 't';
(void) chown(line, ttyuid, ttygid);
(void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
# ifdef HAVE_REVOKE
* Device nodes to ignore.
*/
static const char *ignore_devs[] = {
- "/dev/stdin",
- "/dev/stdout",
- "/dev/stderr",
+ _PATH_DEV "stdin",
+ _PATH_DEV "stdout",
+ _PATH_DEV "stderr",
NULL
};
/*
* 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)
goto done;
memcpy(path, cp, len);
path[len] = '\0';
- if (strcmp(path, "/dev/pts") == 0) {
+ if (strcmp(path, _PATH_DEV "pts") == 0) {
/* Special case /dev/pts */
- len = (size_t)snprintf(path, sizeof(path), "/dev/pts/%u",
- (unsigned int)minor(rdev));
+ len = (size_t)snprintf(path, sizeof(path), "%spts/%u",
+ _PATH_DEV, (unsigned int)minor(rdev));
if (len >= sizeof(path)) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
- "devsearch entry /dev/pts/%u too long",
- (unsigned int)minor(rdev));
+ "devsearch entry %spts/%u too long",
+ _PATH_DEV, (unsigned int)minor(rdev));
continue;
}
ret = sudo_dev_check(rdev, path, buf, buflen);