Kawm cov kev cai tswjhwm Linux - wtmp

Lub npe

utmp, wtmp - tus ID nkag mus

Synopsis

#include

Kev piav qhia

Cov ntaub ntawv utmp tso cai rau ib qho kom paub txog cov neeg uas tab tom siv lub system. Tej zaum muaj ntau cov neeg siv tam sim no siv lub system, vim hais tias tag nrho cov kev pab cuam siv utmp txiav.

Lus ceeb toom: utmp yuav tsum tsis txhob sau, vim hais tias ntau qhov kev pab cuam (foolishly) nyob ntawm nws txoj kev ntseeg. Koj yuav raug foob qhov system logfiles thiab kev hloov kho ntawm cov ntaub ntawv yog tias koj tawm utmp ntawv sau rau txhua tus neeg siv.

Cov ntaub ntawv yog cov kab pib ntawm cov ntaub ntawv nrog cov qauv hauv qab no hauv cov ntaub ntawv muaj xws li (cim tseg tias qhov no tsuas yog ib qho ntawm ntau cov ntsiab lus nyob ib ncig ntawm xwb; cov ntsiab lus yog nyob ntawm version of libc):

#define UT_UNKNOWN 0 #define RUN_LVL 1 #define BOOT_TIME 2 #define NEW_TIME 3 #define NEW_TIME #define OLD_TIME 4 #define INIT_PROCESS 5 #define LOGIN_PROCESS 6 #define USER_PROCESS 7 #define DEAD_PROCESS 8 #define ACCOUNTING 9 #define UT_LINESIZE 12 #define UT_NAMESIZE 32 #define UT_HOSTSIZE 256 struct exit_status {luv int e_termination; / * txheej txheem tshem tawm txheej xwm. * / luv luv e_exit; / * tawm ntawm txoj cai. * /}; struct utmp {luv ut_type; / * hom login * / pid_t ut_pid; / * pid ntawm tus ID nkag mus * / char ut_line [UT_LINESIZE]; / * ntaus ntawv lub npe tty - "/ dev /" * / char ut_id [4]; / * init id los yog tus tsiaj ntawv. ttyname * / char ut_user [UT_NAMESIZE]; / * neeg lub npe * / char ut_host [UT_HOSTSIZE]; / * hostname rau cov chaw taws teeb login * / struct exit_status ut_exit; / * Tshaj tawm ntawm tus txheej txheem uas sau ua DEAD_PROCESS. * / ntev ut_session; / * ID kev sib tham, siv rau kev txheeb xyuas * / struct timeval ut_tv; / * Lub sijhawm nkag tuaj. * / int32_t ut_addr_v6 [4]; / * Tus IP chaw ntawm cov chaw taws teeb sab nraud. * / char ncoo [20]; / * Yuam sij rau kev siv yav tom ntej. * /}; / * Backwards compatibility hacks. * / #define ut_name ut_user #ifndef _NO_UT_TIME #define ut_time ut_tv.tv_sec #endif #define ut_xtime ut_tv.tv_sec #define ut_addr ut_addr_v6 [0]

Cov qauv no muab lub npe ntawm cov ntaub ntawv tshwj xeeb nrog tus neeg siv lub davhlau ya nyob twg, tus neeg siv tus ID nkag mus lub npe, thiab lub sijhawm nkag mus hauv lub sijhawm (2). Txoj hlua khoob raug tshem tawm ntawm '\ 0' yog tias lawv yog luv dua qhov loj ntawm daim teb.

Thawj nkag tau tsim los ntawm init (8) kev ua hauv (5). Ua ntej pib qhov kev ua tiav, tab sis, init (8) cleans up utmp los ntawm qhov chaw ut_type rau DEAD_PROCESS , clear ut_user , ut_host , thiab ut_time nrog thov bytes rau txhua cov ntaub ntawv uas ut_type tsis DEAD_PROCESS los yog RUN_LVL thiab qhov twg tsis muaj txoj kev nrog PID ut_pid . Yog hais tias tsis muaj cov ntaub ntawv npliag nrog qhov ut_id xav tau, nrhiav tau ib qho tshiab. Nws teev ut_id los ntawm inittab, ut_pid thiab ut_time mus rau qhov tam sim no qhov tseem ceeb, thiab ut_type rau INIT_PROCESS .

getty (8) nrhiav qhov nkag los ntawm lub Disease pid, hloov ut_type rau LOGIN_PROCESS , hloov ut_time , teev ut_line , thiab tos kom kev txuas mus rau. tus ID nkag mus (8), tom qab tus neeg siv tau lees paub, hloov ut_type rau USER_PROCESS , hloov ut_time , thiab teev ut_host thiab ut_addr . Raws li ntawm plaub (8) thiab tus ID nkag mus (8), cov ntaub ntawv kuj yuav nyob ze ntawm ut_line es tsis txhob siv cov ut_pid .

Thaum init (8) pom tias tus txheej txheem tau tawm, nws nrhiav nws cov utmp nkag los ntawm ut_pid , teev ut_type rau DEAD_PROCESS , thiab clears ut_user , ut_host thiab ut_time nrog thov bytes.

xterm (1) thiab lwm yam khoom siv davhlau ya nyob twg ncaj qha tsim cov ntaub ntawv USER_PROCESS thiab tsim lub ut_id los ntawm kev siv ob nqe lus kawg ntawm / dev / ttyp % c lossis siv p % d rau / dev / pts / % d . Yog tias lawv pom DEAD_PROCESS rau daim npav no, lawv rov ua dua tshiab, txwv tsis pub lawv tsim ib qho tshiab. Yog hais tias lawv ua tau, lawv yuav kos nws li DEAD_PROCESS thaum tawm mus thiab nws tau qhia tias lawv thov ut_line , ut_time , ut_user , thiab ut_host zoo li.

xdm (8) yuav tsum tsis txhob tsim daim ntawv utmp, vim tias tsis muaj qhov chaw nres tsheb. Cia nws tsim ib qho yuav ua rau kom raug, xws li 'ntiv tes: tsis stat /dev/machine.dom'. Nws yuav tsum tsim wtmp nkag, ho, zoo li ftpd (8) puas.

telnetd (8) teev ib LOGIN_PROCESS nkag thiab tawm ntawm tus so rau tus ID nkag mus (8) li qub. Tom qab cov kev sib ntsib hauv tsev kho mob xaus, telnetd (8) ua kom pom zoo txog kev ua kom tiav.

Cov ntaub ntawv wtmp teev tag nrho logins thiab logouts. Nws cov hom yog raws nraim li utmp tshwj tsis yog tias cov neeg siv lub npe thov qhia tias logout ntawm lub davhlau ya nyob twg. Txuas ntxiv, lub ntsiab lus xaus "~" nrog tus neeg siv lub npe "shutdown" lossis "reboot" qhia tias kaw qhov kev kaw lossis kev rov tua dua thiab nkawm lub npe ntawm "|" / "}" teev cov qub / tshiab lub sij hawm thaum hnub (1) hloov nws. Wtmp yog tswj los ntawm login (1), init (1), thiab ib co versions of getty (1). Tsis muaj leej twg ntawm cov kev pab cuam no tsim cov ntaub ntawv , yog tias nws raug muab tshem tawm, cov ntaub ntawv khaws tseg yog muab tua.