Commit Graph

2377 Commits

Author SHA1 Message Date
Todd C. Miller
6c3d20cb41 Convert PVS-Studio comment to ANSI C. 2018-10-26 08:39:09 -06:00
Todd C. Miller
019279a4b8 Fix some mangled text in the license block. 2018-10-26 08:19:41 -06:00
Todd C. Miller
1b035b5426 Add padding option to cvtsudoers.
Bug #856
2018-10-25 08:40:25 -06:00
Todd C. Miller
cb588f2337 Pass --sourcetree-root to pvs-studio and don't check sudo_noexec.c.
Since we don't auto-generate dependencies for sudo_noexec.c we
can't easily check it from outside the source tree.  This
is not a problem as it just contains stub functions.
2018-10-22 09:12:17 -06:00
Todd C. Miller
c5df091123 Add pvs-studio target and associated production rules. 2018-10-21 08:46:05 -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
45652e6d71 Simplify range checks.
No need to check for ERANGE in the cases where we also check
that the value is <= INT_MAX.  Found by PVS-Studio.
2018-10-20 08:47:12 -06:00
Todd C. Miller
8c94175ba1 Avoid some PVS-Studio false positives. 2018-10-19 13:35:20 -06:00
Todd C. Miller
6786d53d45 In timestamp_open() no need to free cookie on error, it is NULL.
Found by PVS-Studio.
2018-10-19 13:32:24 -06:00
Todd C. Miller
deccfe68f1 Fix a memory leak on malloc() error in sudo_ldap_role_to_priv().
Coverity CID 188804
2018-10-18 15:38:54 -06:00
Todd C. Miller
84ef500061 Move the allocation of role to be immediately before in_role is set.
This makes it clear that when in_role == true, role is non-NULL.
Also remove two dead stores.
2018-10-18 14:43:08 -06:00
Todd C. Miller
2ff8f8601b Fix trimming of non-escaped trailing space in ldif_parse_attribute().
Found by PVS-Studio.
2018-10-18 14:29:33 -06:00
Todd C. Miller
c2d93b8c97 Simplify the logic surrounding sudoers_args in command_args_match().
We only need to check that sudoers_args is non-NULL once.
Found by PVS-Studio.
2018-10-18 14:24:55 -06:00
Todd C. Miller
54784a234c If sudo_ldap_get_values_len() fails goto cleanup instead of oom.
This is not strictly necessary as there's not anything to cleanup
in this case but it is more consistent with the code that follows.
2018-10-18 14:19:09 -06:00
Todd C. Miller
63afa569f7 Fix handling of timeout values in sudoers.
When passing the timeout back to the front end, ignore the
user-specified timeout if it is not set (initialized to 0).
Otherwise, sudo would choose a zero user-specified timeout over
the sudoers-specified timeout (non-zero).
2018-10-18 08:08:44 -06:00
Todd C. Miller
675fc34c3d Fix cut & pastos in cvtsudoers_make_gritem() 2018-10-17 09:54:53 -06:00
Todd C. Miller
60f0d65e22 Fix expected test output now that command_timeout is parsed correctly
in LDIF.
2018-10-17 06:57:06 -06:00
Todd C. Miller
25a58ba1ca Avoid potentially undefined behavior.
Found by PVS Studio.
2018-10-16 12:50:43 -06:00
Todd C. Miller
e1a402f1d6 sudo_ldap_parse_option() never returns '=' as the operator.
When parsing command_timeout, role, type, privs and limitprivs,
check that val is non-NULL instead.  Found by PVS Studio.
2018-10-16 12:49:34 -06:00
Todd C. Miller
a9fd783f20 Fix up #line entries that reference lex.sudoers.c. 2018-10-16 10:31:43 -06:00
Todd C. Miller
387672583e Fix workaround for broken sudo 1.8.7 timing files. 2018-10-13 08:08:16 -06:00
Todd C. Miller
fa7e6f3f04 Fix memory leak when reusing the runas list. We need to free the
member list itself as well as its contents.
2018-10-13 07:31:34 -06:00
Todd C. Miller
b89cf34b53 Replace sudo_fatal(NULL) with an "unable to allocate memory" message
that includes the function name.
2018-10-12 08:39:12 -06:00
Todd C. Miller
a71eb86a71 Add new -S option to sleep while the command was suspended.
The default behavior is now to not consider the time the command
was suspended as part of the normal inter-event delay.
2018-10-05 14:48:35 -06:00
Todd C. Miller
cf07dc0757 Add a suspend event type to the I/O log to log suspend/resume of
the command so we can skip that delay during replay.
2018-10-05 14:16:08 -06:00
Todd C. Miller
c0e8bde104 Add support for OpenLDAP's TLS_REQCERT setting in ldap.conf. 2018-09-27 09:58:10 -06:00
Todd C. Miller
2121693879 Move definition of TIME_T_MAX to sudo_util.h 2018-09-24 14:21:58 -06:00
Todd C. Miller
d537daf787 Treat LOGIN, LOGNAME and USER specially. If one is preserved
or deleted we want to preserve or delete all of them.
2018-09-24 05:30:28 -06:00
Todd C. Miller
5f61f2c0f4 Remove special handling of the USERNAME environment variable. It
used to be set on old versions of Fedora but that hasn't been the
case for some time.  It's worth noting that ssh doesn't set USERNAME
either.
2018-09-24 05:30:03 -06:00
Todd C. Miller
72ce2c807b In print_member_json_int() eliminate the need_newline variable
and just move the non-alias expansion printing bits into the
else clause, including the newline and comma printing.
2018-09-20 15:15:14 -06:00
Todd C. Miller
8bf279b11e Add regress test for bug #853 2018-09-20 15:10:15 -06:00
Todd C. Miller
8aad365082 When expanding an alias in print_member_json_int() avoid printing
an extra comma at the end of the entry.  Bug #853.
2018-09-20 14:56:25 -06:00
Todd C. Miller
1a9b932ffd regen 2018-09-02 06:29:32 -06:00
Todd C. Miller
27e549a3ef Allow for some clock drift due to ntpd, etc. 2018-08-31 09:22:59 -06:00
Todd C. Miller
470a7830dc If sudo_lock_file() fails for a reason other than the file already
being locked, give the user a chance to edit anyway.
2018-08-31 08:08:45 -06:00
Todd C. Miller
0715b55474 Quick sort is not a stable sort; use distinct sudoOrder values so
the output is predictable.
2018-08-30 14:43:24 -06:00
Todd C. Miller
a924b4610b Fix warnings on OpenIndiana (Illumos) 2018-08-30 14:06:18 -06:00
Todd C. Miller
765d99e1f9 Correct ldap_to_sudoers() return value. 2018-08-30 13:47:02 -06:00
Todd C. Miller
ae04b40c05 The sssd backend used to take the first match, assuming that entries
were sorted in descending order by sudoOrder.  That allowed it to
avoid iterating over the entire list of rules.  Now that we convert
to a sudoers parse tree, we need to convert rules in ascending
order, not descending.  The simplest way to accomplish this is to
simply iterate over the rules from last to first, reversing the
sort order.  Bug #849
2018-08-30 08:36:09 -06:00
Todd C. Miller
2221fbe2f1 Add some more ldif -> sudoers tests to verify sudoOrder. 2018-08-30 07:49:59 -06:00
Todd C. Miller
ea38e9d909 For conversion to a sudoers parse tree, ldap_entry_compare() now
needs to sort in ascending order, not descending.  Bug #849
2018-08-30 07:48:16 -06:00
Todd C. Miller
58445393a7 No need to set input_file for stdin in parse_ldif(); noted by clang analyzer. 2018-08-29 10:57:37 -06:00
Todd C. Miller
e0b413eb17 Use TIME_T_MAX when parsing the I/O log file timestamp and disallow
negative times.
2018-08-29 10:54:32 -06:00
Todd C. Miller
e318f27fba When parsing an I/O log timing line, store the result in a timespec,
not a double.  The speed factor (for scaling the delay) in sudoreplay
is still a double but we only need to adjust the delay if the factor
is something other than 1.0.
2018-08-29 09:57:12 -06:00
Todd C. Miller
f1f632665c Fix memory leak in test. 2018-08-29 07:38:27 -06:00
Todd C. Miller
2ff7870263 Update conversion of DID_* to KEPT_* to match the new values of
DID_* and KEPT_*.
2018-08-28 20:25:06 -06:00
Todd C. Miller
8acc29dc01 Set the LOGIN environment variable on AIX like we do LOGNAME. 2018-08-28 18:32:39 -06:00
Todd C. Miller
fdd7296122 Add a test for the 4-argument au_close() function found in Solaris
11 instead of assuming it is present if __sun is defined.  Fixes a
compilation error on OpenIndiana and older Solaris versions.
2018-08-27 13:50:23 -06:00
Todd C. Miller
901b2666fc Add ldif support to testsudoers 2018-08-27 05:21:04 -06:00
Todd C. Miller
4782b22a47 Move ldif -> sudoers conversion code into parse_ldif.c 2018-08-26 20:02:49 -06:00