Todd C. Miller
1e03cbd0b4
sudo_term_is_raw: only try to lock the fd if it is a tty
...
This moves sudo_isatty() to libsudo_util so sudo_term_is_raw() can
use it. Fixes GitHub issue #335
2023-12-09 12:54:56 -07:00
Todd C. Miller
a6ac589cc1
sudo_term_restore: don't check c_cflag on systems with TCSASOFT.
...
If TCSASOFT is present, tcsetattr() will ignore c_cflag.
Fixes a bug where sudo_term_restore() would refuse to change
the terminal settings back if the PARENB control flag was set.
GitHub issue #326 .
2023-11-08 16:58:02 -07:00
Todd C. Miller
fabb6264fc
Better handling of multiple sudo processes modifying terminal settings.
...
1. Lock the terminal before tcgetattr/tcsetattr
2. Don't restore terminal settings if changed by another process
3. Don't set terminal to raw mode if it is already raw
GitHub issue #312
2023-10-16 19:27:27 -06:00
Todd C. Miller
e343e07543
Use #include <foo.h> instead of #include "foo.h" in most cases.
...
We rely on the include path to find many of these headers. It
especially doesn't make sense to use #include "foo.h" for headers
in the top-level include directory.
2023-09-25 10:13:28 -06:00
Todd C. Miller
49c7c1f4d3
Only cast TIOCSWINSZ to int on systems that might require it (AIX).
...
Otherwise we end up with a -Wconversion warning on systems where
the ioctl() request argument is unsigned long.
2023-09-15 10:26:29 -06:00
Todd C. Miller
7cb1f7f3a9
Cast TIOCSWINSZ to int to avoid overflow warning on 64-bit AIX.
2023-07-31 09:58:13 -06:00
Todd C. Miller
4b5480cf76
Quiet a warning false positive with older versions of gcc.
2023-07-17 11:23:04 -06:00
Todd C. Miller
625653de08
sudo_term_raw: change the isig argument into a flags field
...
There are current two flags: SUDO_TERM_ISIG (enable terminal signals)
and SUDO_TERM_OFLAG (preserve output flags).
2023-07-14 13:12:51 -06:00
Rose
e54ba33ea0
Avoid compiler casting warnings by assigning to the same type where possible
...
This saves instructions that are related to casting as well as compiler warnings.
2023-06-28 17:25:26 -04:00
Todd C. Miller
3e734fa51b
Correct a comment.
2023-03-23 08:20:48 -06:00
Todd C. Miller
e63eeee7b4
Add debug tracing to tcsetattr_nobg().
2023-02-02 09:31:25 -07:00
Todd C. Miller
803998d2bd
Only add trailing carriage return to messages if output is a raw tty.
...
If output is being written to a terminal in "raw" mode, we need to
add a carriage return after the newline to avoid "stair-step" output.
However, we should not write the carriage return if the terminal
is in "cooked" mode, output to a pipe, or output redirected to a file.
Bug #1042 .
2022-10-20 08:55:26 -06:00
Todd C. Miller
88dcdcd11d
Fix -Wshadow warnings.
2020-09-25 15:09:45 -06:00
Todd C. Miller
84e6e6ccf9
Update copyright year on some files where it was out of date.
2020-08-31 14:09:36 -06:00
Todd C. Miller
985af422d2
Rename __dso_public -> sudo_dso_public and move to config.h.
2020-08-12 09:57:42 -06:00
Todd C. Miller
446ae3f507
Include string.h unconditionally and only use strings.h for strn?casecmp()
...
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
dd88460800
We no longer need to include headers we don't use for sudo*.h files.
...
Previously we needed to include headers required by the various
sudo*h files. Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
486ee2b71f
debug_decl and debug_decl_vars now require a semicolon at the end.
2019-12-22 08:48:16 -07:00
Todd C. Miller
d7b4f88658
Use cfmakeraw() in sudo_term_raw() instead of doing it manually.
2019-12-07 12:25:51 -07:00
Todd C. Miller
cd2cfeb8cb
It is safe to assume _POSIX_VDISABLE is defined.
...
The old compat defines were to support pre-termios systems.
2019-05-16 12:24:48 -06:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
6c3d20cb41
Convert PVS-Studio comment to ANSI C.
2018-10-26 08:39:09 -06:00
Todd C. Miller
64e5d34c57
Add comments in .c files so PVS-Studio will check them.
2018-10-21 08:46:05 -06:00
Todd C. Miller
2b56252210
Handle EOF on password input when pwfedback is enabled.
2018-10-08 06:47:53 -06:00
Todd C. Miller
6953e7fc79
Move updating of the window size to the monitor process.
...
This will allow us to close the slave in the main sudo process in
the future so only the command and monitor have it open.
2018-08-20 10:04:14 -06:00
Todd C. Miller
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00
Todd C. Miller
6505d05803
Clear input, output, control and local flags before copying them
...
from the source terminal. Otherwise, flags that are disabled
in the source terminal may still be enabled in the destination.
2017-07-12 05:47:28 -06:00
Todd C. Miller
c77c5d026a
When copying terminal settings from one tty to another only copy a
...
subset of the flags. Sudo now copies the same set of flags that
OpenSSH uses, which should be safe.
2017-06-15 12:59:46 -06:00
Todd C. Miller
d979898e71
Remove use of non-standard sigaction_t
2017-05-12 10:02:18 -06:00
Todd C. Miller
0c70df5de9
Implement suspend/resume callbacks for the conversation function.
...
If suspended, close the timestamp file (dropping all locks). On
resume, lock the record before reading the password.
For this to work properly we need to be able to run th callback
when tsetattr() suspends us, not just when the user does. To
accomplish this the term_* functions now return EINTR if SIGTTOU
would be generated. The caller now has to restart the term_*
function (and send itself SIGTTOU) instead of it being done
automatically.
2015-09-07 06:06:08 -06:00
Todd C. Miller
e941f97eb4
Replace two "return 0" with debug_return_bool(false).
2015-07-22 19:11:32 -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
8088806bd8
Update function names in debug_decl.
2015-03-10 11:09:25 -06:00
Todd C. Miller
ef1b2c3beb
Use TCSAFLUSH instead of TCSANOW in sudo_term_copy().
...
Be consistent with where we put TCSASOFT in the action flags.
2015-03-10 08:55:01 -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
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
47835ff289
Rename missing.h -> sudo_compat.h
2014-07-22 14:25:16 -06:00
Todd C. Miller
844a285391
Version the functions in libsudo_util
2014-07-22 11:26:17 -06:00
Todd C. Miller
d36846a699
Reduce name space pollution in libsudo_util.so
2014-06-26 16:21:19 -06:00
Todd C. Miller
088edcb6f5
Add exported libsudo_util functions to util.exp and mark in headers
...
using __dso_public.
2014-06-26 15:51:15 -06:00
Todd C. Miller
4d37a4a162
Top level directory reorg
...
Move src/po -> po
Combine common and compat -> lib/util
Move zlib -> lib/zlib
2014-06-26 15:51:02 -06:00