mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-06-09 21:22:41 +00:00
Unix: fix doas auth PTY opening on OpenBSD
OpenBSD defines O_CLOEXEC, but rejects it in posix_openpt() with EINVAL. Retry with the POSIX pseudoterminal flags and then set FD_CLOEXEC explicitly so doas authentication can create its private PTY.
This commit is contained in:
@@ -119,13 +119,27 @@ namespace VeraCrypt
|
||||
static int OpenDoasAuthTerminal (string &slavePath)
|
||||
{
|
||||
#ifdef O_CLOEXEC
|
||||
bool fdCloseOnExec = true;
|
||||
int fd = posix_openpt (O_RDWR | O_NOCTTY | O_CLOEXEC);
|
||||
if (fd == -1 && errno == EINVAL)
|
||||
{
|
||||
// Some systems, including OpenBSD, only accept the POSIX
|
||||
// pseudoterminal flags here. Set close-on-exec below instead.
|
||||
fdCloseOnExec = false;
|
||||
fd = posix_openpt (O_RDWR | O_NOCTTY);
|
||||
}
|
||||
#else
|
||||
int fd = posix_openpt (O_RDWR | O_NOCTTY);
|
||||
#endif
|
||||
throw_sys_sub_if (fd == -1, "posix_openpt");
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#ifdef O_CLOEXEC
|
||||
if (!fdCloseOnExec && fcntl (fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
{
|
||||
close (fd);
|
||||
throw SystemException (SRC_POS);
|
||||
}
|
||||
#else
|
||||
if (fcntl (fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
{
|
||||
close (fd);
|
||||
|
||||
Reference in New Issue
Block a user