Todd C. Miller
4b96e94f37
Need to be root when switching to a different user.
2016-01-18 13:12:50 -07:00
Todd C. Miller
9f481f128d
Use O_SEARCH on systems without O_PATH if present. It can be used
...
for a similar purpose.
2016-01-18 12:38:41 -07:00
Todd C. Miller
c1b1481204
Use faccessat(2) for directory writability instead of doing the
...
checks manually where possible. This also allows us to remove the
#ifdef __linux__ bits since we no longer use fstat(2) on Linux with
an O_PATH fd.
2016-01-18 10:45:47 -07:00
Todd C. Miller
051fe2d4cf
Add missing dfd argument to the version of sudo_edit_openat_nofollow()
...
for systems without O_NOFOLLOW.
2016-01-11 16:36:40 -07:00
Todd C. Miller
c7c80913ef
No need to check whether the fd we opened is really a directory in
...
sudo_edit_open_nonwritable() since if not, the openat() will fail
with ENOTDIR anyway.
2016-01-11 11:15:42 -07:00
Todd C. Miller
68c1073fe5
Rewritten sudoedit_checkdir support that checks all the dirs in the
...
path and refuses to follow symlinks in writable directories.
This is a better fix for CVE-2015-5602.
Adapted from a diff by Ben Hutchings. Bug #707
2016-01-10 18:31:29 -07:00
Todd C. Miller
97e86c74ff
Call openat() with the basename not the full path. From Ben Hutchings.
2015-12-29 13:38:14 -07:00
Todd C. Miller
9ecf12daa7
Set errno to EISDIR instead of ENOTDIR if directory is writable
...
since ENOTDIR can be a legitimate errno. This avoids a bogus
"directory is writable" error in that case.
2015-10-25 14:28:38 -06:00
Todd C. Miller
5d66b840d8
When creating a new file, sudoedit will now check that the file's
...
parent directory exists before running the editor.
2015-10-24 06:20:20 -06:00
Todd C. Miller
c50cead833
Add directory writability checks for sudoedit.
2015-10-23 14:04:35 -06:00
Todd C. Miller
6dc5151d5d
Remove S_ISREG check from sudo_edit_open(), it is already done in
...
the caller.
2015-10-02 20:35:55 -06:00
Todd C. Miller
37dff5fbcb
Open sudoedit files with O_NONBLOCK and fail if they are not regular
...
files.
2015-10-02 14:45:09 -06:00
Todd C. Miller
67183d74f4
Remove include/compat/timespec.h. Systems old enough to lack struct
...
timespec are too old to build a modern sudo.
2015-09-09 11:13:22 -06:00
Todd C. Miller
2fbce103f6
Change warning when user tries to sudoedit a symbolic link.
2015-08-07 07:09:01 -06:00
Todd C. Miller
3354d27a17
Do not follow symbolic links in sudoedit by default. This behavior
...
can be controlled by the sudoedit_follow Defaults flag as well as
the FOLLOW/NOFOLLOW tags.
2015-08-06 13:20:01 -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
4a07b472f0
Only include stddef.h where it is needed.
2015-06-20 05:34:35 -06:00
Todd C. Miller
c36415417f
Add function name to "unable to allocate memory" warnings.
2015-06-19 14:51:17 -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
cb63ca701c
Avoid using exiting allocators in the front end.
2015-06-17 17:00:54 -06:00
Todd C. Miller
ee72cba937
Use futimens() and utimensat() instead of futimes() and utimes().
2015-03-02 13:58:50 -07:00
Todd C. Miller
f25cf99679
Our utimes() emulation support futime() too.
2015-02-28 15:13:19 -07:00
Todd C. Miller
973286c7ac
Check the return value of gettimeofday(), even though it should
...
never fail.
2015-02-25 07:10:25 -07: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
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
79f209dbd7
Fix restoration of effective uid/gid in command_details.
...
This masked the effects an unset (really zero) egid.
Bug 656
2014-08-25 11:30:03 -06:00
Todd C. Miller
5676d9874d
Don't leak temp fd in sudo_edit_copy_tfiles().
...
Fix fd leak in error path in sudo_edit_copy_tfiles().
2014-08-25 10:42:59 -06:00
Todd C. Miller
a8f63191ef
Sprinkle some debugging around uid/gid setting in sudoedit.
2014-08-21 15:42:35 -06:00
Todd C. Miller
db35c7c0e4
Make sudoedit work with SELinux RBAC.
...
Adapted from RedHat patches (Daniel Kopecek) but made to behave a
bit more like the non-SELinux bits.
2014-08-21 15:28:36 -06:00
Todd C. Miller
a147330f3f
Refactor code that copies temp files into separate functions.
2014-08-21 15:28:35 -06:00
Todd C. Miller
7a988d489c
It is now sudo_efree() not efree().
...
Don't try to free a pointer to garbage on error.
2014-07-30 09:46:48 -06:00
Todd C. Miller
edf0d39703
Plug memory leak, even though we are headed for exit.
2014-07-29 19:33:55 -06:00
Todd C. Miller
6f77ffd7c7
Don't memcpy() the preserved_fds TAILQ as the pointers into the
...
head will be wrong. All we need to do is save the old command
details and restore them after calling run_command(). Fixes a hang
with sudoedit when debugging is enabled.
2014-07-26 06:06:18 -06:00
Todd C. Miller
2be0929f22
Handle systems like AIX that lack a way to set the modification
...
time on open fds.
2014-06-27 11:47:16 -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
f029e3e744
Remove touch() from fileops.c and just call utimes/futimes directly.
...
Rename lock_file -> sudo_lock_file to avoid namespace pollution
2014-06-26 15:51:15 -06:00
Todd C. Miller
134b2a4228
Rename emalloc2() -> emallocarray() and erealloc3() -> ereallocarray().
2014-04-22 16:02:28 -06:00
Todd C. Miller
b813c4de48
Use sudo_timeval macros and remove compat macros from missing.h
2014-01-30 15:51:59 -07:00
Todd C. Miller
96eb2c4f8f
Add warning_gettext() wrapper function that changes to the user locale,
...
then calls gettext().
Add U_ macro that calls warning_gettext() instead of gettext().
Rename warning2()/error2() back to warning_nodebug()/error_nodebug().
2013-11-18 08:59: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
1f3ea50afd
Implement memset_s() and use it instead of zero_bytes().
...
A new constant, SUDO_CONV_REPL_MAX, is defined by the plugin
API as the max conversation reply length. This constant can be
used as a max value for memset_s() when clearing passwords
filled in by the conversation function.
2013-08-03 08:30:06 -06:00
Todd C. Miller
d6282d154a
Update copyright years.
2013-04-24 09:35:02 -04:00
Todd C. Miller
39acd2fcba
Rename error/errorx -> fatal/fatalx and remove the exit value as
...
it was always 1.
2013-04-18 14:07:59 -04: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
7b3d268687
Call gettext() on parameters for warning()/warningx() instead of
...
having warning() do it for us.
2012-11-25 09:34:04 -05:00
Todd C. Miller
595d3b2651
Display warning/error messages in the user's locale.
2012-11-08 15:37:44 -05:00
Todd C. Miller
dc727ff6d4
Fix compilation when seteuid() is not available.
2012-03-12 13:52:51 -04:00
Todd C. Miller
7799d01cfa
Quiet a bogus gcc warning.
2011-12-20 13:50:48 -05:00
Todd C. Miller
839919566e
Add debug_decl/debug_return (almost) everywhere.
...
Remove old sudo_debug() and convert users to sudo_debug_printf().
2011-10-22 14:40:21 -04:00