diff options
author | Antoine Jacoutot <ajacoutot@openbsd.org> | 2019-02-10 18:37:48 +0100 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@openbsd.org> | 2020-11-22 11:02:10 +0100 |
commit | 337bda5427df5c52eeaab862cf3ba327048497f3 (patch) | |
tree | 81e2a1f7c277544876241711188d7c3900018d45 | |
parent | 735ae642100c8fef95826186aa2ef749c015cc53 (diff) | |
download | ConsoleKit2-337bda5427df5c52eeaab862cf3ba327048497f3.tar.gz |
ck_open_a_console: unbreak on OpenBSD
OpenBSD only allows change-setting ioctls when FWRITE is set on
the descriptor.
-rw-r--r-- | src/ck-sysdeps-unix.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c index a7814aa..b46905b 100644 --- a/src/ck-sysdeps-unix.c +++ b/src/ck-sysdeps-unix.c @@ -259,9 +259,15 @@ ck_open_a_console (char *fnam) again: #endif /* __linux__ */ +/* OpenBSD only allows change-setting ioctls when FWRITE is set on the fd */ +#ifdef __OpenBSD__ + fd = open (fnam, O_WRONLY | O_NOCTTY); +#else fd = open (fnam, O_RDONLY | O_NOCTTY); if (fd < 0 && errno == EACCES) fd = open (fnam, O_WRONLY | O_NOCTTY); +#endif + #ifdef __linux__ if (fd < 0 && errno == EIO) { /* Linux can return EIO if the tty is currently closing, |