*/
int fd = open(timestampfile, O_WRONLY|O_CREAT, 0600);
if (fd == -1)
- log_error(NO_EXIT|USE_ERRNO, _("unable to open %s"), timestampfile);
+ log_error(USE_ERRNO, _("unable to open %s"), timestampfile);
else {
lock_file(fd, SUDO_LOCK);
if (write(fd, &tty_info, sizeof(tty_info)) != sizeof(tty_info)) {
- log_error(NO_EXIT|USE_ERRNO, _("unable to write to %s"),
+ log_error(USE_ERRNO, _("unable to write to %s"),
timestampfile);
}
close(fd);
} else {
if (touch(-1, timestampdir, NULL) == -1) {
if (mkdir(timestampdir, 0700) == -1) {
- log_error(NO_EXIT|USE_ERRNO, _("unable to mkdir %s"),
+ log_error(USE_ERRNO, _("unable to mkdir %s"),
timestampdir);
}
}
debug_return_int(len);
bad:
- log_error(0, _("timestamp path too long: %s"), *timestampfile);
+ log_fatal(0, _("timestamp path too long: %s"), *timestampfile);
debug_return_int(-1);
}
*/
if (lstat(dirparent, &sb) == 0) {
if (!S_ISDIR(sb.st_mode))
- log_error(NO_EXIT, _("%s exists but is not a directory (0%o)"),
+ log_error(0, _("%s exists but is not a directory (0%o)"),
dirparent, (unsigned int) sb.st_mode);
else if (sb.st_uid != timestamp_uid)
- log_error(NO_EXIT, _("%s owned by uid %u, should be uid %u"),
+ log_error(0, _("%s owned by uid %u, should be uid %u"),
dirparent, (unsigned int) sb.st_uid,
(unsigned int) timestamp_uid);
else if ((sb.st_mode & 0000022))
- log_error(NO_EXIT,
+ log_error(0,
_("%s writable by non-owner (0%o), should be mode 0700"),
dirparent, (unsigned int) sb.st_mode);
else {
status = TS_MISSING;
}
} else if (errno != ENOENT) {
- log_error(NO_EXIT|USE_ERRNO, _("unable to stat %s"), dirparent);
+ log_error(USE_ERRNO, _("unable to stat %s"), dirparent);
} else {
/* No dirparent, try to make one. */
if (ISSET(flags, TS_MAKE_DIRS)) {
if (mkdir(dirparent, S_IRWXU))
- log_error(NO_EXIT|USE_ERRNO, _("unable to mkdir %s"),
+ log_error(USE_ERRNO, _("unable to mkdir %s"),
dirparent);
else
status = TS_MISSING;
if (unlink(timestampdir) == 0)
status = TS_MISSING;
} else
- log_error(NO_EXIT, _("%s exists but is not a directory (0%o)"),
+ log_error(0, _("%s exists but is not a directory (0%o)"),
timestampdir, (unsigned int) sb.st_mode);
} else if (sb.st_uid != timestamp_uid)
- log_error(NO_EXIT, _("%s owned by uid %u, should be uid %u"),
+ log_error(0, _("%s owned by uid %u, should be uid %u"),
timestampdir, (unsigned int) sb.st_uid,
(unsigned int) timestamp_uid);
else if ((sb.st_mode & 0000022))
- log_error(NO_EXIT,
+ log_error(0,
_("%s writable by non-owner (0%o), should be mode 0700"),
timestampdir, (unsigned int) sb.st_mode);
else {
status = TS_OLD; /* do date check later */
}
} else if (errno != ENOENT) {
- log_error(NO_EXIT|USE_ERRNO, _("unable to stat %s"), timestampdir);
+ log_error(USE_ERRNO, _("unable to stat %s"), timestampdir);
} else
status = TS_MISSING;
if (status == TS_MISSING && timestampfile && ISSET(flags, TS_MAKE_DIRS)) {
if (mkdir(timestampdir, S_IRWXU) == -1) {
status = TS_ERROR;
- log_error(NO_EXIT|USE_ERRNO, _("unable to mkdir %s"), timestampdir);
+ log_error(USE_ERRNO, _("unable to mkdir %s"), timestampdir);
}
}
if (lstat(timestampfile, &sb) == 0) {
if (!S_ISREG(sb.st_mode)) {
status = TS_ERROR;
- log_error(NO_EXIT, _("%s exists but is not a regular file (0%o)"),
+ log_error(0, _("%s exists but is not a regular file (0%o)"),
timestampfile, (unsigned int) sb.st_mode);
} else {
/* If bad uid or file mode, complain and kill the bogus file. */
if (sb.st_uid != timestamp_uid) {
- log_error(NO_EXIT,
+ log_error(0,
_("%s owned by uid %u, should be uid %u"),
timestampfile, (unsigned int) sb.st_uid,
(unsigned int) timestamp_uid);
(void) unlink(timestampfile);
} else if ((sb.st_mode & 0000022)) {
- log_error(NO_EXIT,
+ log_error(0,
_("%s writable by non-owner (0%o), should be mode 0600"),
timestampfile, (unsigned int) sb.st_mode);
(void) unlink(timestampfile);
}
}
} else if (errno != ENOENT) {
- log_error(NO_EXIT|USE_ERRNO, _("unable to stat %s"), timestampfile);
+ log_error(USE_ERRNO, _("unable to stat %s"), timestampfile);
status = TS_ERROR;
}
}
*/
if (mtime.tv_sec > now + 60 * def_timestamp_timeout * 2) {
time_t tv_sec = (time_t)mtime.tv_sec;
- log_error(NO_EXIT,
+ log_error(0,
_("timestamp too far in the future: %20.20s"),
4 + ctime(&tv_sec));
if (timestampfile)
else
status = rmdir(timestampdir);
if (status == -1 && errno != ENOENT) {
- log_error(NO_EXIT,
+ log_error(0,
_("unable to remove %s (%s), will reset to the epoch"),
path, strerror(errno));
remove = false;
}
/*
- * Returns true if tty lives on a devpts or /devices filesystem, else false.
- * Unlike most filesystems, the ctime of devpts nodes is not updated when
- * the device node is written to, only when the inode's status changes,
+ * Returns true if tty lives on a devpts, /dev or /devices filesystem, else
+ * false. Unlike most filesystems, the ctime of devpts nodes is not updated
+ * when the device node is written to, only when the inode's status changes,
* typically via the chmod, chown, link, rename, or utimes system calls.
* Since the ctime is "stable" in this case, we can stash it the tty ticket
* file and use it to determine whether the tty ticket file is stale.
debug_decl(tty_is_devpts, SUDO_DEBUG_PTY)
if (statvfs(tty, &sfs) == 0) {
- if (strcmp(sfs.f_fstr, "devices") == 0)
+ if (strcmp(sfs.f_fstr, "dev") == 0 || strcmp(sfs.f_fstr, "devices") == 0)
retval = true;
}
#else
if (def_rootpw) {
if ((pw = sudo_getpwuid(ROOT_UID)) == NULL)
- log_error(0, _("unknown uid: %u"), ROOT_UID);
+ log_fatal(0, _("unknown uid: %u"), ROOT_UID);
} else if (def_runaspw) {
if ((pw = sudo_getpwnam(def_runas_default)) == NULL)
- log_error(0, _("unknown user: %s"), def_runas_default);
+ log_fatal(0, _("unknown user: %s"), def_runas_default);
} else if (def_targetpw) {
if (runas_pw->pw_name == NULL)
- log_error(NO_MAIL|MSG_ONLY, _("unknown uid: %u"),
+ log_fatal(NO_MAIL|MSG_ONLY, _("unknown uid: %u"),
(unsigned int) runas_pw->pw_uid);
pw_addref(runas_pw);
pw = runas_pw;