Mercurial > dropbear
comparison svr-chansession.c @ 568:005530560594
Rearrange getaddrstring() etc
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 01 Sep 2009 16:38:26 +0000 |
parents | 893a9dd0b9dd |
children | 6f472dc54da7 |
comparison
equal
deleted
inserted
replaced
567:893a9dd0b9dd | 568:005530560594 |
---|---|
248 | 248 |
249 return 0; | 249 return 0; |
250 | 250 |
251 } | 251 } |
252 | 252 |
253 static struct logininfo* | |
254 chansess_login_alloc(struct ChanSess *chansess) { | |
255 char *remotehost; | |
256 struct logininfo * li; | |
257 get_socket_address(ses.sock_in, NULL, NULL, &remotehost, NULL, 1); | |
258 li = login_alloc_entry(chansess->pid, ses.authstate.username, | |
259 remotehost, chansess->tty); | |
260 m_free(remotehost); | |
261 return li; | |
262 } | |
263 | |
253 /* clean a session channel */ | 264 /* clean a session channel */ |
254 static void closechansess(struct Channel *channel) { | 265 static void closechansess(struct Channel *channel) { |
255 | 266 |
256 struct ChanSess *chansess; | 267 struct ChanSess *chansess; |
257 unsigned int i; | 268 unsigned int i; |
271 m_free(chansess->cmd); | 282 m_free(chansess->cmd); |
272 m_free(chansess->term); | 283 m_free(chansess->term); |
273 | 284 |
274 if (chansess->tty) { | 285 if (chansess->tty) { |
275 /* write the utmp/wtmp login record */ | 286 /* write the utmp/wtmp login record */ |
276 li = login_alloc_entry(chansess->pid, ses.authstate.username, | 287 li = chansess_login_alloc(chansess); |
277 ses.remotehost, chansess->tty); | |
278 login_logout(li); | 288 login_logout(li); |
279 login_free_entry(li); | 289 login_free_entry(li); |
280 | 290 |
281 pty_release(chansess->tty); | 291 pty_release(chansess->tty); |
282 m_free(chansess->tty); | 292 m_free(chansess->tty); |
576 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ | 586 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ |
577 static int sessioncommand(struct Channel *channel, struct ChanSess *chansess, | 587 static int sessioncommand(struct Channel *channel, struct ChanSess *chansess, |
578 int iscmd, int issubsys) { | 588 int iscmd, int issubsys) { |
579 | 589 |
580 unsigned int cmdlen; | 590 unsigned int cmdlen; |
581 int is_forced; | |
582 int ret; | 591 int ret; |
583 | 592 |
584 TRACE(("enter sessioncommand")) | 593 TRACE(("enter sessioncommand")) |
585 | 594 |
586 if (chansess->cmd != NULL) { | 595 if (chansess->cmd != NULL) { |
625 } else { | 634 } else { |
626 dropbear_log(LOG_INFO, "user %s executing login shell", | 635 dropbear_log(LOG_INFO, "user %s executing login shell", |
627 ses.authstate.pw_name); | 636 ses.authstate.pw_name); |
628 } | 637 } |
629 #endif | 638 #endif |
639 | |
640 // XXX set SSH_CONNECTION string here, since about to close socket... | |
630 | 641 |
631 if (chansess->term == NULL) { | 642 if (chansess->term == NULL) { |
632 /* no pty */ | 643 /* no pty */ |
633 ret = noptycommand(channel, chansess); | 644 ret = noptycommand(channel, chansess); |
634 } else { | 645 } else { |
735 | 746 |
736 close(chansess->slave); | 747 close(chansess->slave); |
737 | 748 |
738 /* write the utmp/wtmp login record - must be after changing the | 749 /* write the utmp/wtmp login record - must be after changing the |
739 * terminal used for stdout with the dup2 above */ | 750 * terminal used for stdout with the dup2 above */ |
740 li= login_alloc_entry(getpid(), ses.authstate.username, | 751 li = chansess_login_alloc(chansess); |
741 ses.remotehost, chansess->tty); | |
742 login_login(li); | 752 login_login(li); |
743 login_free_entry(li); | 753 login_free_entry(li); |
744 | 754 |
745 #ifdef DO_MOTD | 755 #ifdef DO_MOTD |
746 if (svr_opts.domotd) { | 756 if (svr_opts.domotd) { |
884 | 894 |
885 if (chansess->tty) { | 895 if (chansess->tty) { |
886 addnewvar("SSH_TTY", chansess->tty); | 896 addnewvar("SSH_TTY", chansess->tty); |
887 } | 897 } |
888 | 898 |
899 | |
900 | |
889 #ifdef ENABLE_SVR_PUBKEY_OPTIONS | 901 #ifdef ENABLE_SVR_PUBKEY_OPTIONS |
890 if (ses.authstate.pubkey_options && | 902 if (ses.authstate.pubkey_options && |
891 ses.authstate.pubkey_options->original_command) { | 903 ses.authstate.pubkey_options->original_command) { |
892 addnewvar("SSH_ORIGINAL_COMMAND", | 904 addnewvar("SSH_ORIGINAL_COMMAND", |
893 ses.authstate.pubkey_options->original_command); | 905 ses.authstate.pubkey_options->original_command); |