You are not logged in.

#1 2021-05-08 18:24:02

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,730
Website

sudoers problem [SOLVED]

I just finished setting up a new Archlinux box.
As usual I set the firewall and pacman first. But I do not want to have to su to admin all the time for these things so I set up sudo.
This time around I got odd results.

Checking in the forums I found a couple of people that have some issues recently but their solutions did not work for me.
Clicking the user as Admin and then setting the user as a regular user again, as someone suggested, did not work for me either.

So this is my situation:

sudo  -l

User ralvez may run the following commands on thunderbolt:
    (root) NOPASSWD: /usb/bin/pacman, /usr/bin/ufw

As indicated above my user can run both ufw and pacman with no password.

If I run ufw status, for example, I get the expected behaviour but when I run pacman it prompts me for sudo password (??) which fails if I enter it anyway.

In my visudo the last line I added is:

ralvez ALL=NOPASSWD: /usr/bin/pacman, /usr/bin/ufw

Any ideas to solve this problem will be appreciated.
This time around Google was "not my friend" sad

R.

Last edited by ralvez (2021-05-08 19:09:26)

Offline

#2 2021-05-08 18:32:36

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: sudoers problem [SOLVED]

Are you actually running sudo pacman and not just pacman?
The NOPASSWD entry just means that you won't be prompted for a password, you still need to use sudo...

If this isn't the issue then paste the full contents of your sudoers as well as the content of any files in sudoers.d


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2021-05-08 18:53:11

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,730
Website

Re: sudoers problem [SOLVED]

@Slithery,

Thanks for your reply.
Yes, I'm doing "sudo pacman" as the command
My sudoers is:

## sudoers file.
##
## This file MUST be edited with the 'visudo' command as root.
## Failure to use 'visudo' may result in syntax or file permission errors
## that prevent sudo from running.
##
## See the sudoers man page for the details on how to write a sudoers file.
##

##
## Host alias specification
##
## Groups of machines. These may include host names (optionally with wildcards),
## IP addresses, network numbers or netgroups.
# Host_Alias	WEBSERVERS = www1, www2, www3

##
## User alias specification
##
## Groups of users.  These may consist of user names, uids, Unix groups,
## or netgroups.
# User_Alias	ADMINS = millert, dowdy, mikef

##
## Cmnd alias specification
##
## Groups of commands.  Often used to group related commands together.
# Cmnd_Alias	PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \
# 			    /usr/bin/pkill, /usr/bin/top
# Cmnd_Alias	REBOOT = /sbin/halt, /sbin/reboot, /sbin/poweroff

##
## Defaults specification
##
## You may wish to keep some of the following environment variables
## when running commands via sudo.
##
## Locale settings
# Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET"
##
## Run X applications through sudo; HOME is used to find the
## .Xauthority file.  Note that other programs use HOME to find   
## configuration files and this may lead to privilege escalation!
# Defaults env_keep += "HOME"
##
## X11 resource path settings
# Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH"
##
## Desktop path settings
# Defaults env_keep += "QTDIR KDEDIR"
##
## Allow sudo-run commands to inherit the callers' ConsoleKit session
# Defaults env_keep += "XDG_SESSION_COOKIE"
##
## Uncomment to enable special input methods.  Care should be taken as
## this may allow users to subvert the command being run via sudo.
# Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER"
##
## Uncomment to use a hard-coded PATH instead of the user's to find commands
# Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
##
## Uncomment to send mail if the user does not enter the correct password.
# Defaults mail_badpass
##
## Uncomment to enable logging of a command's output, except for
## sudoreplay and reboot.  Use sudoreplay to play back logged sessions.
# Defaults log_output
# Defaults!/usr/bin/sudoreplay !log_output
# Defaults!/usr/local/bin/sudoreplay !log_output
# Defaults!REBOOT !log_output

##
## Runas alias specification
##

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

## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

## Uncomment to allow members of group sudo to execute any command
# %sudo	ALL=(ALL) ALL

## Uncomment to allow any user to run sudo if they know the password
## of the user they are running the command as (root by default).
# Defaults targetpw  # Ask for the password of the target user
# ALL ALL=(ALL) ALL  # WARNING: only use this together with 'Defaults targetpw'

## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /etc/sudoers.d


ralvez ALL=NOPASSWD: /usr/bin/pacman, /usr/bin/ufw

I do not have any files in /etc/sudoers.d/

BTW, the sudoes files is the original file from Archlinux, I just added the last line at the end as I usually do.


R.

Offline

#4 2021-05-08 19:08:59

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,730
Website

Re: sudoers problem [SOLVED]

@Slithery,

I just had an idea... and it worked!
I went to one of my other rigs running Arch and copied /etc/sudoers into a USB, then I logged into the new machine and copied the file from the working machine into the one that was not working and ... magic! Now it's working.

The only thing I can think of is that for some reason the file in the new machine was corrupted.
But this little trick fixed it.

Thanks for your assistance.

R.

Offline

#5 2021-05-08 20:07:26

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,527

Re: sudoers problem [SOLVED]

Do you have the same line in the new sudoers?
Otherwise: "type pacman" - might be shadowed, eg. by a script.

Offline

#6 2021-05-08 20:12:41

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,730
Website

Re: sudoers problem [SOLVED]

@seth,

Sorry I'm not sure I understand your question.
In the sudoes file I uploaded to the new system I have the same line:

ralvez ALL=NOPASSWD: /usr/bin/pacman, /usr/bin/ufw

What do you mean by "shadowed by a script"?

R.

Offline

#7 2021-05-08 20:17:46

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,527

Re: sudoers problem [SOLVED]

/usr/local/bin/pacman (the script is dumb and only for illustration of the meaning)

#!/bin/sh
/usr/bin/pacman --color always "$@"

You'd end up running "sudo /usr/local/bin/pacman" by "sudo pacman" and sudo will ask you for a password.
BUT: Since the new sudoers also has an absolute path, that's not the case.

Offline

#8 2021-05-08 20:21:58

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,730
Website

Re: sudoers problem [SOLVED]

@seth,

Oh! I see.
I think that the issue was likely that somewhat the sudoes file was corrupted because it partially worked. If I was to run sudo ufw it DID work.
It would consistently fail for sudo pacman.
I'm good now... thanks for your assistance too.

R

Offline

#9 2021-05-08 20:26:08

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: sudoers problem [SOLVED]

You had a typo....

User ralvez may run the following commands on thunderbolt:
    (root) NOPASSWD: /usb/bin/pacman, /usr/bin/ufw

Take a close look at the pacman path.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#10 2021-05-09 13:44:57

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,730
Website

Re: sudoers problem [SOLVED]

Oh boy!!
That's funny.
The typo was introduced when I posted the last time.
In the original sudoes files that I copied, pasted (was way too long to type smile) it reads /usr/bin/pacman.

R.

Offline

Board footer

Powered by FluxBB