Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket perms for system-wide access ? #231

Open
pgnd opened this issue Mar 2, 2024 · 4 comments
Open

socket perms for system-wide access ? #231

pgnd opened this issue Mar 2, 2024 · 4 comments

Comments

@pgnd
Copy link

pgnd commented Mar 2, 2024

i've built/installed ydotool from src

i'm working on the required socket perms, hoping to harden access

it's launched via systemd

...
[Service]
UMask = 0117
User=ydotool
Group=input
PermissionsStartOnly=true
ExecStart=/usr/local/ydotool/bin/ydotoold \
 --socket-path=/run/ydotool/ydotoold.sock \
 --socket-perm=0660
...

it's up

ps aux | grep ydotool
	ydotool   9129  0.0  0.0   2476  1536 ?        Ss   11:37   0:00 /usr/local/ydotool/bin/ydotoold --socket-path=/run/ydotool/ydotoold.sock --socket-perm=0660

ls -alR /run/ydotool
	/run/ydotool:
	total 0
	drwxrwx---  2 ydotool input   60 Mar  2 11:47 ./
	drwxr-xr-x 49 root    root  1.4K Mar  2 10:42 ../
	srw-rw----  1 ydotool input    0 Mar  2 11:47 ydotoold.sock=

my local desktop and ydotool users have been added to the input group

id ydotool
	uid=376(ydotool) gid=377(ydotool) groups=377(ydotool),999(input)

getent group input
	input:x:999:ydotool,pgnd

at shell, as my user,

whoami
	pgnd
YDOTOOL_SOCKET=/run/ydotool/ydotoold.sock /usr/local/ydotool/bin/ydotool type 'TESTTEST'

fails with

failed to connect to socket `/run/ydotool/ydotoold.sock': Permission denied
Please check if the current user has sufficient permissions to access the socket file

if i open the sock's perms

chmod 777 /run/ydotool
chmod 666 /run/ydotool/ydotoold.sock
ls -alR /run/ydotool
	/run/ydotool:
	total 0
	drwxrwxrwx  2 ydotool input   60 Mar  2 11:47 ./
	drwxr-xr-x 49 root    root  1.4K Mar  2 10:42 ../
	srw-rw-rw-  1 ydotool input    0 Mar  2 11:47 ydotoold.sock=

then exec of

YDOTOOL_SOCKET=/run/ydotool/ydotoold.sock /usr/local/ydotool/bin/ydotool type 'TESTTEST'

types, as intended,

TESTTEST

also,

chmod 770 /run/ydotool
chmod 660 /run/ydotool/ydotoold.sock
sudo -u ydotool YDOTOOL_SOCKET=/run/ydotool/ydotoold.sock /usr/local/ydotool/bin/ydotool type 'TESTTEST'

users ydotool & pgnd, both as members of input group, should have equivalent r/w perms for the socket, no?

am i missing a config/assumption re: needed perms?

@pgnd
Copy link
Author

pgnd commented Mar 2, 2024

adding suid to rpm post-install

	%post
	...
+	chown ydotool:input /path/to/bin/ydotool
+	chmod +s /path/to/bin/ydotool

so that, with above config,

ls -al /run/ydotool/
	total 0
	drwxrwx---  2 ydotool input   60 Mar  2 16:09 ./
	drwxr-xr-x 49 root    root  1.4K Mar  2 10:42 ../
	srw-rw----  1 ydotool input    0 Mar  2 16:09 ydotoold.sock=

ls -al /path/to/bin/ydotool
	-rwsr-sr-x 1 ydotool input 32K Mar  1 19:00 /path/to/bin/ydotool*

does the trick. if only as a workaround ...

@Paiusco
Copy link
Contributor

Paiusco commented Mar 6, 2024

Can you share your working branch or code so I can try to reproduce it over here?

@pgnd
Copy link
Author

pgnd commented Mar 7, 2024

fwiw, very WIP for builds @ Fedora,

https://pagure.io/pgnd/ydotool-pgnd/tree/main

seems to behave as built --- with the 'expanded' socket perms, as above.

biggest issue is assigning a 'hotkey' trigger in KDE to ydotool scripts; but that appears to be a KDE problem ...

@Paiusco
Copy link
Contributor

Paiusco commented Apr 29, 2024

I tested something similar to what you're trying to do, and it's still working... maybe I missed something?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants