How can I have php execute a shell script as a user other than www-data
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
I have a user called gmodserver which manages a garrys mod server. The manager script only works properly when its executed using that user. I want to make a php enabled site that allows people with a special key to restart the server.
Therefore I need a way to run that script using "gmodserver" as the user.
How can I do that?
command-line bash scripts apache2 php
add a comment |Â
up vote
0
down vote
favorite
I have a user called gmodserver which manages a garrys mod server. The manager script only works properly when its executed using that user. I want to make a php enabled site that allows people with a special key to restart the server.
Therefore I need a way to run that script using "gmodserver" as the user.
How can I do that?
command-line bash scripts apache2 php
You can do this bysudo -u gmodserver command
, but first configure sudo to allow www-data to do it. Configure to not have root access but only access to this user/command.
â LeonidMew
Feb 25 at 10:00
@LeonidMew Yes I did that correctly now but the server doesnt seem to correctly identify the server now. Here is the thing. If I have php run whoami it returns "gmodserver" which is correct, but if I run anything with the lgsm script that runs the server it acts like it needs to start a NEW server and ignores the existing one. Why could this be happening ( some educated guesses maybe? )
â MoustacheSpy
Feb 25 at 17:34
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a user called gmodserver which manages a garrys mod server. The manager script only works properly when its executed using that user. I want to make a php enabled site that allows people with a special key to restart the server.
Therefore I need a way to run that script using "gmodserver" as the user.
How can I do that?
command-line bash scripts apache2 php
I have a user called gmodserver which manages a garrys mod server. The manager script only works properly when its executed using that user. I want to make a php enabled site that allows people with a special key to restart the server.
Therefore I need a way to run that script using "gmodserver" as the user.
How can I do that?
command-line bash scripts apache2 php
command-line bash scripts apache2 php
asked Feb 25 at 9:54
![](https://lh6.googleusercontent.com/-LLpSbDyH9Lg/AAAAAAAAAAI/AAAAAAAAAJQ/rV39zQ1-V2U/photo.jpg?sz=32)
![](https://lh6.googleusercontent.com/-LLpSbDyH9Lg/AAAAAAAAAAI/AAAAAAAAAJQ/rV39zQ1-V2U/photo.jpg?sz=32)
MoustacheSpy
1013
1013
You can do this bysudo -u gmodserver command
, but first configure sudo to allow www-data to do it. Configure to not have root access but only access to this user/command.
â LeonidMew
Feb 25 at 10:00
@LeonidMew Yes I did that correctly now but the server doesnt seem to correctly identify the server now. Here is the thing. If I have php run whoami it returns "gmodserver" which is correct, but if I run anything with the lgsm script that runs the server it acts like it needs to start a NEW server and ignores the existing one. Why could this be happening ( some educated guesses maybe? )
â MoustacheSpy
Feb 25 at 17:34
add a comment |Â
You can do this bysudo -u gmodserver command
, but first configure sudo to allow www-data to do it. Configure to not have root access but only access to this user/command.
â LeonidMew
Feb 25 at 10:00
@LeonidMew Yes I did that correctly now but the server doesnt seem to correctly identify the server now. Here is the thing. If I have php run whoami it returns "gmodserver" which is correct, but if I run anything with the lgsm script that runs the server it acts like it needs to start a NEW server and ignores the existing one. Why could this be happening ( some educated guesses maybe? )
â MoustacheSpy
Feb 25 at 17:34
You can do this by
sudo -u gmodserver command
, but first configure sudo to allow www-data to do it. Configure to not have root access but only access to this user/command.â LeonidMew
Feb 25 at 10:00
You can do this by
sudo -u gmodserver command
, but first configure sudo to allow www-data to do it. Configure to not have root access but only access to this user/command.â LeonidMew
Feb 25 at 10:00
@LeonidMew Yes I did that correctly now but the server doesnt seem to correctly identify the server now. Here is the thing. If I have php run whoami it returns "gmodserver" which is correct, but if I run anything with the lgsm script that runs the server it acts like it needs to start a NEW server and ignores the existing one. Why could this be happening ( some educated guesses maybe? )
â MoustacheSpy
Feb 25 at 17:34
@LeonidMew Yes I did that correctly now but the server doesnt seem to correctly identify the server now. Here is the thing. If I have php run whoami it returns "gmodserver" which is correct, but if I run anything with the lgsm script that runs the server it acts like it needs to start a NEW server and ignores the existing one. Why could this be happening ( some educated guesses maybe? )
â MoustacheSpy
Feb 25 at 17:34
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1009560%2fhow-can-i-have-php-execute-a-shell-script-as-a-user-other-than-www-data%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You can do this by
sudo -u gmodserver command
, but first configure sudo to allow www-data to do it. Configure to not have root access but only access to this user/command.â LeonidMew
Feb 25 at 10:00
@LeonidMew Yes I did that correctly now but the server doesnt seem to correctly identify the server now. Here is the thing. If I have php run whoami it returns "gmodserver" which is correct, but if I run anything with the lgsm script that runs the server it acts like it needs to start a NEW server and ignores the existing one. Why could this be happening ( some educated guesses maybe? )
â MoustacheSpy
Feb 25 at 17:34