/* * end_slc * * Finish up the slc negotiation. If something to send, then send it. */ int end_slc(unsigned char **bufp) { int len; /* * If a change has occured, store the new terminal control * structures back to the terminal driver. */ if (slcchange) { set_termbuf(); } /* * If the pty state has not yet been fully processed and there is a * deferred slc request from the client, then do not send any * sort of slc negotiation now. We will respond to the client's * request very soon. */ if (def_slcbuf && (terminit() == 0)) { return 0; } if (slcptr > (slcbuf + 4)) { if (bufp) { *bufp = &slcbuf[4]; return(slcptr - slcbuf - 4); } else { sprintf(slcptr, "%c%c", IAC, SE); slcptr += 2; len = slcptr - slcbuf; writenet(slcbuf, len); netflush(); /* force it out immediately */ } } return 0; }
int send_req(int id,char encrypt,int finished,int srvtype,int transid,int length) { char chlen[16]; length+=32; memcpy(tcpbuf.flag,MSGFLAG,4); sprintf(chlen,"%04d",length); memcpy(tcpbuf.msglen,chlen,4); sprintf(tcpbuf.srvtype,"%08d",srvtype); sprintf(tcpbuf.transid,"%08d",transid); tcpbuf.finished=finished; tcpbuf.msgtype=REQ_TYPE; tcpbuf.encrypt=encrypt; memcpy(tcpbuf.reserve," ",5); printf("\nSND:%s[%d]\n",(char *)&tcpbuf,length); return writenet(id,(char *)&tcpbuf,length); }
/* ARGSUSED */ void startslave(const char *host, const char *utmp_host, int autologin, char *autoname) { int i; #ifdef AUTHENTICATION if (!autoname || !autoname[0]) autologin = 0; if (autologin < auth_level) { fatal(net, "Authorization failed"); exit(1); } #endif { char *tbuf = "\r\n*** Connection not encrypted! " "Communication may be eavesdropped. ***\r\n"; #ifdef ENCRYPTION if (!no_warn && (encrypt_output == 0 || decrypt_input == 0)) #endif writenet(tbuf, strlen(tbuf)); } # ifdef PARENT_DOES_UTMP utmp_sig_init(); # endif /* PARENT_DOES_UTMP */ if ((i = fork()) < 0) fatalperror(net, "fork"); if (i) { # ifdef PARENT_DOES_UTMP /* * Cray parent will create utmp entry for child and send * signal to child to tell when done. Child waits for signal * before doing anything important. */ int pid = i; void sigjob (int); setpgrp(); utmp_sig_reset(); /* reset handler to default */ /* * Create utmp entry for child */ wtmp.ut_time = time(NULL); wtmp.ut_type = LOGIN_PROCESS; wtmp.ut_pid = pid; strncpy(wtmp.ut_user, "LOGIN", sizeof(wtmp.ut_user)); strncpy(wtmp.ut_host, utmp_host, sizeof(wtmp.ut_host)); strncpy(wtmp.ut_line, clean_ttyname(line), sizeof(wtmp.ut_line)); #ifdef HAVE_STRUCT_UTMP_UT_ID strncpy(wtmp.ut_id, wtmp.ut_line + 3, sizeof(wtmp.ut_id)); #endif pututline(&wtmp); endutent(); if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) { write(i, &wtmp, sizeof(struct utmp)); close(i); } #ifdef _CRAY signal(WJSIGNAL, sigjob); #endif utmp_sig_notify(pid); # endif /* PARENT_DOES_UTMP */ } else { getptyslave(); #if defined(DCE) /* if we authenticated via K5, try and join the PAG */ kerberos5_dfspag(); #endif start_login(host, autologin, autoname); /*NOTREACHED*/ } }