Commit Graph

39 Commits

Author SHA1 Message Date
Todd C. Miller
378d15f8fc Always update the stashed mtime of the temp file instead of using what
we have for the original because the time resolution of the filesystem the
temporary is on may not match that of the filesystem that holds the original.
Should fix bz #371 found by Philippe Levan.
2009-09-30 13:50:58 +00:00
Todd C. Miller
334c19a405 Fix a bug introduced with def_closefrom. The value of def_closefrom
already includes the +1.
2009-08-05 23:59:21 +00:00
Todd C. Miller
840acbd3ac Update copyright years. 2008-11-09 14:13:13 +00:00
Todd C. Miller
3cb9d538f9 use zero_bytes() instead of memset() for consistency 2008-11-02 14:51:16 +00:00
Todd C. Miller
4afceb8e92 Zero out sigaction_t before use in case it has non-standard entries. 2008-11-02 14:45:31 +00:00
Todd C. Miller
7bb5160394 add SUDO_EDITOR variable that sudoedit uses in preference to VISUAL or EDITOR 2008-10-08 20:56:17 +00:00
Todd C. Miller
8fa4ef591c Check EDITOR/VISUAL to make sure sudoedit is not re-invoking itself or sudo.
This allows one to set EDITOR to sudoedit without getting into an infinite
loop of sudoedit running itself until the path gets too big.
2008-09-14 20:07:49 +00:00
Todd C. Miller
5756ddfbeb Change how the mailer is waited for. Instead of having a SIGCHLD
handler, use the double fork trick to orphan the child that opens
the pipe to sendmail.  Fixes a problem running su on some Linux distros.
2008-06-21 00:34:47 +00:00
Todd C. Miller
32403a2d83 Fix sudoedit of a non-existent file. From Tilo Stritzky. 2007-09-03 20:28:15 +00:00
Todd C. Miller
5919eb1fa6 Call rebuild_env() in call cases.
Pass original envp to sudo_edit().
Don't allow -E or env var setting in sudoedit mode.
More accurate usage() when called as sudoedit.
2007-07-08 18:44:28 +00:00
Todd C. Miller
884b70acc9 Move password/group cache cleaning out of sudo_end{pw,grp}ent() so
we can close the passwd/group files early.
2006-07-31 17:51:44 +00:00
Todd C. Miller
b2a32d13c0 Move sudo_end{gr,pw}ent() until just before the exec since they
free up our cached copy of the passwd structs, including sudo_user
and sudo_runas.  Fixes a use-after-free bug.
2005-11-11 22:23:08 +00:00
Todd C. Miller
2566e6b7d8 Move declatation of struct timespec to its own include files for
systems without it since it needs time_t defined.
2005-06-23 03:04:35 +00:00
Todd C. Miller
778d587063 Update copyright years. 2005-02-12 22:56:07 +00:00
Todd C. Miller
3b8b88407f Add __unused to rcsids 2005-01-27 15:42:30 +00:00
Todd C. Miller
7d488657f0 Use TIME_WITH_SYS_TIME 2004-12-03 18:52:28 +00:00
Todd C. Miller
33db4b2edb Add check for 2-argument form of timespecsub (FreeBSD and BSD/OS) and
fix a typo in the gettimeofday check.
2004-11-25 17:09:31 +00:00
Todd C. Miller
2c2daa8eca Use: #include <config.h>
Not: #include "config.h"
That way we get the correct config.h when build dir != src dir
2004-11-19 18:39:14 +00:00
Todd C. Miller
6a78b91949 Make arg splitting in visudo and sudoedit consistent. 2004-11-19 17:55:14 +00:00
Todd C. Miller
88ce50751e paranoia when stripping trailing slashes from tempdir. 2004-11-17 15:33:45 +00:00
Todd C. Miller
900db20f7a On Digital UNIX _PATH_VAR_TMP doesn't end with a trailing slash so
chop off any trailing slashes we see and add an explicit one.
2004-11-16 20:54:37 +00:00
Todd C. Miller
51375f969f Add local error/warning functions like err/warn but that call an additional
cleanup routine in the error case.  This means we no longer need to compile
a special version of alloc.o for visudo.
2004-11-15 15:53:53 +00:00
Todd C. Miller
5ac82331be Simplify logic around open & stat of files and do sanity on edited
file even if we lack fstat (still racable but worth doing).
2004-09-16 16:58:03 +00:00
Todd C. Miller
12c78c0f6d Add sanity check so we don't try to edit something other than a regular file. 2004-09-15 16:16:20 +00:00
Todd C. Miller
c932482733 Rename ots -> omtim for improved readability. 2004-09-09 15:02:28 +00:00
Todd C. Miller
611b0ca14c Redo changes in revision 1.7. Don't really need to keep the temp
file open; re-opening it with the invoking user's euid is sufficient.
2004-09-08 18:38:06 +00:00
Todd C. Miller
0f056c0d5f Use timespec throughout. 2004-09-08 15:48:23 +00:00
Todd C. Miller
c0bfcc95c3 Add checks for st_mtim and st_mtimespec and add macros for pulling
the mtime sec and nsec out of struct stat.  These are used in sudo_edit()
to better tell whether or not the file has changed.
2004-09-07 19:57:00 +00:00
Todd C. Miller
7f772c822f Add an extra param to touch() for nsec 2004-09-07 19:55:37 +00:00
Todd C. Miller
707c3c2cb9 Call mkstemp() as the in invoking user so we don't have to chown the file later.
Only touch() the temp file if we can do it via the file descriptor.
Don't check for modification of the temp file if we lack fstat().
Catch errors read()ing the temp file.
2004-09-07 18:06:33 +00:00
Todd C. Miller
47d25da64b closefrom() is overkill, the only extra fds are the ones we opened so
just close those in the child.
2004-09-07 17:31:54 +00:00
Todd C. Miller
1c20ff1a6d Use utimes() and futimes() instead of utime() in touch(), emulating as needed.
Not all systems are able to support setting the times of an fd so touch()
takes both an fd and a file name as arguments.
2004-09-07 17:14:52 +00:00
Todd C. Miller
b701107b4e Keep the temp file open instead of re-opening after the editor has exited. 2004-09-06 16:11:42 +00:00
Todd C. Miller
6acae1b3be Better warning message when sudoedit is unable to write to the
destination file.
2004-08-17 19:11:47 +00:00
Todd C. Miller
21e3ca9cf8 More to a less restrictive, ISC-style license. 2004-02-13 21:36:43 +00:00
Todd C. Miller
4716ea9880 Do not require _PATH_USRTMP to be set. 2004-01-30 00:50:41 +00:00
Todd C. Miller
2af994ada6 Add a comment describing why we need to be notified about our child
stopping.
2004-01-23 00:22:28 +00:00
Todd C. Miller
5ccddf8176 Fix suspending the editor in -e mode. Because we do a fork() first
we need to be notified when the child has been stopped and then send
that same signal to ourself so the shell can do its job control thing.
2004-01-22 02:57:01 +00:00
Todd C. Miller
4dc5700a6d Add a new flag, -e, that makes it possible to give users the ability
to edit files with the editor of their choice as the invoking user,
not the runas user.  Temporary files are used for the actual edit
and the temp file is copied over the original after the editor is done.
2004-01-21 22:25:10 +00:00