Commit Graph

880 Commits

Author SHA1 Message Date
Corinna Vinschen
68085066b6 Fix signedness bug in Cygwin code
The Cygwin-specific pattern match code has a bug.  It checks
the size_t value returned by mbstowcs for being < 0.  The right
thing to do is to check against (size_t) -1.  Fix that.

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
2022-01-21 09:53:07 +11:00
Damien Miller
a1d42a6ce0 fix edge case in poll(2) wrapper
Correct handling of select(2) exceptfds. These should only be consulted
for POLLPRI flagged pfds and not unconditionally converted to POLLERR.

with and ok dtucker@
2022-01-14 14:09:38 +11:00
Damien Miller
61a1a6af22 OS X poll(2) is broken; use compat replacement
Darwin's poll(2) implementation is broken. For character-special
devices like /dev/null, it returns POLLNVAL when polled with
POLLIN.

Apparently this is Apple bug 3710161, which is AFAIK not public,
but a websearch will find other OSS projects rediscovering it
periodically since it was first identified in 2005 (!!)
2022-01-12 09:02:36 +11:00
Damien Miller
715c892f0a remove sys/param.h in -portable, after upstream 2021-12-22 09:02:50 +11:00
Damien Miller
e6e7d2654a previous commit broke bcrypt_pbkdf()
Accidentally reverted part of the conversion to use SHA512 from SUPERCOP
instead of OpenBSD-style libc SHA512.
2021-11-29 14:11:51 +11:00
Damien Miller
158bf854e2 sync bcrypt-related files with OpenBSD
The main change is that Niels Provos kindly agreed to rescind the
BSD license advertising clause, shifting them to the 3-term BSD
license.

This was the last thing in OpenSSH that used the advertising clause.
2021-11-29 12:30:22 +11:00
Darren Tucker
5a0f461904 Correct ifdef to activate poll() only if needed. 2021-11-28 15:31:37 +11:00
Darren Tucker
b7ffbb17e3 Allow for fd = -1 in compat ppoll overflow check.
Fixes tests on at least FreeBSD 6, possibly others.
2021-11-19 18:54:34 +11:00
Darren Tucker
d902d728df Correct calculation of tv_nsec in poll(). 2021-11-18 23:44:07 +11:00
Darren Tucker
21dd5a9a3f Add compat implementation of ppoll using pselect. 2021-11-18 23:11:37 +11:00
Darren Tucker
10b899a15c Don't trust closefrom() on Linux.
glibc's closefrom implementation does not work in a chroot when the kernel
does not have close_range.  It tries to read from /proc/self/fd and when
that fails dies with an assertion of sorts.  Instead, call close_range
ourselves from our compat code and fall back if that fails.  bz#3349,
with william.wilson at canonical.com and fweimer at redhat.com.
2021-11-10 12:34:25 +11:00
Darren Tucker
7a78fe63b0 Skip getline() on HP-UX 10.x.
HP-UX 10.x has a getline() implementation in libc that does not behave
as we expect so don't use it.  With correction from Thorsten Glaser and
typo fix from Larkin Nickle.
2021-11-06 21:09:48 +11:00
Damien Miller
a5ab488234 remove built-in support for md5crypt()
Users of MD5-hashed password should arrange for ./configure to link
against libxcrypt or similar. Though it would be better to avoid use
of MD5 password hashing entirely, it's arguably worse than DEScrypt.

feedback and ok dtucker@
2021-10-28 16:16:13 +11:00
Darren Tucker
207648d7a6 Include stdlib.h for arc4random_uniform prototype. 2021-09-29 20:03:58 +10:00
Darren Tucker
b6255593ed Increment nfds when coming from startup_pipe.
If we have to increase nfds because startup_pipe[0] is above any of the
descriptors passed in the fd_sets, we also need to add 1 to nfds since
select takes highest FD number plus one.  bz#3345 from yaroslav.kuzmin
at vmssoftware.com.
2021-09-08 18:39:44 +10:00
Darren Tucker
9a2ed62173 Also check pid in pselect_notify_setup.
Spotted by djm@.
2021-08-20 10:48:13 +10:00
Darren Tucker
deaadcb93c Prefix pselect functions to clarify debug messages 2021-08-20 08:39:33 +10:00
Darren Tucker
10e45654cf Fix race in pselect replacement code.
On the second and subsequent calls to pselect the notify_pipe was not
added to the select readset, opening up a race that om G. Christensen
discovered on multiprocessor Solaris <=9 systems.

Also reinitialize notify_pipe if the pid changes.  This will prevent a
parent and child from using the same FD, although this is not an issue
in the current structure it might be in future.
2021-08-20 08:30:42 +10:00
Tim Rice
e65198e52c openbsd-compat/openbsd-compat.h: put bsd-signal.h before bsd-misc.h
to get sigset_t from signal.h needed for the pselect replacement.
2021-08-14 13:08:07 -07:00
Darren Tucker
419aa01123 Add includes.h to compat tests.
On platforms where closefrom returns void (eg glibc>=2.34) the prototype
for closefrom in its compat tests would cause compile errors.  Remove
this and have the tests pull in the compat headers in the same way as
the main code.  bz#3336.
2021-08-11 09:21:09 +10:00
Darren Tucker
0f494236b4 lastenv is only used in setenv.
Prevents an unused variable warning on platforms that have setenv but
not unsetenv.
2021-07-27 17:45:34 +10:00
Darren Tucker
f841fc9c8c Fix ifdefs around get_random_bytes_prngd.
get_random_bytes_prngd() is used if either of PRNGD_PORT or PRNGD_SOCKET
are defined, so adjust ifdef accordingly.
2021-07-02 15:20:32 +10:00
Damien Miller
0767627cf6 wrap get_random_bytes_prngd() in ifdef
avoid unused static function warning
2021-07-02 14:30:23 +10:00
Darren Tucker
e409d79667 Try EGD/PRNGD if random device fails.
When built --without-openssl, try EGD/PRGGD (if configured) as a last
resort before failing.
2021-06-18 19:32:11 +10:00
Darren Tucker
e43a898043 Split EGD/PRNGD interface into its own file.
This will allow us to use it when building --without-openssl.
2021-06-18 18:32:51 +10:00
Darren Tucker
acb2887a76 Handle GIDs > 2^31 in getgrouplist.
When compiled in 32bit mode, the getgrouplist implementation may fail
for GIDs greater than LONG_MAX.  Analysis and change from ralf.winkel
at tui.com.
2021-06-17 21:03:19 +10:00
Darren Tucker
aa99b2d9a3 Clear notify_pipe from readset if present.
Prevents leaking an implementation detail to the caller.
2021-06-04 23:41:29 +10:00
Darren Tucker
6de8dadf6b space->tabs. 2021-06-04 23:24:25 +10:00
Darren Tucker
c867706507 Add pselect implementation for platforms without.
This is basically the existing notify_pipe kludge from serverloop.c
moved behind a pselect interface.  It works by installing a signal
handler that writes to a pipe that the select is watching, then calls
the original handler.

The select call in serverloop will become pselect soon, at which point the
kludge will be removed from thereand will only exist in the compat layer.
Original code by markus, help from djm.
2021-06-04 18:39:48 +10:00
Darren Tucker
eb68e669bc Include login_cap.h for login_getpwclass override.
On minix3, login_getpwclass is __RENAME'ed to __login_getpwclass50 so
without this the include overriding login_getpwclass causes a compile
error.
2021-05-27 21:14:15 +10:00
Darren Tucker
a6b4ec94e5 Add OPENBSD ORIGINAL marker. 2021-04-24 17:52:24 +10:00
Darren Tucker
80032102d0 ifdef out MIN and MAX.
In -portable, defines.h ensures that these are defined, so redefining
potentially causes a warning.  We don't just delete it to make any
future code syncs a little but easier.  bz#3293.
2021-04-08 13:25:57 +10:00
Damien Miller
57ed647ee0 polish whitespace for portable files 2021-04-03 17:47:37 +11:00
Darren Tucker
1cd67ee15c Move generic includes outside of ifdef.
This ensures that the macros in log.h are defined in the case where
either of --with-solaris-projects or --with-solaris-privs are used
without --with-solaris-contracts.  bz#3278.
2021-03-12 13:16:10 +11:00
Damien Miller
324449a68d support OpenSSL 3.x cipher IV API change
OpenSSL renamed the "get current CIPHER_CTX" IV operation in 3.x.
This uses the new name if available.

https://github.com/openssl/openssl/issues/13411

bz#3238 ok dtucker@
2021-02-18 12:06:25 +11:00
Damien Miller
845fe9811c prefer login_getpwclass() to login_getclass()
FreeBSD has login_getpwclass() that does some special magic for
UID=0. Prefer this to login_getclass() as its easier to emulate
the former with the latter.

Based on FreeBSD PR 37416 via Ed Maste; ok dtucker@
2021-02-18 11:27:09 +11:00
David Carlier
1cb6ce98d6 Using explicit_memset for the explicit_bzero compatibility layer.
Favoriting the native implementation in this case.
2021-02-05 17:07:03 +11:00
Darren Tucker
0f2e21c9dc Include stdio.h for FILE in misc.h.
Fixes build on at least OpenBSD.
2020-12-22 18:56:54 +11:00
Damien Miller
e51dc7fab6 SELinux has deprecated security_context_t
(it was only ever a char* anyway)
2020-11-13 13:46:28 +11:00
Damien Miller
33267feaff Remove checks for strict POSIX mkdtemp()
We needed a mkdtemp() that accepted template paths that did not
end in XXXXXX a long time ago for KRB4, but that code is long
deprecated. We no longer need to replace mkdtemp() for strictly
following POSIX. ok dtucker@
2020-10-27 16:50:38 +11:00
Damien Miller
f9ea651520 logging is now macros, remove function pointers 2020-10-17 11:51:20 +11:00
Damien Miller
86cc8ce002 use relative rather than system include here 2020-10-03 13:39:17 +10:00
Darren Tucker
05c215de8d Wrap stdint.h include in ifdef HAVE_STDINT_H. 2020-08-17 21:34:32 +10:00
Damien Miller
eaf2765efe sync memmem.c with OpenBSD 2020-08-10 13:24:20 +10:00
Damien Miller
32c63e75a7 wrap a declaration in the same ifdefs as its use
avoids warnings on NetBSD
2020-08-04 14:59:21 +10:00
Damien Miller
c9e3be9f4b undef TAILQ_CONCAT and friends
Needed for NetBSD. etc that supply these macros
2020-08-04 14:58:46 +10:00
Damien Miller
adfdbf1211 sync sys-queue.h with OpenBSD upstream
needed for TAILQ_CONCAT
2020-07-03 15:15:15 +10:00
Darren Tucker
b4556c8ad7 Add OPENBSD ORIGINAL marker to bcrypt_pbkdf. 2020-06-19 19:22:00 +10:00
Darren Tucker
1babb8bb14 Extra brackets around sizeof() in bcrypt.
Prevents following warning from clang 10:
bcrypt_pbkdf.c:94:40: error: expression does not compute the number of
  elements in this array; element type is ´uint32_tÂ[...]
  place parentheses around the ´sizeof(uint64_t)´ expression to
  silence this warning
2020-06-19 19:10:47 +10:00
Darren Tucker
8854724cce Sync rev 1.49.
Prevent infinite for loop since i went from ssize_t to size_t.  Patch from
eagleoflqj via OpenSSH github PR#178, ok djm@, feedback & ok millert@
2020-04-21 18:28:19 +10:00