Commit Graph

3234 Commits

Author SHA1 Message Date
Todd C. Miller
a2d27bc9ec Fix return value for non-interactive mode for non-standalone auth methods.
AUTH_NONINTERACTIVE was being stored in the wrong variable.
2022-01-05 16:41:19 -07:00
Todd C. Miller
513574ce10 Updated translations from translationproject.org 2022-01-05 11:13:01 -07:00
Todd C. Miller
d6ff97d837 defaults_var_matches() should return bool, not enum match_result.
Remove enum match_result as it is no longer used.
2022-01-05 11:12:07 -07:00
Todd C. Miller
72989bf83f Quiet two PVS-studio warnings. 2022-01-05 11:04:18 -07:00
Todd C. Miller
1b72f138e3 Remove PAM_TTY workaround for old, buggy PAM modules.
In the past, some PAM modules assumed that PAM_TTY was set and would
misbehave (or crash) if not.  This was primarily obsolete versions
of Linux-PAM, so it should now be safe to remove this.  Setting
PAM_TTY to an empty string can cause its own set of issues.
GitHub issue #74
2022-01-05 10:59:27 -07:00
Todd C. Miller
521ef37aea Push non-interactive mode checking down into the auth methods.
For "sudo -n" we only want to reject a command if user input is
actually required.  In the case of PAM at least, we may not need
to interact with the user.  Bug #956, GitHub issue #83
2022-01-04 18:57:36 -07:00
Todd C. Miller
296d876b76 userspec_overridden: fix checks when there is more than one userspec 2022-01-03 16:40:32 -07:00
Todd C. Miller
835079fa3f Fix merging of global/ALL entries when each input file has a host.
If a host is specified for the input file, cvtsudoers will bind
global Defaults to that host and change host "ALL" in a userspec
to the host name.  However, if all the input files have matching
hosts we can simplify the merged file by converting back to ALL
after resolving conflicts.
2022-01-03 13:23:22 -07:00
Todd C. Miller
e22cc72530 Back out changes to enable SELinux by default.
This may return in a future release in a different form.
2021-12-22 11:13:22 -07:00
Todd C. Miller
149e8208b5 cvtsudoers: fix a regression when merging matching Defaults.
If a host is specified with a sudoers file, we have to treat Defaults
as Defaults@host checking for duplicates.
2021-12-20 12:57:02 -07:00
Todd C. Miller
4ffc3142c5 add_defaults: add defs == NULL check to quiet coverity false positive 2021-12-18 07:54:26 -07:00
Todd C. Miller
dfc11d7483 When merging Defaults, allow a subsequent global Defaults (no
binding) to override a prior Defaults setting with a binding.
2021-12-17 18:59:29 -07:00
Todd C. Miller
6a2c5043a9 add_defaults: defs can never be NULL 2021-12-17 16:04:33 -07:00
Todd C. Miller
546d4f6246 Plug memory leak when making a default host-specific.
We don't need to allocate new space for the binding list,
just the members of the list.
2021-12-17 16:01:11 -07:00
Todd C. Miller
991ef32508 Add group_file, match_local, and passwd_file to cvtsudoers.conf.
Previously, these were only settable via command line options.
2021-12-16 15:42:06 -07:00
Todd C. Miller
7158b03b50 Add simple test for cvtsudoers merge functionality. 2021-12-12 10:28:09 -07:00
Todd C. Miller
955359af5d Updated translations from translationproject.org 2021-12-12 10:25:04 -07:00
Todd C. Miller
869994433f Add sudoers Spanish translation from translationproject.org 2021-12-12 10:24:53 -07:00
Todd C. Miller
c13b21c199 Avoid TOCTOU in sudo_mkdir_parents() using openat(2) and mkdirat(2).
This also allows us to make path const as it should be.
2021-12-11 08:35:18 -07:00
Todd C. Miller
55db239243 Sudo parsed "deref" and "tls_reqcert" in ldap.conf but didn't set the options.
The switch() in the sudo_ldap_set_options_table() function needed to be
updated to treat CONF_DEREF_VAL and CONF_REQCERT_VAL data types as int.
Fix from Dennis Filder.  Bug #1013.
2021-12-11 08:35:14 -07:00
Todd C. Miller
83defd3a6f Fix CodeQL "Multiplication result converted to larger type" warnings. 2021-12-10 13:33:07 -07:00
Todd C. Miller
3cd0ffade8 Updated translations from translationproject.org 2021-12-08 10:23:37 -07:00
Todd C. Miller
27121cff65 Update .pot files for 1.9.9 2021-12-08 10:22:02 -07:00
juspence
1d13533ea3 Allow sudo -g anyone and sudo -u anyone -g anytwo
When only the user (ALL) is specified explicitly, and the group is implied, only sudo -u works. Specifying both the user and group, like (ALL:ALL), is required to:

1) Use sudo -g by itself (with no -u user)
2) Use sudo -u and -g together, with a -g group that is different from the -u user's primary group
2021-12-04 17:41:13 -05:00
Todd C. Miller
0608a4ea6f cvtsudoers: better merging of lists that are not exact duplicates
When merging rules, if one list would be overridden by another,
remove the overridden rule and continue merging.
2021-11-29 11:50:40 -07:00
Todd C. Miller
003f9550f1 cvtsudoers: add -l option to log merge actions
The "-l logfile" option can be used to store a log of what
actions cvtsudoers took when merging multiple files.
For example, which aliases were renamed, which entries were overriden
or removed as duplicated.
2021-11-24 06:52:51 -07:00
Todd C. Miller
d83321388d Quiet a PVS Studio warning.
The warning that need_comma is always false is correct but in this
case it is better to use a consistent construct so that if the code
is re-ordered no bugs are introduced.
2021-11-20 09:40:06 -07:00
Todd C. Miller
e64a089aea Add reference counting to Defaults bindings.
Previously, we checked that the previous entry's binding pointer
was not the same while freeing.  However, to be able to merge
Defaults records we cannot rely on Defaults entries with the same
binding being immediately adjacent.  This removes the prev_binding
checks in favor of a reference count which allows us to plug the
memory leak in cvtsudoers when merging Defaults.
2021-11-20 08:01:37 -07:00
Todd C. Miller
aed51033e1 cvtsudoers: use init_parse_tree() to initialize a parse tree.
Also free the parse tree before exit.
2021-11-19 12:29:21 -07:00
Todd C. Miller
730ebabdba init_parse_tree() now takes ownership of lhost and shost, if any.
This means that lhost and shost in struct sudoers_parse_tree
are no longer const and that free_parse_tree() will free lhost/shost.
The only consumer that passed in lho.st/shost was the SSSD back-end
which has been updated to avoid a double-free.
2021-11-19 12:29:21 -07:00
Todd C. Miller
f5c6e2df7b cvtsudoers: merge userspecs when multiple sudoers files are specified
If a hostname is specified with the sudoers file, it will be used to
make the userspec host-specific, if possible.  Duplicate userspecs
are removed but conflicting entries are not currently pruned.
2021-11-19 12:29:21 -07:00
Todd C. Miller
d31109ded2 cvtsudoers: merge Defaults when multiple sudoers files are specified
If a hostname is specified with the sudoers file, it will be used to
make the Defaults setting host-specific, if possible.
Duplicate Defaults settings are removed and conflicts are warned about.
It is not possible to resolve all conflicts automatically.
2021-11-19 12:29:21 -07:00
Todd C. Miller
ab9e44a6ca cvtsudoers: merge aliases when multiple sudoers files are specified
Duplicate aliases are remove.  If there are conflicting alias names,
the conflicts are renamed by appending a numerical suffix.
For example, if there are two SERVERS Host_Aliases, the second one
will be renamed to SERVERS_1.
2021-11-19 12:29:21 -07:00
Todd C. Miller
33fbf59467 Add support for specifying the hostname as a prefix to the sudoers file.
If present, the host name is copied into the struct sudoers_parse_tree.
2021-11-16 19:00:56 -07:00
Todd C. Miller
4cb34a2015 cvtsudoers: parse multiple sudoers files and store them in a tail queue
In the future the parsed files will be merged before they are output.
2021-11-11 16:04:45 -07:00
Todd C. Miller
b1309f76db Add sudoers_parse_tree_list, a tail queue of struct sudoers_parse_tree.
This will be used to store multiple parse trees and merge them
into a single sudoers_parse_tree.
2021-11-11 15:40:51 -07:00
Todd C. Miller
09b82a22ca Add configure check for sha1sum and use "openssh dgst -sha1" if missing.
Only needed when building the seed corpus zip files.
2021-11-10 13:31:42 -07:00
Todd C. Miller
55d17eaa34 install_sudoers: fix return value when there is no temp file to install
This can happen when no changes were made.  Also preserve the edited
temp file on error if we are unable to move it into place.
2021-11-09 16:09:48 -07:00
Todd C. Miller
def7a51f4d Bump plugin version in test data to 1.18. 2021-11-09 13:59:36 -07:00
Todd C. Miller
8e656b63c8 free_defs_val: free rlimits like strings (which they are). 2021-11-09 13:45:06 -07:00
Todd C. Miller
288bb82543 Rename {check,set}_perms variable to {check,set}_mode.
Avoids a name clash with the set_perms() function.
2021-11-09 13:41:27 -07:00
Todd C. Miller
19065cb221 Use strtoul() on systems without strtoull().
We can assume that systems without strtoull() have 32-bit resource limits.
2021-11-08 18:21:15 -07:00
Todd C. Miller
f279df5e18 Add basic support for setting resource limits in sudoers.
The default for rlimit_core is "0,0"
Resource limits are passed back to the front-end in command_info[]
when set.
2021-11-08 17:46:19 -07:00
Todd C. Miller
cdd41af66f visudo: add -O and -P options to check/set owner and permissions.
This can be used in conjunction with the -c option to check that
the sudoers file ownership and permissions are correct.
Bug #1007
2021-11-06 12:37:13 -06:00
Todd C. Miller
a336a8422f Pass status of selinux sudoers setting to front-end as selinux-rbac.
The front-end uses this to decide whether or not to enable SELinux.
If selinux-rbac is true _or_ if it is not present and selinux_role or
selinux_type are set, SELinux support is enabled.
Previously, SELinux support was only enabled if a role was specified.
2021-11-05 12:32:02 -06:00
Todd C. Miller
4eebd53bce parse_gentime: use timegm() to generate time since the epoch
The timegm() function is non-standard but widely available.
Provide an implementation for those systems that lack it.
Bug #1006
2021-10-31 09:27:34 -06:00
Todd C. Miller
dcd2199f79 Take daylight saving time into consideration when computing offset.
Otherwise, the resulting time may be off by and hour, depending on
whether DST is currently active compared to the target time.
2021-10-31 08:42:49 -06:00
Todd C. Miller
cc6157d7d4 Add support for WolfSSL's OpenSSL compatibility layer.
Based on changes from Hayden Roche
2021-10-25 13:17:57 -06:00
Todd C. Miller
465bfbba72 regenerate dependencies 2021-10-25 12:32:02 -06:00
Todd C. Miller
88c577171e Make sure INET_ADDRSTRLEN and INET6_ADDRSTRLEN are defined. 2021-10-21 19:53:48 -06:00