Service functions without sudo

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











up vote
1
down vote

favorite












My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system:



[Service]
User=buildman


When I am sued as buildman, I can run:



systemctl status myservice.service


but if I try to do start or stop, it prompts me for password.



If I do:



sudo systemctl status myservice.service


it does not prompt me because I have configured visudo:



%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service


But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.



The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.







share|improve this question






















  • tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
    – Tagwint
    Oct 20 '17 at 17:37










  • your suggestion still requires sudo
    – amphibient
    Oct 20 '17 at 17:46










  • that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
    – Tagwint
    Oct 20 '17 at 17:52











  • Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
    – Tagwint
    Oct 20 '17 at 18:33










  • yes, that group does exist
    – amphibient
    Oct 20 '17 at 18:36














up vote
1
down vote

favorite












My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system:



[Service]
User=buildman


When I am sued as buildman, I can run:



systemctl status myservice.service


but if I try to do start or stop, it prompts me for password.



If I do:



sudo systemctl status myservice.service


it does not prompt me because I have configured visudo:



%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service


But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.



The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.







share|improve this question






















  • tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
    – Tagwint
    Oct 20 '17 at 17:37










  • your suggestion still requires sudo
    – amphibient
    Oct 20 '17 at 17:46










  • that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
    – Tagwint
    Oct 20 '17 at 17:52











  • Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
    – Tagwint
    Oct 20 '17 at 18:33










  • yes, that group does exist
    – amphibient
    Oct 20 '17 at 18:36












up vote
1
down vote

favorite









up vote
1
down vote

favorite











My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system:



[Service]
User=buildman


When I am sued as buildman, I can run:



systemctl status myservice.service


but if I try to do start or stop, it prompts me for password.



If I do:



sudo systemctl status myservice.service


it does not prompt me because I have configured visudo:



%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service


But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.



The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.







share|improve this question














My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system:



[Service]
User=buildman


When I am sued as buildman, I can run:



systemctl status myservice.service


but if I try to do start or stop, it prompts me for password.



If I do:



sudo systemctl status myservice.service


it does not prompt me because I have configured visudo:



%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service


But why doesn't service stop and start work like status? I would like
to enable buildman to execute these service commands without sudo or
password.



The primary reason for this is that I need to enable service restart
from Jenkins and I ran into problems running sudo from its
container, which complained that I needed a "TTY" to run it.









share|improve this question













share|improve this question




share|improve this question








edited Oct 20 '17 at 17:03









dhag

10.7k32742




10.7k32742










asked Oct 20 '17 at 16:57









amphibient

4,42993469




4,42993469











  • tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
    – Tagwint
    Oct 20 '17 at 17:37










  • your suggestion still requires sudo
    – amphibient
    Oct 20 '17 at 17:46










  • that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
    – Tagwint
    Oct 20 '17 at 17:52











  • Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
    – Tagwint
    Oct 20 '17 at 18:33










  • yes, that group does exist
    – amphibient
    Oct 20 '17 at 18:36
















  • tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
    – Tagwint
    Oct 20 '17 at 17:37










  • your suggestion still requires sudo
    – amphibient
    Oct 20 '17 at 17:46










  • that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
    – Tagwint
    Oct 20 '17 at 17:52











  • Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
    – Tagwint
    Oct 20 '17 at 18:33










  • yes, that group does exist
    – amphibient
    Oct 20 '17 at 18:36















tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
– Tagwint
Oct 20 '17 at 17:37




tried sudo /bin/systemctl start myservice (giving full path, like configured in visudo) ?
– Tagwint
Oct 20 '17 at 17:37












your suggestion still requires sudo
– amphibient
Oct 20 '17 at 17:46




your suggestion still requires sudo
– amphibient
Oct 20 '17 at 17:46












that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
– Tagwint
Oct 20 '17 at 17:52





that's not a suggestion yet :), just a question to figure out some details. Did it work with start / stop too if specifyin full path ?
– Tagwint
Oct 20 '17 at 17:52













Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
– Tagwint
Oct 20 '17 at 18:33




Just in case one more check: %buildman denotes a group, not user. Does that group exist?Does user buildman belongs to it?
– Tagwint
Oct 20 '17 at 18:33












yes, that group does exist
– amphibient
Oct 20 '17 at 18:36




yes, that group does exist
– amphibient
Oct 20 '17 at 18:36










1 Answer
1






active

oldest

votes

















up vote
0
down vote













status command does not require superuser rights, it works w/o sudo too.
start and stop do require sudo. You can avoid entering password but not specifying sudo.






share|improve this answer






















  • I tried 1 and it didn't work. How do I do your #2 suggestion?
    – amphibient
    Oct 20 '17 at 18:12










  • You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
    – Tagwint
    Oct 20 '17 at 18:31










  • this OP asks for a way to do away with sudo
    – amphibient
    Oct 20 '17 at 18:36










  • I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
    – Tagwint
    Oct 20 '17 at 18:45










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f399388%2fservice-functions-without-sudo%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













status command does not require superuser rights, it works w/o sudo too.
start and stop do require sudo. You can avoid entering password but not specifying sudo.






share|improve this answer






















  • I tried 1 and it didn't work. How do I do your #2 suggestion?
    – amphibient
    Oct 20 '17 at 18:12










  • You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
    – Tagwint
    Oct 20 '17 at 18:31










  • this OP asks for a way to do away with sudo
    – amphibient
    Oct 20 '17 at 18:36










  • I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
    – Tagwint
    Oct 20 '17 at 18:45














up vote
0
down vote













status command does not require superuser rights, it works w/o sudo too.
start and stop do require sudo. You can avoid entering password but not specifying sudo.






share|improve this answer






















  • I tried 1 and it didn't work. How do I do your #2 suggestion?
    – amphibient
    Oct 20 '17 at 18:12










  • You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
    – Tagwint
    Oct 20 '17 at 18:31










  • this OP asks for a way to do away with sudo
    – amphibient
    Oct 20 '17 at 18:36










  • I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
    – Tagwint
    Oct 20 '17 at 18:45












up vote
0
down vote










up vote
0
down vote









status command does not require superuser rights, it works w/o sudo too.
start and stop do require sudo. You can avoid entering password but not specifying sudo.






share|improve this answer














status command does not require superuser rights, it works w/o sudo too.
start and stop do require sudo. You can avoid entering password but not specifying sudo.







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 20 '17 at 18:48

























answered Oct 20 '17 at 18:08









Tagwint

1,3181612




1,3181612











  • I tried 1 and it didn't work. How do I do your #2 suggestion?
    – amphibient
    Oct 20 '17 at 18:12










  • You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
    – Tagwint
    Oct 20 '17 at 18:31










  • this OP asks for a way to do away with sudo
    – amphibient
    Oct 20 '17 at 18:36










  • I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
    – Tagwint
    Oct 20 '17 at 18:45
















  • I tried 1 and it didn't work. How do I do your #2 suggestion?
    – amphibient
    Oct 20 '17 at 18:12










  • You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
    – Tagwint
    Oct 20 '17 at 18:31










  • this OP asks for a way to do away with sudo
    – amphibient
    Oct 20 '17 at 18:36










  • I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
    – Tagwint
    Oct 20 '17 at 18:45















I tried 1 and it didn't work. How do I do your #2 suggestion?
– amphibient
Oct 20 '17 at 18:12




I tried 1 and it didn't work. How do I do your #2 suggestion?
– amphibient
Oct 20 '17 at 18:12












You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
– Tagwint
Oct 20 '17 at 18:31




You still need sudo in front of the command for other than status. Assuming sudo config is correct it won't requre password
– Tagwint
Oct 20 '17 at 18:31












this OP asks for a way to do away with sudo
– amphibient
Oct 20 '17 at 18:36




this OP asks for a way to do away with sudo
– amphibient
Oct 20 '17 at 18:36












I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
– Tagwint
Oct 20 '17 at 18:45




I was wrong about full path guess, sudo config do require full path indeed. sorry, will correct my answer. But I don't think you can avoid sudo for a non-root user. I OP asked 'without sudo OR password' - I suggesed w/o password option
– Tagwint
Oct 20 '17 at 18:45

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399388%2fservice-functions-without-sudo%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay