Commit Graph

54 Commits

Author SHA1 Message Date
Todd C. Miller
0765f5fe7f fix typo in previous commit 2015-07-22 06:21:21 -06:00
Todd C. Miller
83d8cbf811 Fix errno value from get_process_ttyname() when no tty is present. 2015-07-21 15:20:49 -06:00
Todd C. Miller
aeaa6a6111 On AIX, only convert the tty device number from dev64_t to dev32_t
if dev_t is 32-bits.
2015-07-21 15:02:56 -06:00
Todd C. Miller
d96f8bcabb Avoid needless memory allocation when resolving the tty name. 2015-07-19 20:19:22 -06:00
Todd C. Miller
d77941c2be We require POSIX so no need to conditionally include dirent.h.
Add a check for d_namlen and use the result in the NAMLEN macro.
2015-07-02 09:24:48 -06:00
Todd C. Miller
0b241088b3 There's no need to conditionalize the #include <unistd.h>, we require
a POSIX system.
2015-07-02 09:08:28 -06:00
Todd C. Miller
7b086b6842 Quiet clang analyzer false positive. 2015-06-23 12:58:02 -06:00
Todd C. Miller
4a07b472f0 Only include stddef.h where it is needed. 2015-06-20 05:34:35 -06:00
Todd C. Miller
dc883f2454 We require ANSI C so stop using the obsolete STDC_HEADERS. 2015-06-19 14:29:27 -06:00
Todd C. Miller
4f9cabd005 Remove obsolete memory.h include. 2015-06-18 21:02:57 -06:00
Todd C. Miller
cb63ca701c Avoid using exiting allocators in the front end. 2015-06-17 17:00:54 -06:00
Todd C. Miller
59ab26dbcc Go back to a 2 args debug_decl and just use the "default" instance,
now renamed "active".
2015-02-01 08:24:49 -07:00
Todd C. Miller
acea28b9a5 Document why we need sys/param.h. 2015-01-14 11:01:41 -07:00
Todd C. Miller
866cfc4fc3 Add support for multiple Debug lines per program. Callers may
register arbitrary debug facilities or use built-in defaults.  We
now use separate Debug statements for plugins and programs.
2014-10-22 13:23:05 -06:00
Todd C. Miller
36a5767e3e efree -> sudo_efree for consistency 2014-07-10 15:35:04 -06:00
Todd C. Miller
2d61d38c23 Add sudo_ prefix to alloc.c functions and rename alloc.h -> sudo_alloc.h 2014-06-27 10:48:31 -06:00
Todd C. Miller
aecef4aa1d Rename warning/fatal -> sudo_warn/sudo_fatal to avoid namespace
pollution in libsudo_util.so.
2014-06-27 09:30:52 -06:00
Todd C. Miller
134b2a4228 Rename emalloc2() -> emallocarray() and erealloc3() -> ereallocarray(). 2014-04-22 16:02:28 -06:00
Todd C. Miller
d99b4f0909 Fix strtonum() usage when parsing /proc/self/stat on Linux.
Bug #630
2014-01-13 11:11:26 -07:00
Todd C. Miller
cbf41b8b96 The OpenBSD strtonum() uses very short error strings that can't
be translated usefully.  Convert them to longer strings on error.
Also use the longer strings for atomode() and atoid().
2013-12-11 13:43:10 -07:00
Todd C. Miller
8f9ce7249a Use strtonum() instead of atoi(), strtol() or strtoul() where possible. 2013-12-10 16:23:21 -07:00
Todd C. Miller
902215a8c0 Ignore EOVERFLOW from pstat_getproc(). The HP-UX kernel appears
to return this in certain situations but it appears to be harmless
at least insofar as retrieving the tty goes.
2013-11-30 18:43:57 -07:00
Todd C. Miller
99b7351de0 Fix some #if vs. #ifdef and remove an extraneous semicolon.
Bug #624; from Daniel Richard G.
2013-11-17 16:15:36 -07:00
Todd C. Miller
0817429583 More sign compare fixes. On Solaris id_t is signed so use uid_t
in the set_perms.c ID macro instead.
2013-10-23 15:19:41 -06:00
Todd C. Miller
07a804caf3 Quiet sign comparision warnings. 2013-10-23 15:03:31 -06:00
Todd C. Miller
5869916533 Clarify a comment. 2013-05-18 04:38:26 -04:00
Todd C. Miller
5549e44cd8 Handle d_type == DT_UNKNOWN when resolving the device to a name and
sprinkle some more debugging.
2013-05-16 10:18:13 -04:00
Todd C. Miller
2b1b9ae72d Don't check the tty of the parent process. Now that we get the
controlling tty device number from the kernel there is no need.  If
the process has really disassociated from the tty then reporting
"unknown" is appropriate.
2013-04-21 10:35:52 -04:00
Todd C. Miller
42313adc0d AIX may have a 64-bit pr_ttydev that we need to convert to 32-bit
before we try to match it against st_rdev.
2013-04-10 12:30:16 -04:00
Todd C. Miller
54f092c3e6 Break out of the loop if sudo_ttyname_scan() returns non-NULL.
Fixes a problem finding the tty name when it is not in /dev/pts.
2013-04-10 12:11:12 -04:00
Todd C. Miller
e30b0bd121 Use pstat() on HP-UX to determine the tty device. 2013-02-28 09:01:08 -05:00
Todd C. Miller
23649bef16 Remove ttyname() fall back code on systems where we can query the
kernel for the tty device via /proc or sysctl().  If there is no
controlling tty, it is better to just treat the tty as unknown
rather than to blindly use what is hooked up to std{in,out,err}.
2013-01-31 11:05:56 -05:00
Todd C. Miller
1d7072fe09 Don't include <sys/param.h>. We only needed it for MAXPATHLEN,
MAXHOSTNAMELEN and the MIN/MAX macros.  We now use PATH_MAX and
HOST_NAME_MAX throughout without falling back on MAXPATHLEN or
MAXHOSTNAMELEN and define our own MIN/MAX macros as needed.
2012-12-04 10:40:47 -05:00
Todd C. Miller
d3ab8b080b Define sudo_ttyname_dev() for the HAVE_STRUCT_PSINFO_PR_TTYDEV case
too.
2012-11-27 10:49:46 -05:00
Todd C. Miller
84eedd3f79 sudo_ttyname_dev() is unused if there is no /proc or sysctl(). 2012-10-02 15:29:52 -04:00
Todd C. Miller
ae21fb299d Silence compiler warnings. 2012-08-29 14:40:25 -04:00
Todd C. Miller
cf3fce6651 Use AC_HEADER_MAJOR to determine where major/minor are defined. 2012-04-16 10:25:49 -04:00
Todd C. Miller
dbcd7222a1 Include sys/mkdev.h if present instead of sys/sysmacros.h for
minor().  This is needed on Solaris (at least) where the makedev
macros in sysmacros.h are obsolete and library functions should be
used instead.
2012-04-16 10:18:32 -04:00
Todd C. Miller
21eddb5d60 Add back buf and tty variables for _ttyname() case that were
inadvertantly removed.
2012-04-15 13:10:26 -04:00
Todd C. Miller
8db20e6ae9 remove some XXX 2012-04-13 16:16:10 -04:00
Todd C. Miller
48d3b5aad1 When looking for a device match, do a breadth-first search instead
of depth-first.  We already special case /dev/pts/ so chances are
good that if it is not a pseudo-tty it is in the base of /dev/.
Also avoid a stat(2) when possible if struct dirent has d_type.
2012-04-13 16:00:32 -04:00
Todd C. Miller
08ad578b7c Add depth-first traversal of /dev/ for the /proc case when not /dev/pts/N 2012-04-13 12:54:03 -04:00
Todd C. Miller
83fc02bc97 Rototill code to determine the tty. For Linux, we now look up the
tty device in /proc/pid/stat instead of trying to open /proc/pid/fd/[0-2].
The sudo_ttyname_dev() function maps the given device number to a
string.  On BSD, we can use devname().  On Solaris, _ttyname_dev()
does what we want.
TODO: write /dev/ traversal code for the generic sudo_ttyname_dev().
2012-04-11 14:48:08 -04:00
Todd C. Miller
271f3e2054 Define PRNODEV for those w/o it. 2012-04-10 16:12:08 -04:00
Todd C. Miller
11f13be0dd Check for SVR4-style struct psinfo.pr_ttydev and use that to determine
the tty if std{in,out,err} are not ttys.
2012-04-10 15:53:41 -04:00
Todd C. Miller
2e59eafba6 Better support for SVR4-style /proc entries where we can't use
ttyname() on the /proc/pid/fd/[0-2] entries.  We can, however,
attempt to map the device number back to the correct pseudo-tty
slave device.
2012-04-10 14:35:30 -04:00
Todd C. Miller
329e224db9 When trying to determine the tty name, check parent's stderr in
addition to its stdin and stdout.
2012-04-10 13:49:49 -04:00
Todd C. Miller
30fee3aade Open /proc/pid/fd/[0-2] in non-blocking mode just in case we might
block in open.
2012-04-10 09:26:52 -04:00
Todd C. Miller
4bd136e11a Simply move the free of ki_proc outside the realloc() loop. 2012-03-12 11:37:33 -04:00
Todd C. Miller
1ca5009563 Bring back the erealloc() for the ENOMEM loop and just zero the
pointer after we free it.
2012-03-12 10:49:26 -04:00