Todd C. Miller
b9a0c72fd1
Don't report a usage error for "sudo -V".
...
GitHub issue #95
2021-03-30 15:17:31 -06:00
Todd C. Miller
19d5845f8b
The program name may now only be "sudo" or "sudoedit".
...
We no longer need to check for any string that ends in "edit".
2021-01-26 11:33:05 -07:00
Todd C. Miller
c0eecf85c8
Don't assume that argv is allocated as a single flat buffer.
...
While this is how the kernel behaves it is not a portable assumption.
The assumption may also be violated if getopt_long(3) permutes arguments.
Found by Qualys.
2021-01-23 08:44:00 -07:00
Todd C. Miller
b301b46b79
Reset valid_flags to MODE_NONINTERACTIVE for sudoedit.
...
This is consistent with how the -e option is handled.
Also reject -H and -P flags for sudoedit as was done in sudo 1.7.
Found by Qualys, this is part of the fix for CVE-2021-3156.
2021-01-23 08:43:59 -07:00
Todd C. Miller
1676f0ceeb
Support "*" for CWD/CHROOT to allow user to specify cwd or chroot.
...
Adds two new command line options, -D (--chdir) and -R (--chroot)
that can only be used when sudoers sets runcwd or runchroot to "*".
2020-09-01 14:10:02 -06:00
Todd C. Miller
a940a2c78e
Fix some warnings from pvs-studio
2020-08-12 20:01:39 -06:00
Todd C. Miller
961a4afe67
Fix some warnings from pvs-studio
2020-08-12 13:45:09 -06:00
Todd C. Miller
cbad17a994
Move inclusion of compat headers up with the system headers.
...
Now that sudo_dso_public is defined in config.h we don't need sudo_compat.h
before including the compat headers.
2020-08-12 10:07:07 -06:00
Todd C. Miller
03ad96e445
Use the fallthrough attribute instead of /* FALLTHROUGH */ comments.
2020-08-01 13:10:50 -06:00
Todd C. Miller
df49897bd0
Replace or remove use of `scare quotes'
...
These don't translate well and look odd in many fonts.
2020-06-24 05:40:18 -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
92199e25c4
The --preserve-env=list option may be specified more than once.
2020-05-07 11:11:43 -06:00
Todd C. Miller
4266279c0c
Don't allow duplicate values for command line options that take an argument.
...
Previously, if multiple instances of the same command line option were
specified, the last one would be used. This meant that, for example,
"sudo -u someuser -u otheruser id" would run the command as "otheruser".
This has the potential to cause problems for programs that run sudo with
a user-specified command that do not use the "--" option to indicate
that no more options should be processed. While this is a bug in
the calling program, there is little downside to erroring out when
multiple options of the same type are specified on the command line.
Bug #924
2020-05-06 19:33:24 -06:00
Todd C. Miller
ac61b5655d
Use EXIT_SUCCESS and EXIT_FAILURE more consistently.
2020-02-08 12:43:00 -07:00
Todd C. Miller
c5afbf00fc
Mark main sudo usage() function __noreturn__.
...
This splits the usage printing out into display_usage().
2020-02-08 12:17:33 -07:00
Todd C. Miller
22105009d8
Define a new plugin type that receives accept and reject messages.
...
This can be used to implement logging-only plugins.
The plugin functions now take an errstr argument that can be used
to return an error string to be logged on failure or error.
2020-01-30 13:25:34 -07: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
2512f6efbf
Use sudo_strtonum() explicitly instead of via a macro.
2019-10-14 10:09:30 -06:00
Todd C. Miller
d35670d1ae
Silence a warning from clang about string concatenation.
2019-09-17 08:25:33 -06:00
Todd C. Miller
ffaef7939a
Add asserts() to avoid static analyzer false positives.
2019-08-30 11:13:35 -06:00
Todd C. Miller
19c548fd57
Add -B option to ring the bell before the password prompt.
2019-05-27 08:49:43 -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
cf9c0102d4
Only set MODE_PRESERVE_ENV when preserving the entire environment.
...
Fixes a problem introduced in 1.8.23 where "sudo -i" could not be
used in conjunction with --preserve-env=VARIABLE. Bug #835
2018-05-16 09:10:43 -06:00
Todd C. Miller
4b29e0bd70
Restore line to set MODE_PRESERVE_ENV in flags when the -E command
...
line option is used. The caller doesn't check MODE_PRESERVE_ENV
these days but parse_args uses it to detect usage errors when -E
is used along with a mutually excusive option. Problem found by
Yuriy Vostrikov.
2018-02-28 07:05:36 -07:00
Todd C. Miller
5106bfc139
Allow the plugin to determine whether or not an empty timeout is
...
allowed. For sudoers, an error will be returned for an empty timeout.
2017-12-11 09:20:41 -07:00
Todd C. Miller
bbc43b5e30
Change some _() into U_() since they are used for warn/fatal.
...
We always want to issue warnings in the user's locale.
2017-12-11 08:07:01 -07:00
Todd C. Miller
d322caf7ac
Print usage and return an error when an empty argument is given for
...
all command line arguments other than -p and -E. Bug #817
2017-12-10 07:53:09 -07:00
Todd C. Miller
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00
Todd C. Miller
c18dde2350
Allow the user to specify a list of environment variables to preserve.
...
This adds an option paramter to the --preserve-env option, a
comma-separated list of variable names.
2017-08-03 07:32:24 -06:00
Todd C. Miller
c86a6a23ad
Add a command line option to specify the command timeout, as long
...
as sudoers does not specify a shorter time limit.
2017-02-16 09:58:18 -07:00
Todd C. Miller
6dff4ac7fd
Always define _PATH_SUDO_NOEXEC, _PATH_SUDO_SESH, _PATH_SUDO_PLUGIN_DIR,
...
even if only defined to NULL. This means the accessors can always be
present.
Use RTLD_PRELOAD_VAR instead of _PATH_SUDO_NOEXEC to tell when
noexec is available.
Add ENABLE_SUDO_PLUGIN_API and use it instead of _PATH_SUDO_PLUGIN_DIR
to tell when the plugin API is available.
Add sudo_conf_clear_paths() to clear the path values so the
regress tests are not affected by compile-time settings.
2016-11-16 10:13:26 -07:00
Todd C. Miller
efe957544f
Add the argument vector allocated for -s and -i mode to the garbage
...
collector list. Avoids an ASAN warning on exit when the -s or -i
flags are used.
2016-11-10 10:11:18 -07: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
fc7143760b
Fix indentation of -a flag help line.
2015-05-11 13:34:41 -06:00
Todd C. Miller
0008747bef
Bail with usage() early if argc <= 0.
2015-02-06 09:17:39 -07:00
Todd C. Miller
67eba7e534
Don't assume argv[0] is set without first checking argc.
2015-02-05 11:17: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
a7e724b75d
Change how sudo.conf is parsed. We now do a quick parse and then
...
set the values after the entire file has been parsed. This lets
us init the debug system earlier. Plugin-specific debug flags are
now stored in struct plugin_info and struct plugin_container and
passed to the plugin via one or more debug_flags settings.
2014-10-22 13:20:32 -06:00
Todd C. Miller
1e0b8903f2
Return settings from parse_args as struct sudo_settings and format
...
for the plugin at plugin open time. This will allow for additional,
plugin-specific settings to be added to the array.
2014-10-22 13:13:00 -06:00
Todd C. Miller
1cc2433428
If we were invoked with any name ending in "edit", treat as sudoedit.
2014-09-08 09:37:39 -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