Mercurial > dropbear
comparison svr-chansession.c @ 1295:750ec4ec4cbe
Convert #ifdef to #if, other build changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 04 May 2016 15:33:40 +0200 |
parents | a23386821e9f |
children | 79225928bf59 |
comparison
equal
deleted
inserted
replaced
1294:56aba7dedbea | 1295:750ec4ec4cbe |
---|---|
252 | 252 |
253 chansess->exit.exitpid = -1; | 253 chansess->exit.exitpid = -1; |
254 | 254 |
255 channel->typedata = chansess; | 255 channel->typedata = chansess; |
256 | 256 |
257 #ifndef DISABLE_X11FWD | 257 #if DROPBEAR_X11FWD |
258 chansess->x11listener = NULL; | 258 chansess->x11listener = NULL; |
259 chansess->x11authprot = NULL; | 259 chansess->x11authprot = NULL; |
260 chansess->x11authcookie = NULL; | 260 chansess->x11authcookie = NULL; |
261 #endif | 261 #endif |
262 | 262 |
263 #ifdef ENABLE_SVR_AGENTFWD | 263 #if DROPBEAR_SVR_AGENTFWD |
264 chansess->agentlistener = NULL; | 264 chansess->agentlistener = NULL; |
265 chansess->agentfile = NULL; | 265 chansess->agentfile = NULL; |
266 chansess->agentdir = NULL; | 266 chansess->agentdir = NULL; |
267 #endif | 267 #endif |
268 | 268 |
299 send_exitsignalstatus(channel); | 299 send_exitsignalstatus(channel); |
300 | 300 |
301 m_free(chansess->cmd); | 301 m_free(chansess->cmd); |
302 m_free(chansess->term); | 302 m_free(chansess->term); |
303 | 303 |
304 #ifdef ENABLE_SVR_PUBKEY_OPTIONS | 304 #if DROPBEAR_SVR_PUBKEY_OPTIONS_BUILT |
305 m_free(chansess->original_command); | 305 m_free(chansess->original_command); |
306 #endif | 306 #endif |
307 | 307 |
308 if (chansess->tty) { | 308 if (chansess->tty) { |
309 /* write the utmp/wtmp login record */ | 309 /* write the utmp/wtmp login record */ |
313 | 313 |
314 pty_release(chansess->tty); | 314 pty_release(chansess->tty); |
315 m_free(chansess->tty); | 315 m_free(chansess->tty); |
316 } | 316 } |
317 | 317 |
318 #ifndef DISABLE_X11FWD | 318 #if DROPBEAR_X11FWD |
319 x11cleanup(chansess); | 319 x11cleanup(chansess); |
320 #endif | 320 #endif |
321 | 321 |
322 #ifdef ENABLE_SVR_AGENTFWD | 322 #if DROPBEAR_SVR_AGENTFWD |
323 svr_agentcleanup(chansess); | 323 svr_agentcleanup(chansess); |
324 #endif | 324 #endif |
325 | 325 |
326 /* clear child pid entries */ | 326 /* clear child pid entries */ |
327 for (i = 0; i < svr_ses.childpidsize; i++) { | 327 for (i = 0; i < svr_ses.childpidsize; i++) { |
371 ret = sessionpty(chansess); | 371 ret = sessionpty(chansess); |
372 } else if (strcmp(type, "exec") == 0) { | 372 } else if (strcmp(type, "exec") == 0) { |
373 ret = sessioncommand(channel, chansess, 1, 0); | 373 ret = sessioncommand(channel, chansess, 1, 0); |
374 } else if (strcmp(type, "subsystem") == 0) { | 374 } else if (strcmp(type, "subsystem") == 0) { |
375 ret = sessioncommand(channel, chansess, 1, 1); | 375 ret = sessioncommand(channel, chansess, 1, 1); |
376 #ifndef DISABLE_X11FWD | 376 #if DROPBEAR_X11FWD |
377 } else if (strcmp(type, "x11-req") == 0) { | 377 } else if (strcmp(type, "x11-req") == 0) { |
378 ret = x11req(chansess); | 378 ret = x11req(chansess); |
379 #endif | 379 #endif |
380 #ifdef ENABLE_SVR_AGENTFWD | 380 #if DROPBEAR_SVR_AGENTFWD |
381 } else if (strcmp(type, "[email protected]") == 0) { | 381 } else if (strcmp(type, "[email protected]") == 0) { |
382 ret = svr_agentreq(chansess); | 382 ret = svr_agentreq(chansess); |
383 #endif | 383 #endif |
384 } else if (strcmp(type, "signal") == 0) { | 384 } else if (strcmp(type, "signal") == 0) { |
385 ret = sessionsignal(chansess); | 385 ret = sessionsignal(chansess); |
601 | 601 |
602 TRACE(("leave sessionpty")) | 602 TRACE(("leave sessionpty")) |
603 return DROPBEAR_SUCCESS; | 603 return DROPBEAR_SUCCESS; |
604 } | 604 } |
605 | 605 |
606 #ifndef USE_VFORK | 606 #if !DROPBEAR_VFORK |
607 static void make_connection_string(struct ChanSess *chansess) { | 607 static void make_connection_string(struct ChanSess *chansess) { |
608 char *local_ip, *local_port, *remote_ip, *remote_port; | 608 char *local_ip, *local_port, *remote_ip, *remote_port; |
609 size_t len; | 609 size_t len; |
610 get_socket_address(ses.sock_in, &local_ip, &local_port, &remote_ip, &remote_port, 0); | 610 get_socket_address(ses.sock_in, &local_ip, &local_port, &remote_ip, &remote_port, 0); |
611 | 611 |
692 } | 692 } |
693 #endif | 693 #endif |
694 | 694 |
695 /* uClinux will vfork(), so there'll be a race as | 695 /* uClinux will vfork(), so there'll be a race as |
696 connection_string is freed below. */ | 696 connection_string is freed below. */ |
697 #ifndef USE_VFORK | 697 #if !DROPBEAR_VFORK |
698 make_connection_string(chansess); | 698 make_connection_string(chansess); |
699 #endif | 699 #endif |
700 | 700 |
701 if (chansess->term == NULL) { | 701 if (chansess->term == NULL) { |
702 /* no pty */ | 702 /* no pty */ |
708 } else { | 708 } else { |
709 /* want pty */ | 709 /* want pty */ |
710 ret = ptycommand(channel, chansess); | 710 ret = ptycommand(channel, chansess); |
711 } | 711 } |
712 | 712 |
713 #ifndef USE_VFORK | 713 #if !DROPBEAR_VFORK |
714 m_free(chansess->connection_string); | 714 m_free(chansess->connection_string); |
715 m_free(chansess->client_string); | 715 m_free(chansess->client_string); |
716 #endif | 716 #endif |
717 | 717 |
718 if (ret == DROPBEAR_FAILURE) { | 718 if (ret == DROPBEAR_FAILURE) { |
782 if (chansess->master == -1 || chansess->tty == NULL) { | 782 if (chansess->master == -1 || chansess->tty == NULL) { |
783 dropbear_log(LOG_WARNING, "No pty was allocated, couldn't execute"); | 783 dropbear_log(LOG_WARNING, "No pty was allocated, couldn't execute"); |
784 return DROPBEAR_FAILURE; | 784 return DROPBEAR_FAILURE; |
785 } | 785 } |
786 | 786 |
787 #ifdef USE_VFORK | 787 #if DROPBEAR_VFORK |
788 pid = vfork(); | 788 pid = vfork(); |
789 #else | 789 #else |
790 pid = fork(); | 790 pid = fork(); |
791 #endif | 791 #endif |
792 if (pid < 0) | 792 if (pid < 0) |
902 struct ChanSess *chansess = user_data; | 902 struct ChanSess *chansess = user_data; |
903 char *usershell = NULL; | 903 char *usershell = NULL; |
904 | 904 |
905 /* with uClinux we'll have vfork()ed, so don't want to overwrite the | 905 /* with uClinux we'll have vfork()ed, so don't want to overwrite the |
906 * hostkey. can't think of a workaround to clear it */ | 906 * hostkey. can't think of a workaround to clear it */ |
907 #ifndef USE_VFORK | 907 #if !DROPBEAR_VFORK |
908 /* wipe the hostkey */ | 908 /* wipe the hostkey */ |
909 sign_key_free(svr_opts.hostkey); | 909 sign_key_free(svr_opts.hostkey); |
910 svr_opts.hostkey = NULL; | 910 svr_opts.hostkey = NULL; |
911 | 911 |
912 /* overwrite the prng state */ | 912 /* overwrite the prng state */ |
971 | 971 |
972 if (chansess->client_string) { | 972 if (chansess->client_string) { |
973 addnewvar("SSH_CLIENT", chansess->client_string); | 973 addnewvar("SSH_CLIENT", chansess->client_string); |
974 } | 974 } |
975 | 975 |
976 #ifdef ENABLE_SVR_PUBKEY_OPTIONS | 976 #if DROPBEAR_SVR_PUBKEY_OPTIONS_BUILT |
977 if (chansess->original_command) { | 977 if (chansess->original_command) { |
978 addnewvar("SSH_ORIGINAL_COMMAND", chansess->original_command); | 978 addnewvar("SSH_ORIGINAL_COMMAND", chansess->original_command); |
979 } | 979 } |
980 #endif | 980 #endif |
981 | 981 |
982 /* change directory */ | 982 /* change directory */ |
983 if (chdir(ses.authstate.pw_dir) < 0) { | 983 if (chdir(ses.authstate.pw_dir) < 0) { |
984 dropbear_exit("Error changing directory"); | 984 dropbear_exit("Error changing directory"); |
985 } | 985 } |
986 | 986 |
987 #ifndef DISABLE_X11FWD | 987 #if DROPBEAR_X11FWD |
988 /* set up X11 forwarding if enabled */ | 988 /* set up X11 forwarding if enabled */ |
989 x11setauth(chansess); | 989 x11setauth(chansess); |
990 #endif | 990 #endif |
991 #ifdef ENABLE_SVR_AGENTFWD | 991 #if DROPBEAR_SVR_AGENTFWD |
992 /* set up agent env variable */ | 992 /* set up agent env variable */ |
993 svr_agentset(chansess); | 993 svr_agentset(chansess); |
994 #endif | 994 #endif |
995 | 995 |
996 usershell = m_strdup(get_user_shell()); | 996 usershell = m_strdup(get_user_shell()); |