You are not logged in.
Hi want to execute a systemd service with a deploy hook.
So I want execute
sudo systemctl restart flask.service
or
systemctl restart flask.service
without PWD promt with user vcb.
When I edit /etc/suoders to
vcb ALL=NOPASSWD: ALL
It's ask anyway for a PWD
When I edit /etc/suoders to
vcb ALL=NOPASSWD:/bin/systemctl restart flask.service
It's says I cant' execute the service as root when I prompt
systemctl restart flask.service
The systemd service starts with user vcb and group wheel
What is the problem?
I prefer to add the second line to /etc/suoders.d/vcb
Last edited by Morta (2023-08-09 17:50:10)
Offline
PWD is a *very* confusing abridge for "password"…
In order for sudo to have any effect you'll have to, wel, use sudo
If you just run systemctl it'll check polkit and ask you for permissions this way.
sudo systemctl restart flask.service
Offline
I not totally stupid. The problem is that the sudo password prompt comes anyway on every configuration.
Offline
I not totally stupid.
Maybe not, but your posts would have consistently misrepresented the commands you issued - and made it appear this way.
sudo -l
Offline
[vcb@mail root]$ sudo -l
User vcb may run the following commands on mail:
(vcb) NOPASSWD: /usr/bin/systemctl restart flask-vcb.service
sudo cat /etc/sudoers
[sudo] password for vcb:
Sorry, user vcb is not allowed to execute '/usr/bin/cat /etc/sudoers' as root on mail.
## User privilege specification
##
root ALL=(ALL:ALL) ALL
morta ALL=(ALL:ALL) ALL
stefan ALL=(ALL:ALL) ALL
vcb ALL=(vcb) NOPASSWD: /usr/bin/systemctl restart flask-vcb.service # Also tried vcb ALL=(root) and ALL=(ALL:ALL)
Offline
Ok im stupid. User vcb was not in the group wheel
Offline
This has nothing to do w/ vcb being in the wheel group.
The sudoers you posted can *obviously* not work because you're allowing vcb to execute "systemctl restart flask-vcb.service" as vcb w/o issuing a password (sudo -u vcb systemctl restart flask-vcb.service, what's pointless)
If adding it to the group wheel did anything that's likely because you've a sudoers entry " %wheel ALL=(ALL) NOPASSWD: ALL"
# Also tried vcb ALL=(root) and ALL=(ALL:ALL)
You might want to post "sudo -l" for that attempt.
Offline
[vcb@mail /]$ sudo -l
User vcb may run the following commands on mail:
(ALL : ALL) NOPASSWD: /usr/bin/systemctl restart flask-vcb.service
Offline
And what's then the output for
[vcb@mail /]$ sudo /usr/bin/systemctl restart flask-vcb.service
Edit: if you've the %wheel rule and vcb in %wheel, this is obviously pointless, so comment the %wheel rule or remove vcb from that group (requires re-login to apply)
Last edited by seth (2023-08-09 17:28:57)
Offline
sudo /usr/bin/systemctl restart flask-vcb
[sudo] password for vcb:
Sorry, user vcb is not allowed to execute '/usr/bin/systemctl restart flask-vcb' as root on mail.
#%wheel is comment out
Offline
That's not the command I suggested or you permitted.
This has to match literal, omitting ".service" is not allowed.
Offline
Ok with .service its don't ask the password!
Offline
"quelle surprise"
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline