Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Wrong owner for /run/user/0 at startup(sound does not work)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
I_hate_register_forms
n00b
n00b


Joined: 27 Nov 2023
Posts: 3

PostPosted: Mon Nov 27, 2023 11:25 pm    Post subject: Wrong owner for /run/user/0 at startup(sound does not work) Reply with quote

Every time I start my PC I need to run
Code:
# chown 1000:1000 /run/user/0

otherwise I have strange problems like:

  • the sound does not work (pulseaudio)
  • some programs like vscodium refuse to start

As soon as I run that command pulseaudio starts and the sound works. I don't remember on which part of the internet found this commad but was the only thing that made the sound work in the past when I found it.

I know a easy fix would be to run this command at startup(with a cronjob or something similar) and go on with my life, but that would be a dirty fix(like running this command manually at each startup as I'm doing right now), instead I want to understand why the proper and implement a proper fix.

In the following lines I'll share with you some details that I think would help in troubleshooting this problem:
These are the permissions/owner that I have at startup:
Code:
# ls -la /run/user/0
total 0
drwx------ 2 root root 40 Nov 28 00:45 .
drwxr-xr-x 3 root root 60 Nov 28 00:45 ..

My guess would be that this

dwm is configured to start by adding:
Code:
exec setxkbmap <xkb_layout> &
exec slstatus &
exec dwm

at the end of /etc/X11/xinit/xinitrc
When I first login(I use dwm, I cant login directly in tty with my_non_root_user because it asks for a password despite the fact that it is a passwordless account) I use root user then I run
Code:
su <my_non_root_user>

and
Code:
if [ $(tty) == "/dev/tty1" ] ; then
        startx
fi

in /home/<my_non_root_user>/.bashrc

My guess would be that /run is somehow(somewhere) created by root user instead of my_non_root_user, but still I would like to trace down what I did wrong to create this problem.
Code:
# df -h
Filesystem      Size  Used Avail Use% Mounted on
[...]
tmpfs           3.9G  1.1M  3.9G   1% /run
[...]


Any kind of help I highly appreciated!
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Tue Nov 28, 2023 12:10 am    Post subject: Reply with quote

Welcome to the forums.

I think you started with a bit of technical debt, and kept taking out more debt trying to work around your initial problem. Instead, you should start at the beginning and fix the problems that caused you to start using workarounds.

It is normal for /run/user/$UID to be owned by $UID. Changing it is wrong.

Running exec command & is wrong. If you want to replace the current shell, use exec and no ampersand. If you want something in the background, use & and no exec.

Why are you using root to work around the password issue? Set a password on the account, or fix the PAM configuration to allow a passwordless account.

Using su user without -l is usually wrong, because you are allowing parts of the source environment to pass through. That is usually a bad thing.
Back to top
View user's profile Send private message
gentoo_ram
Guru
Guru


Joined: 25 Oct 2007
Posts: 475
Location: San Diego, California USA

PostPosted: Tue Nov 28, 2023 11:32 pm    Post subject: Reply with quote

What's your environment goal? Are you trying to automatically start an X session as a certain user and log that user in without a password? Maybe try using
SDDM to do that. SDDM is an X session manager. It has the ability to automatically start a session as a given user. Maybe that will get you what you want without resorting to strange workarounds to configure X to start properly.

If you go down this solution path you may have to start taking out whatever changes you made to xinit configurations.
Back to top
View user's profile Send private message
I_hate_register_forms
n00b
n00b


Joined: 27 Nov 2023
Posts: 3

PostPosted: Wed Dec 06, 2023 2:24 pm    Post subject: Reply with quote

Hu wrote:

Running exec command & is wrong. If you want to replace the current shell, use exec and no ampersand. If you want something in the background, use & and no exec.


I replaced
Code:
exec setxkbmap <xkb_layout> &
exec slstatus &

with
Code:
setxkbmap <xkb_layout> &
slstatus &

but I would still want to know what is wrong with using both exec and &.
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1688

PostPosted: Wed Dec 06, 2023 2:40 pm    Post subject: Reply with quote

exec here basically means "switch control to" and will not return to perform the rest of the script
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3366
Location: Rasi, Finland

PostPosted: Wed Dec 06, 2023 7:28 pm    Post subject: Fix the login issue Reply with quote

/run/user/0 is most commonly XDG_RUNTIME_DIR for user root.
I_hate_register_forms wrote:
When I first login(I use dwm, I cant login directly in tty with my_non_root_user because it asks for a password despite the fact that it is a passwordless account) I use root user then I run
Code:
su <my_non_root_user>
... and there's your problem. Running su like you described will "leak" root user's environment into the environment of your regular user. While su -l <your regular user> will probably fix this, you should instead focus fixing the problem which you have with your regular user when trying to log in.
When fixed, your regular user should have a proper environment set and problems with pulseaudio etc probably gone.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
I_hate_register_forms
n00b
n00b


Joined: 27 Nov 2023
Posts: 3

PostPosted: Thu Dec 07, 2023 12:54 am    Post subject: Reply with quote

gentoo_ram wrote:
What's your environment goal? Are you trying to automatically start an X session as a certain user and log that user in without a password? Maybe try using
SDDM to do that. SDDM is an X session manager. It has the ability to automatically start a session as a given user. Maybe that will get you what you want without resorting to strange workarounds to configure X to start properly.

If you go down this solution path you may have to start taking out whatever changes you made to xinit configurations.

A year ago, when I installed gentoo I avoided desktop managers thinking that they are bloat, but now I start to think that they are actually useful, I'll give https://wiki.gentoo.org/wiki/SDDM a try, thanks for the suggestion!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum