0

Hello I am currently trying to give the only user on my R-PI the access to run all the command in the pi-hole application directory without using having to use the sudo command. So i have created a new file in /etc/sudoers.c using the visudo comand

This is the contents

##############################################################################
###############Gives user the ability to run PIhole stuff####################
#############################################################################

user ALL=NOPASSWD: /usr/local/bin/pihole

The file is mode 440 to root and visudo -c (check) parses fine but I still cannot access these files. The same user is also in my sudousers main file. I have rebooted after making these changes. I am not sure if the main file is locking out the changes I am making in my auxilary file

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
user   ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

There is also the webdata file for this app that appears to be doing the same thing I am. Its setup the same way my file is but is working as expected.

# Pi-hole: A black hole for Internet advertisements
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
# Network-wide ad blocking via your own hardware.
#
# Allows the WebUI to use Pi-hole commands
#
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.
#
www-data ALL=NOPASSWD: /usr/local/bin/pihole

Any commands I need to run to get it to commit these changes, any formating issues I should look for.

  • "without using having to use the sudo command" ... I think you misunderstand what's going on here - the NOPASSWD rules let you run sudo foo without having to enter a password, but you still need to use sudo if you want sudoers rules like this one to apply. – muru Jul 25 '17 at 4:10
  • Right, I was misunderstanding and it's working as its supposed to. To give you some perspective I am trying to run a script at login that displays some data. Some of the commands within it require sudo to run. hence the/usr/local/bin/pihole so that script now appears to run when i sudo the entire script but not the script itself is asking me for a root pwd. – PInoob Jul 25 '17 at 4:31
  • So I suppose I now want to have NOPASSWORD set on both the/usr/local/bin/pihole and my command I am running do I put that on one line user ALL=NOPASSWD: /usr/local/bin/pihole /usr/local/bin/myscript.sh' or on 2 separate lines – PInoob Jul 25 '17 at 5:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.