Skip to content

Add support for OpenBSD#325

Open
landryb wants to merge 7 commits into
swaywm:masterfrom
landryb:support-openbsd
Open

Add support for OpenBSD#325
landryb wants to merge 7 commits into
swaywm:masterfrom
landryb:support-openbsd

Conversation

@landryb
Copy link
Copy Markdown

@landryb landryb commented Nov 10, 2023

OpenBSD has initial/wip wayland support, so add support for building/using swaylock on OpenBSD. It uses http://man.openbsd.org/auth_userokay for user authentication so integrates well with the various login methods.

There's no wordexp() on OpenBSD:

been able to use swaylock with image=/usr/local/share/backgrounds/xfce/xfce-blue.jpg in ~/.config/swaylock/config swaylock and it does what's expected.

Feedback welcome !

landryb added a commit to landryb/swayidle that referenced this pull request Nov 10, 2023
- like done in swaywm/swaylock#325, provide an alternative for swayidle
  configuration file lookup
- and provide a handrolled config line parser for 'timeout' commands, using
  strspn(), strchr() and asprintf()
- the latter is in recent POSIX so move _POSIX_C_SOURCE 200809L definition
  within #if HAVE_WORDEXP
- OpenBSD doesn't (and won't) have support for systemd/logind, so only care
  about timeout commands
@emersion
Copy link
Copy Markdown
Member

Our wordexp usage is indeed an abuse I'd say. We've already removed it from Sway but the patches have not been backported to swaylock/swayidle: https://github.com/swaywm/sway/blob/020a572ed615b8fe272c7566a27ee0abe73a58d7/sway/config.c#L364

Can we just completely get rid of it?

@landryb
Copy link
Copy Markdown
Author

landryb commented Nov 10, 2023

Our wordexp usage is indeed an abuse I'd say. We've already removed it from Sway but the patches have not been backported to swaylock/swayidle: https://github.com/swaywm/sway/blob/020a572ed615b8fe272c7566a27ee0abe73a58d7/sway/config.c#L364

Can we just completely get rid of it?

oh definitely ! i see that wordexp() is still used in https://github.com/swaywm/sway/blob/020a572ed615b8fe272c7566a27ee0abe73a58d7/sway/config.c#L659 though, but i'll try to backport/reuse what was done in swaywm/sway@1d62d6bfa at least for the config path lookup, and i can also remove its use from the image path lookup if that's okay with you.

@emersion
Copy link
Copy Markdown
Member

i see that wordexp() is still used

Yeah, that one is for include directives and is going to be much more tricky to drop because users do have env variable expansion and shell substitution in their config file (e.g. include $(uname -n)/*).

@landryb
Copy link
Copy Markdown
Author

landryb commented Nov 10, 2023

wordexp() usage dropped in 9c065d0 - i'll also backport the config bits to swaywm/swayidle#154, but i wouldnt know for the actual config lines parsing...

Comment thread meson.build
Comment on lines +114 to +117
elif is_openbsd
warning('The swaylock binary must be setgid when compiled with bsd auth')
warning('You must do this manually post-install: chgrp auth /path/to/swaylock ; chmod g+s /path/to/swaylock')
sources += ['bsdauth.c']
Copy link
Copy Markdown
Contributor

@WhyNotHugo WhyNotHugo Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use login_passwd(8) instead to avoid this requirement?

Running the locker as root likely has funny attack vectors.

E.g.: point WAYLAND_DISPLAY to another user's socket and lock their session.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swaylock already has a SUID-root mode for the shadow backend. We drop privileges early in the main process.

landryb and others added 7 commits November 10, 2025 12:54
it's already defined in /usr/include/math.h on OpenBSD
sprinkle #if HAVE_WORDEXP where used
include config.h first to only include wordexp.h if needed
OpenBSD doesn't have/need libcrypt or librt
backports/adapted from swaywm/sway@1d62d6bf

note: as a side effect, env vars can't be used anymore for image paths
@landryb
Copy link
Copy Markdown
Author

landryb commented Nov 10, 2025

rebased this PR on top of master, can anyone review it ? been using it in the port since it's creationg..

@emersion
Copy link
Copy Markdown
Member

Currently, swaylock doesn't have platform-specific code. I'm not sure we want to introduce some.

@WhyNotHugo
Copy link
Copy Markdown
Contributor

WhyNotHugo commented Nov 11, 2025 via email

@emersion
Copy link
Copy Markdown
Member

BSDs other than OpenBSD support PAM. BSD auth is specific to OpenBSD and is not compatible with other platforms.

@landryb
Copy link
Copy Markdown
Author

landryb commented Nov 12, 2025

And even if it's much more flexible, PAM is riddled with security issues, so i'm not sure it's a good argument here... oh well, @emersion in the end that's your choice.

@stspdotname
Copy link
Copy Markdown

You already carry some platform-specific code to support glibc. With swearwords.

@kennylevinsen
Copy link
Copy Markdown
Member

kennylevinsen commented Nov 12, 2025

And even if it's much more flexible, PAM is riddled with security issues, so i'm not sure it's a good argument here...

That's not really an argument, as that's the single solution used on the majority of unix derivatives.

I don't think it's final that we won't carry the OpenBSD bits, it's just that adding cross-platform code is always super annoying, especially from a testing/maintenance perspective. None of us maintainers are running OpenBSD, and while we can add a simple compile-test we'll have no clue if something breaks at runtime.

You already carry some platform-specific code to support glibc. With swearwords.

glibc isn't a platform, but swearing does feel like an appropriate response to needing #ifdef's for spec violations... :)

@landryb
Copy link
Copy Markdown
Author

landryb commented Nov 17, 2025

None of us maintainers are running OpenBSD, and while we can add a simple compile-test we'll have no clue if something breaks at runtime.

well, since im trying to upstream patches, that also means i'm using it, and that i plan to update it in our packages, and report regressions if upstream breaks runtime on untested platforms..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants