90 likes | 223 Views
sudo and not su. that is the answer. Giving away candy instead of the candystore. Macros. Cmnd_Alias ADM = /bin/sh Cmnd_Alias OPS = /sbin/init.d/* Cmnd_Alias VENDOR_CMD = /usr/vendor/bin/* Host_Alias HOSTS = host1, host2, host3 User_Alias ADMIN = user1, user2
E N D
sudo and not su that is the answer
Macros Cmnd_Alias ADM = /bin/sh Cmnd_Alias OPS = /sbin/init.d/* Cmnd_Alias VENDOR_CMD = /usr/vendor/bin/* Host_Alias HOSTS = host1, host2, host3 User_Alias ADMIN = user1, user2 User_Alias OPER = user3, user4 User_Alias APPADMIN_VENDOR = <make-generated-list> User_Alias APP_VENDOR = <make-generated-list>
Rules ADMIN HOSTS = (root) ADM OPER HOSTS = (root) NOPASSWD: OPS myname myhost = (root) ALL APPADMIN_VENDOR HOSTS = (vendor) ALL APP_VENDOR HOSTS = (vendor) NOPASSWD: VENDOR_CMD
Makefile #!/bin/make # Makefile PARTS = sudoers.banner sudoers.commands sudoers.hosts sudoers.users sudoers.groups sudoers.rules all: sudoers sudoers: sudoers.built if visudo –c –f $<; then cp -p $< $@; fi sudoers.built: $(PARTS) cat $(PARTS) > $@ chown root $@ chgrp sys $@ chmod 660 $@
Makefile (cont.) sudoers.groups: echo “# Group Macros” > $@ build_alias_from_csv /directory/of/spreadsheets >> $@ echo >> $@
build_alias_from_csv #!/bin/sh # build_alias_from_csv dir=$1 for file in `ls $dir/*.csv` do alias=`basename $file` echo “User_alias $alias = \c” awk –F, ‘ BEGIN {sep=“”} {print “$sep$1“; sep=“, “} END {} ’ $file done
cronjobs 55 * * * * (cd /net/somewhere; make > make.log 2>&1) 05 * * * * cp /net/somewhere/sudoers /etc/sudoers
using sudo $ sudo –l will list all the commands you can sudo $ sudo –i will login interactively like “su –” $ sudo –u root /sbin/init.d/vendor stop $ sudo –u root /sbin/init.d/vendor stop $ sudo –u vendor –i will allow others to admin as vendor (this allows you to set the password to Non*Hashable!) $ sudo –u vendor /usr/vendor/bin/launch