You are not logged in.

#1 2011-01-03 13:58:04

greenfish
Member
From: eating fish in /dev/null
Registered: 2008-08-30
Posts: 229

How do you run applications as NON root without any x (server) ?

Hi! I'm trying to run mpd as a user right after init. According to the wiki one should use .xinitrc, but since there's no X server for me to run it won't work for me.


I've tried this command in bashrc "( sleep 15 && mpd ~/.mpd/mpd.conf )" and yes it works assuming I ssh into my server.

Where do you put script/commands to launch an application as a NORMAL user after init?

My Setup:

archlinux on a server, so no graphical input.

Thanks smile


ARCH64 archSKYNET server AMD  Phenom(tm) II X2 550 HDD 6TB Ram 8GB
Hobbies: Running, Pistol Marksmanship, Classic Music

Offline

#2 2011-01-03 14:00:04

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: How do you run applications as NON root without any x (server) ?

Just add the daemon to rc.conf, and in your mpd.conf set the user under which you want to run it.


ᶘ ᵒᴥᵒᶅ

Offline

#3 2011-01-03 14:10:59

greenfish
Member
From: eating fish in /dev/null
Registered: 2008-08-30
Posts: 229

Re: How do you run applications as NON root without any x (server) ?

litemotiv wrote:

Just add the daemon to rc.conf, and in your mpd.conf set the user under which you want to run it.

Hi!

I have the mpd config set to my username, but running mpd as a daemon won't work for me, since the daemon runs with root privilegies.

Running mpd as root on my system results in massive failures, that's why it works best for me as a normal user.


ARCH64 archSKYNET server AMD  Phenom(tm) II X2 550 HDD 6TB Ram 8GB
Hobbies: Running, Pistol Marksmanship, Classic Music

Offline

#4 2011-01-03 14:18:00

jac
Member
From: /home/jac
Registered: 2009-05-19
Posts: 431
Website

Re: How do you run applications as NON root without any x (server) ?

You know mpd won't actually be running as root, right?

man mpd.conf wrote:

user <username>
This  specifies  the  user that MPD will run as, if set.  MPD should never run as root,
and you may use this option to make MPD change its user id after initialization.  Do
not use this option if you start MPD as an unprivileged user.

Edit: Sorry, can't get that to look normal any way I do it. Best to view it straight from the terimnal wink

Last edited by jac (2011-01-03 14:19:04)

Offline

#5 2011-01-03 14:19:00

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: How do you run applications as NON root without any x (server) ?

I don't use mpd, but you could try putting in /etc/rc.local which executes straight after daemons:

su $username -c "mpd ~/.mpd/mpd.conf"

Last edited by dyscoria (2011-01-03 14:19:30)


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#6 2011-01-04 18:04:37

greenfish
Member
From: eating fish in /dev/null
Registered: 2008-08-30
Posts: 229

Re: How do you run applications as NON root without any x (server) ?

dyscoria wrote:

I don't use mpd, but you could try putting in /etc/rc.local which executes straight after daemons:

su $username -c "mpd ~/.mpd/mpd.conf"

Yeah I've already tried that also tried  (sleep 50 && mpd ~/.mpd/mpd.conf) &. But none of the commands executes to my knowledge, because it's been over 5 minutes now and mpd still hasn't started. Both commands works just fine if I enter em manually in the terminal.

jac wrote:

You know mpd won't actually be running as root, right?

man mpd.conf wrote:

user <username>
This  specifies  the  user that MPD will run as, if set.  MPD should never run as root,
and you may use this option to make MPD change its user id after initialization.  Do
not use this option if you start MPD as an unprivileged user.

Edit: Sorry, can't get that to look normal any way I do it. Best to view it straight from the terimnal wink

Hi! I understand what you mean, thanks.

No,  I assumed it would run as root. But you see I can't launch mpd as a daemon in rc.d, it always fails for me. The easiest way for me is to "mpd my.config" in some ways.


ARCH64 archSKYNET server AMD  Phenom(tm) II X2 550 HDD 6TB Ram 8GB
Hobbies: Running, Pistol Marksmanship, Classic Music

Offline

#7 2011-01-04 18:46:28

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: How do you run applications as NON root without any x (server) ?

you seem to have something misconfigured.

intsead of trying to hack your way around it, why not fix that. if there is a daemon, thats what you are supposed to use.

other than that, i have no clue why your daemon isnt starting.

Offline

#8 2011-01-04 23:21:51

Silence
Member
Registered: 2009-12-28
Posts: 9

Re: How do you run applications as NON root without any x (server) ?

First of all use full path in you script
then add  "> /some/where/xxx.log 2>&1" for logfile

 /bin/su $username -c "/path/to/mpd /home/uyouusername/.mpd/mpd.conf" > /some/where/xxx.log 2>&1 

And I'm agree with eldragon trying workarounds, is not way to go.

Last edited by Silence (2011-01-05 00:22:17)


Eloquent silence

Offline

#9 2011-01-05 04:57:08

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: How do you run applications as NON root without any x (server) ?

If you set up the right permissions to the files mpd is supposed to access - log and state files - then it works just dandy with a non-root user, and you can run it as a service. Best practice is to put all state and log files in the home dir of the user you're running mpd as, if applicable, and if not, to chown the directories or files mpd needs write access to, and make sure the paths are accessible.

Running mpd as a daemon with the limited permissions of a regular user works for hundreds of Arch users, so if you ask me, this is typical PEBKAC.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#10 2011-01-05 14:04:56

Telkkar
Member
From: United States
Registered: 2010-12-26
Posts: 38

Re: How do you run applications as NON root without any x (server) ?

.:B:. wrote:

... so if you ask me, this is typical PEBKAC.

Brutal and to the point. ^_^

------

My 0.02 -- make sure you have the config set up correctly (i.e. you have no errors running from your console first), then daemonize it through rc.conf. If I were in your situation, I'd do that, but I use X, so I start it through .xinitrc with all of my config files in the .mpd directory.

From looking at the default config files, MPD was meant to start the way you don't want to start it. Going against the grain there.

Offline

Board footer

Powered by FluxBB