How can I have php execute a shell script as a user other than www-data

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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?










share|improve this question





















  • 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














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?










share|improve this question





















  • 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












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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 25 at 9:54









MoustacheSpy

1013




1013











  • 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
















  • 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















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















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491