The officially official Devuan Forum!

You are not logged in.

#1 2022-05-06 23:01:23

Altoid
Member
Registered: 2017-05-07
Posts: 1,078  

[SOLVED] sudoers file for 'service'

Hello:

When I need to check the status of a service in a Linux box I use this command as root:

:~# service rsyncd status
running
:~# 

If I want to do this as a user instead of being root, I'd generate a specific sudoers file to add to /etc/sudoers.d.

Like this one I use to run dmesg:

:~$ sudo cat /etc/sudoers.d/user_dmesg
groucho ALL = NOPASSWD:/bin/dmesg 
:~$ 

This because I am convinced that the use of sudo, like a few other things in life, needs to be under check.

I'm at odds with it and can't find a way to get a users_service file that works.
I'd appreciate some help with that.

Thanks in advance,

A.

Offline

#2 2022-05-07 00:53:54

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 731  

Re: [SOLVED] sudoers file for 'service'

I think you (again?) are confused by groucho not having /usr/sbin in PATH (and not /sbin).

It's not a sudo issue; /usr/sbin/service is happily being executed by any user, although the start and stop of services may well require root.

Offline

#3 2022-05-07 01:22:55

Altoid
Member
Registered: 2017-05-07
Posts: 1,078  

Re: [SOLVED] sudoers file for 'service'

Hello:

ralph.ronnquist wrote:

... you (again?)

Yes, always ...  8^D

ralph.ronnquist wrote:

... confused by groucho not having /usr/sbin in PATH (and not /sbin).

Hmm ...
I'm sorry, I think I am being confusing.

The example I show previously is how I run dmesg as sudo in both my main Devuan box and the NAS.
Both my main Devuan box and the NAS have only root and my user (groucho) so it does not matter much.
But you are right, got to fix that.

Now, in my Devuan box, I can find service:

[root@devuan ~]# which service
/usr/sbin/service
[root@devuan ~]# 

But not in my NAS:

root@OpenWrt:~# which service
root@OpenWrt:~# 
root@OpenWrt:~# /usr/bin/service
-ash: /usr/bin/service: not found
root@OpenWrt:~# 

That said, I have not been able to find an example of a sudoers file for this on the web.

Thanks for your input.

Best,

A.

Offline

#4 2022-05-07 11:19:07

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 2,532  

Re: [SOLVED] sudoers file for 'service'

Altoid wrote:

Now, in my Devuan box, I can find service:

[root@devuan ~]# which service
/usr/sbin/service
[root@devuan ~]# 

But not in my NAS:

root@OpenWrt:~# which service
root@OpenWrt:~# 

The which command searches PATH for the named executable.

Run this command in your Devuan system:

echo $PATH

^ That will show a (colon-separated) list of the directories being searched. If you run that command from OpenWRT then it will probably not have /usr/sbin/ listed, hence which cannot find it.

That being the case you need to either add /usr/sbin/ to PATH or declare the full path when running executables from that directory.

See https://wiki.debian.org/EnvironmentVariables for the Debian documentation on setting PATH and if that doesn't work then ask on the OpenWRT forums instead.

Altoid wrote:
root@OpenWrt:~# /usr/bin/service
-ash: /usr/bin/service: not found
root@OpenWrt:~#

Did you not think to try

/usr/sbin/service rsyncd status

Offline

#5 2022-05-07 12:17:04

Altoid
Member
Registered: 2017-05-07
Posts: 1,078  

Re: [SOLVED] sudoers file for 'service'

Hello:

Head_on_a_Stick wrote:

... will show a (colon-separated) list ...
... run that command from OpenWRT then it will probably not have /usr/sbin/ listed ...

But it does:

groucho@OpenWrt:~$ echo $PATH
/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin
groucho@OpenWrt:~$ 
Head_on_a_Stick wrote:

... ask on the OpenWRT forums instead.

I always look for answers in search engine/s, then here and then elsewhere. In that order.  8^ ) 
After all OpenWRT is just Linux in a very compact package to fit in embedded systems.

But you have to coax it to do regular Linux things, like adding users and sudoers.d files.
There's always something new to learn.

Head_on_a_Stick wrote:

... not think to try ...

Of course.

:~$ /usr/sbin/service rsyncd status
-ash: /usr/sbin/service: not found
:~$ 
:~# /usr/sbin/service rsyncd status
-ash: /usr/sbin/service: not found
:~# 

But ...

:~# service rsyncd status
running
:~# 

The thing is that the stanza service rsyncd status is not validated by visudo which needs to see a path.
I think this may be related to BusyBox.

Thanks a lot for your input.

Best,

A.

Offline

#6 2022-05-07 13:15:00

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 2,532  

Re: [SOLVED] sudoers file for 'service'

Find out what is providing the service supervision and query that utility using the provided tools. This is completely off-topic for these boards so I won't go any further here. I refer you again to the OpenWRT forums. I don't mean to be rude but your continued posting of OpenWRT-related issues on these boards is starting to look like spam.

Offline

#7 2022-05-07 18:05:07

Altoid
Member
Registered: 2017-05-07
Posts: 1,078  

Re: [SOLVED] sudoers file for 'service'

Hello:

Head_on_a_Stick wrote:

... completely off-topic for these boards ...
... your continued posting of OpenWRT-related issues on these boards is starting to look like spam.

Hmm ...
spam? 8^D !

merriamwebstwee.com wrote:

spam: noun
unsolicited usually commercial messages (such as emails, text messages, or Internet postings) sent to a large number of recipients or posted in a large number of places

Before I say anything else, I want to say this: I value your opinions, expertise and the help provided to me more than once.
But it seems to me that you are overreacting.

In doing so you are not being rude but much worse than that: you are out of place.
Please don't take my observation personally for it is not personal.

Bear in mind that although my questions do have a relationship to OpenWRT, you may want to consider that although it is not Devuan, both distributions share 1. that they are Linux and 2. they do not use systemd.

And most importantly, my questions are related to uses/tools which are common to both of them.

That said, I'll leave this for the Dev1 admins to opine on and will abide by whatever they decide on the matter.

-------
Edit:

In case you or anyone else is interested, I found a solution to the question with which I started this thread.
Using common Linux tools.

~$ sudo /etc/init.d/rsyncd status
running
~$

Added another line to /etc/profile.d/custom.sh: alias daemon="sudo /etc/init.d/rsyncd status"

And that was it.

~$ daemon
running
~$

The daemon alias will be part of a script which will run anytime I ssh into the NAS and provide me at a glance with basic stats I want to know when I check on it.
-------

Thank you for your input.

Best,

A.

Last edited by Altoid (2022-05-07 22:44:57)

Offline

Board footer