Administration von Unix-Rechnern mit cfengine
Erfahrungen und Probleme
Sysadmin-Organisation
- Administrationsdomänen (verteilte kooperative Sysadmin)
-
- vertikale Administrationsdomäne: Root-Admin für alle Hosts einer BS-Plattform
- horizontale Administrationsdomänen: Spezialisten sind für spezielle Problembereiche auf allen BS-Plattformen verantwortlich
- Für korrekte Konfiguration eines Hosts ist Root-Admin allein verantwortlich
- bei speziellen Problemen in einer horizontale Administrationsdomäne auf einem Host: Root-Admin stellt Anforderung an betreffenden Spezialisten
- Modifikation von Host-Konfigurationsfiles (nach der Installation) nur über Master-Konfigurationsfiles
- Admin-Aktionen werden mittels priv und dem normalen Nutzer-Account realisiert
- Überblick über priv
-
- differenzierte und flexible Zugriffsteuerung auf Basis
-
- des Nutzer-Accounts,
- der Mitgliedschaft von group oder netgroup,
- dem Typ des Host oder
- des Betriebssystems
- Steuerung der Kommandozeilen-Argumente
- SUID-Wrapper plus Policy-Database
- alle Aktionen werden protokolliert
- Beispiel: /etc/priv_policy für Klasse PC_Pool
rpm :passwd: \ :login=wmc,tla: \ :argv=/bin/rpm,$*: cfengine :passwd: \ :login=wmc,tla,meh,thm,ghe: \ :argv=/uni/global/bin/cfengine,$*: glint :passwd: \ :login=wmc,tla: \ :argv=/usr/bin/glint,$*: kill :login=thm,meh,czi,wmc,dgr,ghe,stb,tla,bmu,gha,cho,imu,anhe: \ :passwd: \ :argv=/bin/kill,$*: reboot :passwd: \
:argv=/sbin/reboot: halt :passwd: \ :argv=/sbin/halt: rrpm :login=wmc,tla: \ :argv=/bin/rpm,$*: rcfengine :login=wmc,tla: \ :argv=/uni/global/bin/cfengine,$*: |
-
- Administration von /etc/priv_policy mit cfengine
- Aufbau des Prototyp-Files im AFS (PRIVPOLICY)
- Installation des Mechanismus auf dem Host mittels cfengine
echo " priv_policy installieren ..." cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS echo -n "Bitte AFS-Nutzerkennzeichen eingeben: " read NKZ if ! /usr/afsws/bin/klog $NKZ; then echo "Abbruch!" exit 1 fi cfengine -q -v -DPRIV -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PRIV.$$ |
- cfengine.spec.conf
### # cfengine.spec.conf # cfengine special configuration for RedHat Linux, URZ TU Chemnitz # 25.02.98 wmc ### # BEGIN cfengine.spec.conf import: any:: # # # END cfengine.spec.conf |
- cf.linux_PrivPolicy
### # cf.linux_PrivPolicy # cfengine configuration for RedHat Linux, URZ TU Chemnitz # 03.02.98 wmc ### # BEGIN cf.linux_PrivPolicy copy: PhilPriv.privupd:: Mb3Priv.privupd:: PhysikPool.privupd:: .... CanServer.privupd:: DbServer.privupd:: tech7.privupd:: ################# any.privupd:: ################# # END cf.linux_PrivPolicy |
- System-Sicherheit gefährdet: Zugriffsrechte für Verzeichnis PRIVPOLICY !!
- Aktualisieren über turnusmäßigen cfengine-Aufruf (z.B. täglich über cron)
Aufruf der cfengine-Scripts
- nach der Installation des Systems (kommt später)
- während des Boot-Vorgangs
-
- File root4Allsystems/etc/rc.d/init.d/cf.startup wird beim Booten nach Netzinitialisierung und afs-Start ausgeführt:
#!/bin/sh ################################################ # ACHTUNG! Aenderungen in diesem File sind zwecklos, da es von # cfengine gewartet wird # wmc, 06.05.97 ################################################ # Wenn AFS verfuegbar, wird cfengine bei jedem Boot ausgefuehrt (Normalfall) # Test, ob AFS gestartet werden soll/sollte/kann/konnte # es kann zu diesem Zeitpunkt kein cfengine laufen! if [ -x /afs/.tucz/admin/linux/REDHAT/CFENGINE/NSCRIPTS/startup_check.sh ]; then |
- File startup_check.sh
# !/bin/sh # Startup-Check fuer RedHat-Linux-Syteme durch cfengine # Laeuft bei jedem Booten nach Netz- und AFS-Initialisierung # 06.05.97 wmc # 12.08.97 wmc (mail to root) # 20.02.98 wmc (Umstellung auf neue cfengine-"Technologie") HOST=`hostname -s` LOG_DIR=/afs/.tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS exec >> ${LOG_DIR}/${HOST}/cfengine_startup_check.log 2>> ${LOG_DIR}/${HOST}/cfengine_startup_check.log echo "===`date`===$*===BEGIN===" 2>&1 cat /etc/issue >${LOG_DIR}/${HOST}/ISSUE cfengine -q --no-lock --inform -DHourly -DMOTD -NStaroffice if [ $? -ne 0 ] |
- regelmäßig per cron
-
- root4Allsystems/etc/cron.cfengine/cfengine.hourly
$ cat root4Allsystems/etc/cron.cfengine/cfengine.hourly /usr/sbin/afs_cron /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_hourly.sh $ cat /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_hourly.sh HOST=`hostname -s` export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS /usr/afsws/bin/fs flushv /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS # wait 1...255 seconds depending on ip-adr LOG_DIR=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS echo "===`date`===$*===BEGIN===" 2>&1 # Hourly --> all actions, which should done hourly if [ $? -ne 0 ] |
- root4Allsystems/etc/cron.daily/cfengine.daily
$ cat root4Allsystems/etc/cron.daily/cfengine.daily /usr/sbin/afs_cron /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_daily.sh $ cat /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_daily.sh HOST=`hostname -s` export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS # wait 1...255 seconds depending on ip-adr LOG_DIR=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS echo "===`date`===$*===BEGIN===" 2>&1 cat /etc/issue >${LOG_DIR}/${HOST}/ISSUE # Daily --> all actions, which should done daily (nightly) cfengine --inform -DPRIV -f cfengine.spec.conf if [ $? -ne 0 ] /bin/rpm -qa >${LOG_DIR}/${HOST}/rpm_qa.log |
-
- analog
- weekly bzw. monthly
- Aufruf von cfengine bei Bedarf "on the fly" durch Script root4Allsystems/usr/local/bin/sys_update:
$ cat root4Allsystems/usr/local/bin/sys_update #!/bin/sh # # /usr/local/bin/sys_update: # # Das Script kann von allen in der priv-Datenbasis (/etc/priv_policy) # autorisierten Nutzern benutzt werden, # um Aenderungen im cfengine-Repository eines Hosts # (/afs/tucz/admin/linux/REDHAT/CFENGINE/*) # in das root-Filesystems des betreffenden Hosts zu uebertragen # Es wird das NIS-Passwort des Aufrufers abgefragt (falls der Aufruf # nicht in den letzen 5 Minuten bereits erfolgte) # Die Protokollierung der cfengine-Aktionen erfolgt in # /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS/<hostname>/linux_conf_sys_update.$LOGNAME # d.h. fuer jeden (autorisierten) Nutzer wird ein Logfile fuer diesen Host # (fort)geschrieben # # 07.08.97 wmc /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.linux_sys_update.sh $ cat /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.linux_sys_update.sh HOST=`hostname -s` export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS LOG_DIR=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS/ echo "===`date`===$*===BEGIN===" $2>&1 >> $LOG_FILE cat /etc/issue >${LOG_DIR}/${HOST}/ISSUE if [ $? -ne 0 ] |
Einbeziehen eines neuen Systems <hostname>
- Fall 1: es gibt bereits Systeme mit gleichem Einsatzzweck (gleicher Funktion), d.h. es existieren "passende" Klassen bzgl. Funktionalität und Eigenschaften
-
- im File cf.linux_Classes Klasse <hostname> an entsprechenden Stellen hinzufügen
- Source-Root für Klasse <hostname> aufbauen (Verzeichnisstruktur <hostname>, z.B. Script make_source_root_host)
- (evtl.) priv_policy einrichten
- Systeminstallation
- Ausführung von Post-Install-Scripts, um notwendige Voraussetzungen zu schaffen
- evtl. spezielle SW-Installationen: ssh_host_key, priv_policy, Printer-Installation, afs_cron, StarOffice,... (siehe unten)
- neu Booten
- Host-spezifische Konfigurationsfiles und Infos nach Source-Root für Klasse <hostname> speichern (z.B. Script host_info)
- Beispiel für Post-Install-Scripts
# cd /afs/tucz/admin/linux/REDHAT/CFENGINE/NSCRIPTS
# cat host_inst_part_one
#!/bin/sh
export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS
export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etc
CF_PATH=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/ROOTS/root4RH51/usr/local/binecho "rmdir /var/spool/mail"
rmdir /var/spool/mail
echo "mkdir /usr/local/opt"
cp -p -d -r /opt /usr/local >&/dev/null
/bin/rm -rf /opt >&/dev/null
mkdir /usr/local/opt >&/dev/null
echo "ln -s /usr/local/opt /opt"
ln -s /usr/local/opt /opt# nur fuer PhysikPool !!!!!!
rm /etc/rc.d/rc3.d/S72amd# 3.6.97 muss auf allen Kisten einmal laufen
echo "rmdir /mnt/floppy"
/bin/rmdir /mnt/floppy >&/dev/nullecho "cfengine.conf (-DDaily) (1)"
cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS
$CF_PATH/cfengine -q -v -DDaily >&/tmp/cf.linux_conf_allgemein.1.$$echo "cfengine.conf (-DDaily) (2)"
$CF_PATH/cfengine -q -v -DDaily >&/tmp/cf.linux_conf_allgemein.2.$$echo "cfengine.spec.conf (PWDORIG)"
$CF_PATH/cfengine -v -q -DPWDORIG -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDORIG.$$echo "cf.conf_edit_lokal_passwd"
$CF_PATH/cfengine -v -q -DPWDLOKAL -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDLOKAL.$$...
# cat host_inst_part_two
#!/bin/sh
export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS
export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etccd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS
echo " ssh installieren ..."
./ssh_install#cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS
#echo " ssh re-installieren ..."
#./ssh_host_key_re_installecho " priv_policy installieren ..."
cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS
echo -n "Bitte AFS-Nutzerkennzeichen eingeben: "
read NKZ
if ! /usr/afsws/bin/klog $NKZ; then
echo "Abbruch!"
exit 1
ficfengine -q -v -DPRIV -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PRIV.$$
echo " afs_cron installieren ..."
cfengine -q -v -DAFSCRON -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.AFSCRON.$$#echo " staroffice installieren ..."
#./star_instecho " kde, autorpm und ctwm installieren ..."
rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/kde*
rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/autorpm-*.i386.rpm
rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/ctwm-*.i386.rpm
rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/xsession*.i386.rpm
rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/ncurses3*.i386.rpm
#rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/sndconfig-0.21-2.i386.rpmecho "rm /etc/cron.daily/autorpm"
/bin/rm /etc/cron.daily/autorpmsh /etc/cron.daily/updatedb.cron
echo "jetzt pruefen: /etc/ssh*, /etc/.afs_cron, /etc/priv_policy ..."
echo "falls O.K. --> reboot"
vi /usr/vice/etc/cacheinfo
ls -l /etc/priv* /etc/ssh* /var/spool/printers/ /etc/.afs*
date
echo -n "Soundkartentest - <ENTER> "
read abc
/sbin/pnpdump | grep "# ANSI string"
if [ $? = 0 ];then
echo "Rechner hat eine Soundkarte - evtl. bezueglich Kern beachten !!!"
echo "<ENTER> :"
read abcd
rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/sndconfig-0.21-2.i386.rpm
/usr/sbin/sndconfig
fi
/sbin/pnpdump | grep "# No boards found"
if [ $? = 0 ];then
echo "Rechner hat keine Soundkarte - Kern unproblematisch."
echo
fi
- Fall 2: Systeme mit gleicher Funktionalität und/oder Eigenschaften nicht vorhanden, d.h. es existieren noch keine "passenden" Klassen
- im File cf.linux_Classes Klasse <hostname> an entsprechenden Stellen hinzufügen
-
- zusätzlich
- geeignete Klassen bzgl. Funktionalität und Eigenschaften entwerfen und in cf.linux_Classes einfügen
- Source-Root für Klasse <hostname> aufbauen (Verzeichnisstruktur <hostname>, z.B. Script make_source_root_host)
- Source-Root für die neu definierten Klassen aufbauen
- (evtl.) priv_policy einrichten
- Systeminstallation usw.
- Fall 3: System gehört zu einer noch nicht vorhandenen Administrationsdomäne (DOM_xxx)
-
- neue Admin-Domäne (entsprechend der Anforderungen und Bedingungen) definieren (einschließlich Scripts und Verzeichnishierarchie)
- weiter analog Fall 2
Spezielle Probleme
- Drucker-Installation: printer_install [-s <standard_drucker>] <druckername>...<directory>
- ssh-Konfiguration (Script ssh_install)
#!/usr/afsws/bin/pagsh # Secure-Shell: (erst nach AFS-Install) # echo -n "Bitte AFS-Nutzerkennzeichen eingeben: " # Existierte fuer den Host bereits ssh_host_key? # Erzeugen des Host Keys (/etc/ssh_host_key und /etc/ssh_host_key.pub) # Public Key an thm schicken! -- der steht auch in /etc/ssh_host_key.pub |
- analog: ein System soll komplett neu installiert werden , aber seinen private host key behalten --> (Script ssh_host_key_re_install)
- Problem: einheitlich Einträge für bestimmte Accounts in /etc/passwd (z.B. nobody, not)
-
- Original-Passwortfile korrigieren
# cfengine -v -q -DPWDORIG -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDORIG.$$ ... --> cf.linux_Edit_Orig_Passwd
# cat cf.linux_Edit_Orig_Passwd
###
# cf.linux_Edit_Orig_Passwd
# cfengine configuration for RedHat Linux, URZ TU Chemnitz
# 05.02.98 wmc
#### BEGIN cf.linux_Edit_Orig_Passwd
# Korrigiere Original(!)-Passwordfile
####################################
#root:?????:0:0:root:/root:/bin/bash
#bin:*:1:1:bin:/bin:
#daemon:*:2:2:daemon:/sbin:
#adm:*:3:4:adm:/var/adm:
#lp:*:4:7:lp:/var/spool/lpd:
#sync:*:5:0:sync:/sbin:/bin/sync
#shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown
#halt:*:7:0:halt:/sbin:/sbin/halt
#mail:*:8:12:mail:/var/spool/mail:
#news:*:9:13:news:/var/spool/news:
#uucp:*:10:14:uucp:/var/spool/uucp:
#operator:*:11:0:operator:/root:
#games:*:12:100:games:/usr/games:
#gopher:*:13:30:gopher:/usr/lib/gopher-data:
#ftp:*:14:50:FTP User:/home/ftp:
#nobody:*:99:99:Nobody:/:
#####################################
# wmc 03.12.97editfiles:
SambaServer::
{ /etc/passwd
LocateLineMatching "nobody:\*:99:99:Nobody:/:"
IncrementPointer "1"
BeginGroupIfNoMatch "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash"
InsertLine "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash"
InsertLine "netz:2BTtut3OrhEQk:97:10:Netz-Admin:/home/netz:/bin/bash"
EndGroup
}...
UrzPriv|PC_Pool_ADM::
{ /etc/passwd
LocateLineMatching "nobody:\*:99:99:Nobody:/:"
IncrementPointer "1"
BeginGroupIfNoMatch "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash"
InsertLine "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash"
InsertLine "+@urz_mitarbeiter::65535:65535:::"
InsertLine "+::65535:65535:::/uni/global/etc/nouserid"
EndGroup
}...
# END cf.linux_Edit_Orig_Passwd
# cfengine -v -q -DPWDLOKAL -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDLOKAL.$$ ... --> cf.linux_Edit_Local_Passwd
# cat cf.linux_Edit_Local_Passwd
###
# cf.linux_Edit_Local_Passwd
# cfengine configuration for RedHat Linux, URZ TU Chemnitz
# 05.02.98 wmc
#### BEGIN cf.linux_Edit_Local_Passwd
editfiles:
any.!SambaServer::
{ /etc/passwd
SplitOn ":"
ForEachLineIn "lokale_passwd_eintraege"
ReplaceLinesMatchingField "1"
EndLoop}
SambaServer::
{ /etc/passwd
SplitOn ":"
ForEachLineIn "lokale_passwd_eintraege.samba_server"
ReplaceLinesMatchingField "1"
EndLoop}
# END cf.linux_Edit_Local_Passwd
... File lokale_passwd_eintraege
# cat lokale_passwd_eintraege
nobody:*:65535:65535:Nobody:/:
not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash
28. November 1997, überarbeitet am 03.12.1998
Matthias Clauß, TU Chemnitz, URZ