LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2019, 09:57 PM   #1
trackstar2000
Member
 
Registered: Apr 2013
Posts: 82

Rep: Reputation: Disabled
Disallowing sudo user to not able to add user


To allow a sudo user to be able to run commands but not able to add user to the system. Is it possible to do this in Ubuntu? I am assuming its in the sudoer file.


Thanks,
TT
 
Old 12-09-2019, 10:24 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
The sudoers file allows you to specify a "white list" of commands a specific user or group can execute with sudo. It also allows "blacklisting" by putting an exclamation mark right in front of the command.

There is at least one example in the sudoers man page:
Code:
pete		HPPA = /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
You could put useradd in this list. However, a user with root privileges can still add the user manually in the passwd and shadow files. I don't know how you can prevent that from happening.

Last edited by berndbausch; 12-10-2019 at 12:15 AM.
 
Old 12-10-2019, 12:04 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,303
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
Quote:
Originally Posted by berndbausch View Post
I don't know how you can prevent that from happening.
It's there in the first line of your answer.

Quote:
Originally Posted by berndbausch View Post
"The sudoers file allows you to specify a "white list" of commands a specific user or group can execute with sudo. "
Using a whitelist is the only way to achieve the goal: make a list of the specific commands that the account should be allowed to run as root and ennumerate them in /etc/sudoers.

Yeah, technically the syntax allows blacklisting but there are an infinite number of ways to circumvent anything you might try in that regard. There have been several articles and talks about that but it's an easy enough thought experiment to walk through.
 
Old 12-10-2019, 12:20 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Turbocapitalist View Post
It's there in the first line of your answer.
My fear is that whitelisting won't help the original poster, since they mention open-ended "commands" that the user should be able to run. Let's see if anything comes around.

After thinking a bit more, I also believe that blacklisting is not effective. One would have to design the blacklist with a lot of thought and effort to exclude workarounds.

In short, sudo is probably good for giving blanket root privileges, or for allowing a very narrow, carefully crafted command set to have root privileges.
 
Old 12-10-2019, 03:35 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
There are other ways around this. The problem is more of why you made a user sudoer to begin with. This entry almost assures one is root except as noted way above. One way around is to have a user without sudoers and give them all they need normally or give them an ability to su to a higher user that has all they need actually. Setuid special permissions on the tasks that you want only root to have privilege on.
 
Old 12-10-2019, 08:43 PM   #6
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,317
Blog Entries: 28

Rep: Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140
This tutorial may help: https://www.howtoforge.com/tutorial/...ginners-guide/

My understanding is that, in a default Ubuntu installation, only the installing user is given sudo rights. Other users added after time of install do not have sudo access unless it is manually granted by installing user.
 
Old 12-11-2019, 02:06 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
I'm just gonna leave this here:
Sudo: You're Doing it Wrong
Long story short: sudo is much, much more configurable & powerful than the average Ubuntu use case.
Not that I know from experience, but I'll take the developer's word for it.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
VSFTPD Disallowing ROOT login mattp Linux - Security 2 01-26-2006 09:14 AM
phantom drive disallowing lilo reconfiguration rose_bud4201 Linux - Hardware 3 08-12-2003 08:44 AM
Disallowing root login in SSH cire Linux - Networking 3 08-06-2003 09:29 PM
Disallowing apache to use cgi and perl cannus Linux - General 8 12-21-2002 05:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration