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

Program listed in autostart file starts as root user. #337

Open
apoorv569 opened this issue Feb 5, 2023 · 8 comments
Open

Program listed in autostart file starts as root user. #337

apoorv569 opened this issue Feb 5, 2023 · 8 comments

Comments

@apoorv569
Copy link

The autostart file under ~/.dwm/autostart.sh starts programs as root user which causes issues, sometimes the program reads wrong configuration file sometimes there are permission issues.

Is this normal behavior? Can I change this behavior?

@bakkeby
Copy link
Owner

bakkeby commented Feb 5, 2023

What makes you think that the autostart file starts programs as the root user?

@apoorv569
Copy link
Author

apoorv569 commented Feb 5, 2023

What makes you think that the autostart file starts programs as the root user?

Because I had problems with 2 programs reading wrong configuration file mpd and syncthing. If I run any of these from terminal without specifying path to configuration file they read the correct config file i.e under ~/.config but if I put these in autostart file they use the config form /etc/ or whichever the default is.

Also if I try to kill the process I could not, without using sudo.

I also noticed the SHCMD in the config.h for dwm runs the command as root user as well. I have couple of keybinds like this,

        { MODKEY,                       XK_x,            spawn,                  SHCMD("~/.local/bin/scripts/dm-scripts/dm-session")},

the dmenu prompts does open but shows empty. So I am as a workaround point the keybind to another script which runs this script as my user.

@bakkeby
Copy link
Owner

bakkeby commented Feb 5, 2023

I don't know, it sounds like you are running dwm as the root user.

@apoorv569
Copy link
Author

apoorv569 commented Feb 5, 2023

I don't know, it sounds like you are running dwm as the root user.

How do you mean? I login as my user from my login manager (lightdm). This keybind used to work fine when I was using my own fork of dwm.

@bakkeby
Copy link
Owner

bakkeby commented Feb 5, 2023

To answer your question the autostart.sh should not run as the root user, it would not be normal.

The autostart file and when spawning commands from dwm should run as the user that is logged in.

ps -ef will tell you if the program is running as your user or not.

As for your symptoms:

A program may not necessarily adhere to a kill even if it is running as your user, but a kill -9 should usually work.

If you find that you can open a terminal and start a program (or script) fine, but that same program behaves differently when starting via .xinitrc, autostart.sh or when spawning via dwm then it may be that the program depends on some environment variables that are not set in the current session.

@apoorv569
Copy link
Author

apoorv569 commented Feb 6, 2023

ps -ef will tell you if the program is running as your user or not.

ps -ef says programs are running as the correct user..

As for your symptoms:

A program may not necessarily adhere to a kill even if it is running as your user, but a kill -9 should usually work.

If you find that you can open a terminal and start a program (or script) fine, but that same program behaves differently when starting via .xinitrc, autostart.sh or when spawning via dwm then it may be that the program depends on some environment variables that are not set in the current session.

I always use pkill -9 to kill processes.

About the env vars, I have set all my env vars related to programs I use correctly. I have even set the XDG dirs, cache, config and all.

I do use zsh could that be a issue?

@bakkeby
Copy link
Owner

bakkeby commented Feb 6, 2023

Where do you set those environment variables?

@bakkeby
Copy link
Owner

bakkeby commented Feb 6, 2023

If you run this then that may give you some insight into what environment variables are set for your session (although it is not particularly readable). This will usually be less than what you get when you run env in a terminal.

cat /proc/$(pidof dwm)/environ

What is being set may depend on the login / display manager. It may be that /etc/environment is being read, not sure.

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