this post was submitted on 29 Apr 2025
34 points (94.7% liked)

Linux

54311 readers
318 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

Hello fellow lemmings

I am a long-time i3 user and have decided to switch to Sway. I have encountered a weird error which has left me utterly bamboozled.

I am using Ubuntu 24.04 which has gone from 20.04 -> 22.04 -> 24.04. It has Ubuntu-Gnome, i3 and Sway currently installed.

The issue

The error that I'm facing is when I'm using Sway, I simply don't have sudo access.

This is what the error looks like

$ sudo visudo
[sudo] password for xavier666:
Sorry, user xavier666 is not allowed to execute '/usr/sbin/visudo' as root on <HOSTNAME>.

When I switch back to i3, my permissions are fine for the same user. I have not done any crazy modifications to the sudoer's file as far as I can remember.

PS: I have added a command to no-sudo xavier666 ALL = NOPASSWD: /usr/bin/brightnessctl

The "fix"

I temporarily solved it by adding xavier666 ALL=(ALL:ALL) ALL to the sudoer's file.

IMO, I think this should not be required. I don't remember ever adding the default user to the file for all the installations that I have done. (But this is the first time I've installed Sway)

Logs/Outputs

Running sudo -l without the fix (on Sway)

Matching Defaults entries for xavier666 on <HOSTNAME>:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
    use_pty

User xavier666 may run the following commands on <HOSTNAME>:
    (root) NOPASSWD: /usr/bin/brightnessctl

When I run the same command on i3, i get this (ALL : ALL) ALL extra line in the output. And when I run sudo -l with my fix on Sway, (ALL : ALL) ALL is present and the permission issue is fixed.

What is causing Sway to remove the root permission for the user?

Note: I'm just asking for the standard sudo behaviour. I'm not trying to run GUI applications as root.

Edit:

The issue was caused by swhkd. It was installed as a setuid binary (as instructed by the developer of the project). Once I switched back to sway's default keybinds and disabled swhkd, the permissions were back to normal. I removed my previous "fix" in the sudoers list and I still have sudo access.

Thanks a lot everyone and specially @[email protected] for pointing me in the right direction.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 3 weeks ago (4 children)

but with the way the sway session is started, as opposed to the i3 session. We need more info on this.

I'm using gdm to start sway. I'm using the laptop's built-in fingerprint scanner to unlock (Not sure if it matters). I saved the fingerprint in the Gnome session long back.

gdm probably looks inside /usr/share/wayland-sessions and finds sway.desktop and uses it to launch Sway.

I've tried to keep things as vanilla as possible.

Isn’t i3 Xorg only, and sway wayland only?

Correct.

Maybe wayland is launched using restrictive set of permissions.

[–] [email protected] 6 points 3 weeks ago (1 children)

One big difference is that sway doesn't run as a login process (and neither does gdm), meaning none of your .profile files are getting sourced. Check how your environment variables differ between i3 and sway and see if that might be the issue.

[–] [email protected] 1 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

Check how your environment variables differ between i3 and sway and see if that might be the issue

Just running set for each session and then diff should be enough, right?

[–] [email protected] 1 points 3 weeks ago

That would work.

I'm not sure what could be in (or missing from) your environment that would break sudo, but it's a place to check at least.

[–] [email protected] 1 points 3 weeks ago (1 children)

Does the same issue also happen if you launch sway from the tty and not from gdm ?

I've never used gdm but it probably allow you to open a tty with Ctrl+Alt+F3, then log in and type sway.

[–] [email protected] 1 points 3 weeks ago

I did it. The issue still lingers. Check my last comment for output.

[–] [email protected] 1 points 3 weeks ago (1 children)

gdm probably looks inside /usr/share/wayland-sessions and finds sway.desktop and uses it to launch Sway.

And how did you use to start i3?

[–] [email protected] 2 points 3 weeks ago (1 children)

Just the way I launch sway; via gdm.

[–] [email protected] 1 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

This goes a little beyond me because I have no idea how gdm would differentiate Xorg or wayland sessions.

Look into the session files themselves (.desktop) - they have an Exec= line. Then see if that's maybe just a shell wrapper around something else, e.g.: file /usr/bin/sway and see what it does.

That's all I have.

[–] [email protected] 1 points 3 weeks ago (1 children)

For i3, the desktop file is like this (present in /usr/share/xsessions)

[Desktop Entry]
Name=i3
Comment=improved dynamic tiling window manager
Exec=i3
TryExec=i3
Type=Application
X-LightDM-DesktopName=i3
DesktopNames=i3
Keywords=tiling;wm;windowmanager;window;manager;

And sway (present in /usr/share/wayland-sessions)

[Desktop Entry]
Version=1.0
Name=Sway
Comment=An i3-compatible Wayland compositor
Exec=/usr/bin/sway
Type=Application
DesktopNames=sway

Gdm probably sums up all the DE from both the wayland and x11 sessions.

There are some files & directories in /etc/gdm3 but I'm too lazy to go through all of them

Init       PostSession  Prime     config-error-dialog.sh  greeter.dconf-defaults
PostLogin  PreSession   PrimeOff  custom.conf             Xsession

Thanks for your help.

[–] [email protected] 1 points 3 weeks ago

but I’m too lazy to go through all of them

OK. But you did want to solve this just because you're interested?

[–] [email protected] 1 points 3 weeks ago (1 children)

You're going to have to look at how that process works on Ubuntu and how it differes from Xorg session start.

gdm probably looks inside /usr/share/wayland-sessions and finds sway.desktop and uses it to launch Sway.

FWIW, these are all text files. Look at them.

Sorry, I have to go now. More tonight, if you want.

[–] [email protected] 1 points 3 weeks ago* (last edited 3 weeks ago)

these are all text files

Yeah, it just calls the executable mentioned in the .desktop file (/usr/bin/sway). It should not be a GDM, issue, right?

I also checked that I don't have seatd installed, which is a "minimal user, seat and session management daemon" mentioned in arch wiki (https://wiki.archlinux.org/title/Sway). Could it be related?

Sorry, I have to go now. More tonight, if you want.

No hurry, the fix I am using is not causing issue. I just want to know why this is happening. This is a fun research problem.

PS: I checked Google and I didn't find anyone who has faced the same issue.