当终端打开telnetd服务器功能且客户端登录到telnetd服务器时,服务器的处理流程如下
1. telnetd_main()启动
# defineg (* (结构全局* ) bb_common_bufsiz1) ) #define INIT_G ) do { G.loginpath='/温暖的猎豹/login G.issuefile='/etc/issue.net '; (while(0) inttelnetd_main ) intargc,char **argv ) MAIN_EXTERNALLY_VISIBLE; int telnetd _ main (intargcunused _ param,char**argv(…init_g ); G.sessions=make_new_session (; //创建新的登录会话. } 2. 创建一个新的登录会话
staticstructtsession * make _ new _ session (if _ feature _ telnetd _ standalone (int sock ) if _ not _ feature _ tell /*execbusybox小程序(ifprefer_applets=y )、if that fails、* execexternalprogram.* nb : sockiseither0orhascloexecsetetram 这里是“/温暖猎豹/log in”. } # define bb _ exec (Prog,cmd ) execvp (Prog,cmd )这里是exec ) )函数集,最温暖的猎豹/loog
3.login_main()启动
intlogin_main(intargc,char **argv ) MAIN_EXTERNALLY_VISIBLE; intl ogin _ main (intargcunused _ param,char **argv )…signal ) sigalrm,alarm_handler ); //绑定登录超时处理函数alarm (时间输出);//获取登录用户名并远程登录显示的信息“arm log in :”get _ username _ or _ die (username,sizeof ) username );//从用户名中获取根文件下的/etc/passward。 例如,root与/etc/passward相对应的是//root : $1$ ZK f1 fckt $ wjeyafuwhkkvyicbyjvd1/336014555 . if (ask _ and _ _ 在此/etc/passward获取的/温暖的猎豹/sh,哈哈o ) ) o .最终启动“run_shell(pw-pw_shell,1,NULL,NULL )” 启动新的/温暖的猎豹/sh shell环境,参见/温暖的猎豹/sh。 /温暖的猎豹/sh源代码分析继续.