Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 921584 - gui-apps/swaylock-1.7.2 refuses to work with USE=" filecaps -pam"
Summary: gui-apps/swaylock-1.7.2 refuses to work with USE=" filecaps -pam"
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Matthew Thode ( prometheanfire )
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2024-01-07 18:56 UTC by Bruno
Modified: 2024-01-08 00:18 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to make swaylock with with file capabilities (suid-or-cap_dac_read.patch,3.08 KB, patch)
2024-01-07 19:05 UTC, Bruno
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno 2024-01-07 18:56:34 UTC
With USE=-pam and USE=filecaps the ebuild sets SYS_ADMIN file capabilities for /usr/bin/swaylock.

Swaylock on the other hand does security checks verifying it has geteuid()==0 and later it can drop privileges by testing it can setuid(0).

SYS_ADMIN capability does not make much sense as a value as what could be useful is rather CAP_DAC_READ_SEARCH to be able to read /etc/shadow.


Reproducible: Always

Steps to Reproduce:
1. install swaylock with USE="-pam fileaps"
2. attempt to lock screen

Actual Results:  
Screen does not lock and swaylock outputs the following to stderr:
   [swaylock-1.7.2/shadow.c:22] swaylock needs to be setuid to read /etc/shadow

Expected Results:  
Screen locks

Removing the filecaps option and make /usr/bin/swaylock SUID would be one solution.

Patching swaylock to allow it to accept CAP_DAC_READ_SEARCH (and fixing the capability applied) would be another option.
Comment 1 Bruno 2024-01-07 19:05:42 UTC
Created attachment 881655 [details, diff]
Patch to make swaylock with with file capabilities

This patch uses direct syscall to check/clear capabilities and verifies ability to read /etc/shadow rather than just looking at uid.

An alternative would be linking to libcap or libcap-ng and using cap_set_proc/cap_get_proc instead of the syscalls and thus being less Linux-specific.