(po materialam Motorola Unix System V/88 4.0)
Obzor
init (iz /etc/inittab, state 2 ili 3)
|
V
SAC (Service Access Controller) sm. sac(1m)
| | |
V V V
port monitor port monitor ...
| | | |
V V V V
service ...
a takzhe procedura konfiguracii i adm.fajl SAC (/etc/saf/_sysconfig)
procedura konfiguracii i adm.fajl dlya kazhdogo monitora portov
(/etc/saf//_config)
procedura konfiguracii dlya kazhdogo servisa kazhdogo monitora
komanda sacadm(1m)
komanda pmadm(1m)
komandy dlya konkretnyh monitorov ttyadm(1m), nlsadmin(1m)
format procedur konfiguracii opisan v doconfig(3n), naprimer:
assign TZ=EST5EDT
runwait echo SAC is starting > /dev/console
run /usr/bin/daemon
runwait ulimit 4096
runwait umask 077
push modul'_v_potok
(ulimit, umask, cd - vnutrennie komandy)
tol'ko odin servis mozhet byt' svyazan s kazhdym portom
mnogo portov mozhet byt' privyazano k odnomu servisu
Sostoyaniya monitora: STARTING, ENABLED, DISABLED, STOPPING, NOTRUNNING, FAILED
Procedura raboty SAC:
ustanavlivaet okruzhenie
zapuskaet monitory
otslezhivaet ih rabotu i, pri neobhodimosti, perezapuskaet
Struktura adm.fajla sac: sacadm, /etc/saf/..., /var/saf/...
imya(PMTAG) tip(PMTYPE) flagi(FLGS) povtory(RCNT) komanda(COMMAND)
tip - pozvolyaet rabotat' s gruppoj monitorov kak s edinym celym
flagi - d (startovat', no ne razreshat' obsluzhivanie)
x (ne startovat')
povtory - kolichestvo popytok zapustit' monitor
komanda - polnyj put' komandy, realizuyushchej monitor
Adm. procedura monitora beret argumenty iz komandnoj stroki i preobrazuet ih
v formu, prigodnuyu dlya zapominaniya v baze dannyh (ttyadm , nlsadmin)
Struktura adm.fajla monitora: pmadm
pervaya stroka v forme:
# VERSION=
imya monitora, tip monitora, imya servisa, flagi, id.pol'zovatelya, spec.param.
flagi: x (ne razreshat' obsluzhivanie)
u (sozdat' stroku v utmp)
spec.parametry zavisyat ot monitora
Vnimanie: pri avtokonfiguracii ustrojstva mogut byt' pereadresovany
sm. boot(1m), /etc/device-map
/usr/lib/saf/sac -t
sacadm -l [ -p | -t ] # vyvesti inf. o monitorah
sacadm -a -p -t -c "" -v
[ -f [d|x] ] [ -n ] [ -y "" ]
[ -z ]
dobavit' monitor portov
versiya obychno vypolnyaetsya tak: -v `ttyadm -V`
sacadm -e -p # razreshit' servis
sacadm -d -p # zapretit' servis
sacadm -s -p # zapustit' monitor
sacadm -k -p # ostanovit' monitor (kill SIGTERM)
sacadm -r -p # udalit' opisanie monitora
sacadm -G [ -z ] # pokazat' ili ustanovit'
sacadm -g -p [ -z ]
sacadm -x [ -p ] # perechitat' adm. fajl (esli pomenyali ego
# v tekstovom redaktore (luchshe ne nado)
pmadm -l [ -t | -p ] [ -s ]
# pokazat' informaciyu
pmadm -a [ -p | -t ] -s
-i -m "" -v [ -f [x|u] ]
[ -y "kommentarij" ] [ -z ]
# dobavit' servis k monitoru(am)
pmadm -e -p -s # razreshit' servis
pmadm -d -p -s # zapretit' servis
pmadm -r -p -s # udalit' servis
pmadm -g -p -s [ -z ]
pmadm -g -t -s -z
ttymon
ttymon zamenyaet getty i uugetty
inicializiruet i sledit za portami
zapuskaet ukazannyj stream-modul'
ustanavlivaet rezhimy terminala termio(7) i skorost' linii
vydaet priglashenie i zhdet
esli prihodit hot' odin neBREAK simvol, za kotorym idet NL,
to zapuskaet servis (obychno login)
esli vmesto priglasheniya, pol'zovatel' vidit musor, to on zhmet
knopku BREAK, i ttymon perehodit k sleduyushchej metke v /etc/ttydefs
autobaud - pered vydachej priglasheniya, ttymon chitaet simvol
i, schitaya chto eto NL, pytaetsya opredelit' skorost' (5 popytok)
esli ne poluchilos', to kak obychno perehodim k sleduyushchej metke
esli port zakryt, to servis na nem ne zapuskaetsya
esli monitor zakryt, to VSE ego porty zakryty, skorost' i rezhimy
ne ustanovleny!
pri zapuske servisa monitor zamenyaet %d na polnoe imya porta
(ustrojstva), pri zapuske servisa ego deskriptory 0, 1 i 2
otkryvayutsya na eto ustrojstvo
ldterm - line discipline module: libo zagruzhaetsya servisom, libo
cherez autopush(1m): zadaet strim-moduli, zagruzhaemye v potok pri
otkrytii ustrojstva (zadayutsya st. i ml. nomera ustrojstva i spisok
modulej), obespechivaet pochti ves' terminal'nyj servis (krome
upravleniya ustrojstvom - c_cflag i IGNBRK, IGNPAR, PARMRK, INPCK
obrabatyvaet mnogobajtnye simvoly
dlya console i contty servisy zadayutsya ne cherez monitor portov, a
neposredstvenno v /etc/inittab s pomoshch'yu ekspress-rezhima (sm. ttymon(1m)
/usr/lib/saf/ttymon -g [-h] [-d device] [-l ttylabel] [-t timeout]
[-p prompt] [-m modules] # ekspress-rezhim (parametry sm. nizhe)
/etc/inittab
metka:uroven'_vypolneniya:dejstvie:process
dejstvie: respawn - povtornyj zapusk v parallel'
wait - zapustit' odin raz i zhdat' zaversheniya
once - zapustit' odin raz, no ne zhdat'
boot - zapustit' odin raz posle zagruzki, ne zhdat'
bootwait- zapustit' odin raz posle zagruzki, zhdat'
powerfail-zapustit' pri poluchenii signala SIGPWR
powerwait-to zhe, no zhdat' zaversheniya
off - ne zapuskat', esli uzhe est', to ostanovit'
ondemand- analog respawn
inidefault-pri zapuske init opredelyaet uroven' vyp-ya
ne stav'te 6 ili pusto (budet zaciklivanie)
sysinit - zapustit' (zhdat') do opredeleniya urovnya vyp-ya
process: delaetsya sh -c 'exec process'
ne zabud'te vydat' init q
sacadm -a -p -t ttymon -c /usr/lib/saf/ttymon -v `ttyadm -V`
pmadm -a -p -s -i root [ -f [u|x] ]
-v `ttyadm -V` -m "`ttyadm [ -b ] [ -r count ] [ -c ]
[ -h ] [ -i msg ] [ -m ldterm ] [ -p prompt ]
[ -t timeout ] -d device -l ttylabel -s /usr/bin/login`"
gde msg - soobshchenie, vydavaemoe na zakrytyj terminal
-b dvunapravlennyj port (i vhodyashchie i vyhodyashchie vyzovy)
(BNU dolzhen byt' ustanovlen)
ttylabel - metka v /etc/ttydefs (ranee byl /etc/gettydefs)
Format ttydefs (v buduyushchem mozhet byt' izmenen, tak chto pol'zujsya sttydefs(1m)):
metka:nach-flagi:kon-flagi:autobaud:metka-perehoda
flagi - lyubye parametry stty
mach-flagi ustanavlivayutsya pered vydacheh priglasheniya
kon-flagi ustanavlivayutsya posle zaprosa, no do zapuska servisa
Kstati sttydefs -l pozvolyaet proverit' pravil'nost' fajla /etc/ttydefs
/usr/sbin/ttyadm [ -b ] [ -c ] [ -r count ] [ -h ] [ -i msg ] [-m modules ]
[ -p prompt ] [ -t timeout ] -d device -l ttylabel -s service
-b dvunapravlennyj port (pozvolyaet kak zvonit' na etot port, tak i s nego)
-c monitor zapuskaet servis kak tol'ko obnaruzhena nesushchaya (t.e. ne vydaet
priglashenie i ne opredelyaet skorost' porta)
-d polnoe imya ustrojstva
-h esli flag ne ukazan, to monitor sbrasyvaet liniyu (na vremya ustanavlivaya
nulevuyu skorost') pered ustanovkoj skorosti
-i soobshchenie, vydavaemoe na neaktivnyj ili zablokirovannyj port
-l metka iz /etc/ttydefs
-m spisok STREAM-modulej, razdelennyh zapyatoj, kotorye budut zapihany v
potok pered zapuskom servisa vmesto teh, kotorye byli tam ranee
-r schetchik NL, kotorye monitor zhdet iz porta pered tem kak niciirovat' ego
-p priglashenie
-s polnoe imya programmy, otvechayushchej za servis
-t esli ukazano, to prozhdav eto vremya i nichego ne poluchiv monitor zakryvaet
port
-V vydat' nomer versii
termio
pervyj terminal'nyj fajl, otkryvaemyj liderom sessii (sessiya - eto vsya
sovokupnost' processov, porozhdennyh liderom, poka ocherednoj process
ne vyzovet sistemnyj primitiv smeny sessii), stanovitsya upravlyayushchim
terminalom sessii. Processy, delyatsya na gruppy, odna iz kotoryh
yavlyaetsya gruppoj perednego plana, ostal'nye zadnego.
hungup s tochki zreniya komp'yutera - eto sbros DTR (delaetsya ustanovkoj
nulevoj skorosti)
rezhimy dlya normal'noj raboty:
-ignbrk, brkint - razreshit' preryvanie po BREAK
-parmrk, ignpar, inpck - zapretit' proverku chetnosti
-istrip, -inlcr, igncr&-icrnl / -igncr&icrnl, -iuclc - preobr.vvoda
ixon, -ixany, ixoff - sinhronizaciya vvoda/vyvoda
opost, -olcuc, onlcr, -ocrnl, -onocr, -onret - preobr.vyvoda
ofill, nl0, cr0, tab3, bs0, vt0, ff0 - zaderzhki
b9600 | b19200 | b38400 - skorost' po vkusu
-cstopb, cread, -parenb, hupcl - rezhimy linii
[-]clocal - modem ili terminal
isig, icanon, -xcase, echo, echoe, echoke, echoctl - red-e stroki
-flusho, -pendin, iexten - rasshireniya
/usr/lib/saf/listen [ -m devstem ] net_spec
listen otslezhivaet setevoj transport, orientirovannyj na soedineniya
(TCP), poluchaet vhodyashchie zaprosy i vyzyvaet sootvetstvuyushchij servis
obespechivaet privatnyj adres transporta v dopolnenie k imeni servisa,
peredachu deskriptora fajla vhodnogo soedineniya postoyanno
vypolnyaemomu serveru vmesto fork/exec (cherez FIFO ili imenovannyj
STREAM), podderzhivaet servisy, kotorye pol'zuyutsya soketami vmesto
TLI (realizuyutsya cherez STREAM-moduli), v tom chisle RPC, staticheski
ili dinamicheski naznachaemye adresa
na kazhduyu set' d.b. hotya by odin listen
Samostoyatel'noe ispol'zovanie nlsadmin
net_spec: otnositel'noe imya tochki vhoda v /dev dlya seti (transport-provajder)
adres: libo simvol'noe predstavlenie setevogo adresa, libo \x a zatem
shestnadcaterichnoe predstavlenie adresa
nlsadmin -x # vydat' sostoyanie vseh listen-processov
nlsadmin net_spec # vydat' sostoyanie listen-processa dlya dannoj seti
nlsadmin -v net_spec # vydat' bolee boltlivyj otchet
nlsadmin -z kod_servisa net_spec # vydat' otchet dlya dannogo servisa
nlsadmin -l adres net_spec # ustanavlivaet ili izmenyaet bazovyj adres
nlsadmin -t adres net_spec # ustanavlivaet ili izmenyaet adres terminal'nogo
servisa
nlsadmin -i net_spec # inicializiruet ustanovku listen dlya dannoj seti
# dolzhen byt' vydan do naznacheniya adresov ili servisov
nlsadmin -a service_code [-p modules] [-w username] -c cmd -y comment
# dobavit' servis; service_code stroka simvolov: ot 0 do 100
# zarezervirovany dlya vnutr.polo'zovaniya; 0 - nlps server, kotoryj
# vyzyvaetsya pri zaprose po bazovomu adresu; 1 - remote login servis;
# po umolchaniyu v kachestve imeni pol'zovatelya ispol'zuetsya imya
# pol'zovatelya, vydavshego zapros
nlsadmin -r service_code net_spec # udalit' servis
nlsadmin -e service_code net_spec # razreshit' servis
nlsadmin -d service_code net_spec # zapretit' servis
nlsadmin -s net_spec # zapustit' monitor
nlsadmin -k net_spec # ostanovit' monitor
Ispol'zovanie nlsadmin pod SAF
pod SAF dlya kazhdoj seti mozhno opredelit' nesol'ko monitorov; togda oni
razlichayutsya po -N
nlsadmin -c cmd|-o pipename [-p modules] [-A address|-D]
[-R prognum:versnum]
ispol'zuetsya dlya formatirovaniya informacii dlya pmadm
server zadaetsya libo imenem (-c cmd) ili imenem FIFO ili STREAM (-o pipename)
-A zadaet chastnyj adres
-D dinamicheskoe zadanie adresa; v sochetanii s -R pozvolyaet registrirovat'
dinamicheskij adres cherez rpcbinder
nlsadmin dlya sovmestimosti pozvolyaet dobavlyat' i udalyat' servisy, zapuskat'
i ostanavlivat' listen, zaprashivat' status (hotya na samom dele eto
delaetsya cherez SAF).
pmadm -a -p -s -i
-m "`/usr/sbin/nlsadmin ` -v `nlsadmin -V` -y ""
pmadm -l -p tcp:
tcp listen 0 - root \x00020ace980a01060000000000000000 - c - /usr/lib/saf/nlps_server
# NLPS server (dlya sovmestimosti dlya staryh listen)
tcp listen 1 - listen - c - /usr/slan/lib/ttysrv -m ntty,tirdwr,1d0
# TTY server (remote login, t.e. cu cherez set')
tcp listen 101 - listen - c - /usr/lib/uucp/uucico -r0 0unuucp -iTLI
# uucp access direct to server
tcp listen 102 - listen - c - /usr/slan/lib/ttysrv -d -m ntty,tirdwr,1d0
# uucp access to server via login
ZHurnaly:
/var/saf/_log
/var/saf//log
/var/saf//o.log
getty [ -h ] [ -t timeout ] line [ speed [ terminal [ linedisc ] ] ]
vydaet priglashenie, zhdet imya pol'zovatelya i vyzyvaet login
line - imya fajla v /dev
-h - zapreshchaet hangup (sbros skorost' v 0)
-t - vremya ozhidaniya vvoda imeni pol'zovatelya
speed - imya v /etc/ttydefs
terminal - tip terminala
linedisc - imya discipliny linii
/usr/lib/uucp/uugetty [-t timeout] [-r] line [speed [type [linedisc] ] ]
analogichno getty, no mozhno ispol'zovat' v oboih napravleniyah
(dlya cu, uucico, ct). login zapuskaetsya libo po gotovnosti linii,
libo (klyuch -r) po prihodu pervogo simvola (inache dva uugetty budut
beskonechno zhdat' drug druga). Dlya uucico postav'te
"" \r\d\r\d\r\d\r in:--in: . . .
30:2:respawn:/usr/lib/uucp/uugetty -r -t 60 tty12 1200
linedisc - mozhet byt' tol'ko LDISC0
Last-modified: Tue, 26 Aug 2003 12:29:50 GMT