[sudo-users] Using wildcards in sudoers file
megadethpaw at hotmail.co.uk
Tue Sep 29 15:01:03 EDT 2009
I did hope that there would be a way that you could end the sudo command string, say as you can do by placing "" after a command to state no parameters are allowed.
Maybe an idea would be if the sudoers parser could see "" at the end of a command line and say that if a space appears and then any other text it's invalid, eg
/usr/bin/chown root /usr/sap/trans/[A-z]* ""
I know it's far from perfect as a filename could in theory have a space in it, but for 99% of cases I would imagine something such as the above would do the trick.
Thanks for the suggestion though Robin, all ideas gratefully accepted.
> From: Robin.Battersby-Cornmell at uisl.unisys.com
> To: megadethpaw at hotmail.co.uk; sudo-users at sudo.ws
> Date: Tue, 29 Sep 2009 17:10:34 +0100
> Subject: RE: [sudo-users] Using wildcards in sudoers file
> One potential way would be to script the "sudo chown ......" and validate somehow, e.g.
> # Rough and ready chown script
> shift # Drop $1 from parameter list
> for file in $@ # Loop for all subsequent parameters
> if [ ## Work out your file matching criteria here ## ]
> chown $newowner $file
> echo "Change of ownership on $file not allowed"
> Then secure the script and grant a specific sudo rule to allow the specific user to run it.
> Of course, there is no error checking written here really. You should test that the target file does actually exist else the user will get other splattery messages.
> I hope that this helps.
> -----Original Message-----
> From: megadethpaw megadethpaw [mailto:megadethpaw at hotmail.co.uk]
> Sent: Tuesday, September 29, 2009 2:52 PM
> To: sudo-users at sudo.ws
> Subject: [sudo-users] Using wildcards in sudoers file
> I want to be able to give a user permission to use the "/usr/bin/chown" command on solaris using sudo, but only want them to be able to change files or directories under a certain directory, eg "/usr/sap/trans" and any directories underneath.
> Examples of commands I want to allow to run are:- /usr/bin/chown oracle /usr/sap/trans/file1.txt/usr/bin/chown brian /usr/sap/trans/data/filter.csv In the sudoers file I set up the command to allow to run as this:- /usr/bin/chown [A-z]* /usr/sap/trans/[A-z]* This works for the above two commands I do want to use, but it also allows things like this:- /usr/bin/chown brian /usr/sap/trans/data/filter.csv /etc/passwd Now as you can see this is a major problem as don't want to allow that, I basically want to make sure that the chown starts with "/usr/sap/trans" is there any way I can do this?
> Is there a way to exclude spaces from [A-z] in the suduers line?
> Please help as I really need to get this working.
> Thanks Jeff
> Share your photos with Windows Live Photos - Free.
> This email is sent in confidence for the addressee only.
> Unauthorised recipients must preserve this confidentiality and should please advise the sender immediately by returning the original email to us without reading it, taking a copy or disclosing it to anyone else. Please also destroy and delete the email from your computer.
> We have taken reasonable precautions to ensure that no viruses are transmitted to any third party. Unisys Insurance Services Limited does not accept any responsibility for any loss or damage resulting directly or indirectly from the use of this email or its contents.
> Unisys Insurance Services Limited is authorised and regulated by the Financial Services Authority, is a member of the UNISYS group of companies and provides outsourcing services to the Financial Services Industry
> Unisys Insurance Services Limited Registered in England No. 4087012
> Registered Office: Bakers Court, Bakers Road, Uxbridge, UB8 1RG
MSN straight to your mobile - news, entertainment, videos and more.
More information about the sudo-users