Todd C. Miller
fc7bfd5046
Move OpenSSL compat defines to sudo_ssl_compat.h
2023-08-05 14:16:39 -06:00
Todd C. Miller
a432aed4f0
realpath.c: include limits.h and use sysconf(_SC_SYMLOOP_MAX)
...
This is more portable and eliminates the need to check for SYMLOOP_MAX
(and provide it if missing) in configure. Also quiet some -Wconversion
warnings.
2023-07-10 15:52:16 -06:00
Rose
5d758264ab
Give every printf-like function restrict qualifiers
...
The format value has to be a string literal, every time.
Otherwise, you are not using these functions correctly. To reinforce this fact, I putrestrict over every non-contrib example of this I could find.
2023-07-07 20:23:20 -04:00
Todd C. Miller
f5d0b7abf7
Remove portable getcwd.c, nothing uses it anymore.
...
Any operating system supported by sudo already includes getcwd(3).
2023-03-16 15:01:41 -06:00
Todd C. Miller
6c97b84c0c
Make the check for HAVE_DECL_NSIG consistent with other decl checks.
2023-02-27 18:44:54 -07:00
Todd C. Miller
0443d14578
Add checks for realpath(3) and a version from NetBSD for those without it.
2023-02-12 13:27:17 -07:00
Todd C. Miller
ffb09be49d
Add configure test for NSIG, _NSIG or __NSIG.
...
This is better than just defining NSIG in sudo_compat.h if it is
not defined since signal.h may not have been included.
2023-01-31 11:30:45 -07:00
Todd C. Miller
16ae61dcd7
Use C23 [[__fallthrough__]] and [[__noreturn__]] attributes if supported.
...
If the C23 attributes are not supported, use gcc-style attributes
where possible.
2022-11-29 16:28:27 -07:00
Todd C. Miller
3e8497b5ce
Remove CMSG_* compatibility macros, they are no longer used.
2022-11-09 15:24:28 -07:00
Todd C. Miller
d37710b0f6
Use mkdtempat_np() and mkostempsat_np() on macOS
2022-09-22 11:34:00 -06:00
Todd C. Miller
376d18b5da
Add fchownat() systems without it.
2022-09-21 19:08:12 -06:00
Todd C. Miller
86c108b50b
Add mkdtempat() and mkostempsat() for systems without them.
2022-09-21 19:08:11 -06:00
Todd C. Miller
304726a215
Move gcc-style __attribute__ macros to config.h.in
...
Renamed __malloc -> sudo_malloclike, __printflike -> sudo_printflike,
__printf0like -> sudo_printf0like.
Add sudo_noreturn instead of __attribute__((__noreturn__)).
We do not use stdnoreturn.h since it has been deprecated in C23
in favor of the [[noreturn]] attribute.
2022-09-07 07:48:31 -06:00
Todd C. Miller
882990b1b3
Use gcc's malloc attribute for malloc-like allocation functions.
2022-07-26 15:14:03 -06:00
Todd C. Miller
169e049821
Fix typo, we should define SSIZE_MAX if it is not defined.
2022-06-10 09:34:33 -06:00
Todd C. Miller
46edc4e198
Stop using the WCONTINUED flag with waitpid(2).
...
We don't use it for anything other than a debug message and it will
cause problems when intercept mode starts using ptrace(2).
2022-04-29 08:02:57 -06:00
Todd C. Miller
2e957cd43d
Fix compilation on Debian kFreeBSD.
...
The configure script correctly detects that utimensat() and futimens()
are missing but the headers define stub versions of the functions.
Including sys/stat.h pulls in the system definitions so we can override
them safely. Bug #1021 .
2022-02-03 09:33:30 -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
c2d03f7cca
sudo_compat.h: include unistd.h regardless of OS type
...
This helps to avoid issues with mismatched headers and libraries.
2021-11-10 13:30:27 -07: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
b506497fe4
Fix pasto in gmtime_r and localtime_r macros.
...
Also add missing Makefile targets for them.
2021-10-31 09:01:18 -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
fa71679b5a
Add gmtime_r and localtime_r tests and compat if missing.
2021-09-17 10:55:06 -06:00
Todd C. Miller
e199dd8254
sudo_compat.h: include unistd.h on HP-UX to safely redefine pread/pwrite
...
HP-UX 11.31 defines static functions for pread() and pwrite() which
will conflict with our macros.
2021-08-25 16:31:46 -06:00
Todd C. Miller
ad28b90c4d
We still need the pread/pwrite hack for HP-UX 11.11 at least.
...
This time around, avoid defining _LARGEFILE64_SOURCE and just declare
pread64/pwrite64 ourselves.
2021-08-19 19:18:24 -06:00
Todd C. Miller
23e5304b78
Fix prototypes for sudo_pread() and sudo_pwrite().
2021-08-19 19:05:50 -06:00
Todd C. Miller
62aca803ce
Older Solaris has getusershell() et al but does not declare it.
2021-08-13 09:52:02 -06:00
Todd C. Miller
a556b373c9
Allocate a socketpair to communicate with sudo_intercept.so over.
...
This is used for the intercept and log_children options.
2021-08-09 15:50:25 -06:00
Todd C. Miller
36fbb13c4c
Use TLS_method() instead of TLS_client_method() throughout.
...
OpenSSL returns an error for SSL_accept() if TLS_client_method()
was used to generate the context (LibreSSL doesn't care).
Prior to sudo 1.9.7, TLS_client_method() and TLS_server_method()
were used in the TLS client and server initialization code respectively.
This was refactored in sudo 1.9.7 to allow the code to be shared.
Bug #988
2021-07-26 13:40:25 -06:00
Todd C. Miller
4a90deb2a0
Add configure check for va_copy instead of using #ifdef
...
This prevents the va_copy compat #define from being used if
sudo_compat.h is somehow included before stdarg.h.
2021-07-25 15:51:23 -06:00
Todd C. Miller
cc3b4ffb04
Remove vsyslog(3) emulation, it is no longer used.
2021-06-14 13:11:39 -06:00
Todd C. Miller
d9d450292d
Remove compatibility defines for POSIX sys/stat.h macros.
...
Modern systems have them and we no longer support pre-POSIX systems.
This fixes potential redefinition of the macros if sys/stat.h is
included after sudo_compat.h. Bug #968 .
2021-03-10 12:26:11 -07:00
Todd C. Miller
e392646ed4
Add configure check for SSIZE_MAX
2021-02-08 18:38:17 -07:00
Todd C. Miller
9e068c15e0
Add setprogname(3) for those without it.
2021-01-06 13:01:09 -07:00
Todd C. Miller
06bfbecd64
Add emulation of pread(3) and pwrite(3) for systems without them.
...
This makes it possible to remove some ugly #ifdefs and only affects
very old systems.
2021-01-02 10:43:34 -07: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
ce97ca28db
Use OpenBSD-compatible freezero() in place of explicit_bzero() + free()
2020-08-10 19:24:33 -06:00
Todd C. Miller
cef6e3687e
Switch from memset_s() -> explicit_bzero().
...
memset_s() (and all of Annex K) is likely to be removed from the
a future version of the standard.
2020-08-10 19:24:32 -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
48c2bd0007
Declare getdelim(3) if it exists in libc but is not prototyped in stdio.h.
...
This can happen on systems with a gcc packages that was built on
and older versions of the OS where getdelim(3) was not present.
2020-06-06 18:45:27 -06:00
Todd C. Miller
d85d370c63
Add dependent system includes to make sudo_*.h more standalone.
...
In the past we've relied on the various .c files to include the
system headers that define types that the sudo_*.h headers require.
This is fragile and can cause issues when includes get re-ordered.
2020-05-18 04:47:21 -06:00
Todd C. Miller
ea1226be7c
Only define WCONTINUED and WIFCONTINUED if neither are already defined.
...
Fixes a warning on musl libc where WIFCONTINUED is defined in
stdlib.h for some reason.
2020-05-15 18:50:04 -06:00
Todd C. Miller
92e42ff548
Add compatibility define for fseeko(3).
...
This is better than cluttering up the code with #ifdefs for obsolete
systems.
2020-02-15 10:22:15 -07:00
Todd C. Miller
dde86e585f
Add support for building on OpenSSL 1.0.2.
...
This adds compatibility defines for some OpenSSL 1.1.x functions.
2020-01-21 13:27:40 -07:00
Todd C. Miller
c3bd025052
Store the server host name and IP in client_closure_fill().
...
Also check for getpeername() and inet_ntop() failure.
2020-01-20 14:03:41 -07:00
Todd C. Miller
291221c698
Older systems may not support WCONTINUED.
2019-12-25 11:17:35 -07:00
Todd C. Miller
4690d3ecf6
Add cfmakeraw() for systems without it.
2019-12-23 13:15:34 -07:00
Todd C. Miller
b14d633ec6
Add runas_check_shell flag to require a runas user to have a valid shell.
...
Not enabled by default.
2019-12-09 19:29:45 -07:00
Todd C. Miller
43df086186
Add dup3() emulation.
2019-11-02 10:52:55 -06:00
Todd C. Miller
dbf78d0716
Add fchmodat() and fstatat() emulation.
...
Note that fchmodat() emulation does not support AT_SYMLINK_NOFOLLOW
2019-10-24 20:04:33 -06:00