comparison svr-chansession.c @ 278:e109fb08b8ee

merge of 4cbdd6e0a0d8c061075b9ed7609a06c4547f67d3 and 5d396842815593611f0d61762440145d1fc74d5a
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 12:53:09 +0000
parents 8438ff0cdb74
children 1f5ec029dfe8
comparison
equal deleted inserted replaced
276:3cea9d789cca 278:e109fb08b8ee
621 if (pipe(outfds) != 0) 621 if (pipe(outfds) != 0)
622 return DROPBEAR_FAILURE; 622 return DROPBEAR_FAILURE;
623 if (pipe(errfds) != 0) 623 if (pipe(errfds) != 0)
624 return DROPBEAR_FAILURE; 624 return DROPBEAR_FAILURE;
625 625
626 #ifdef __uClinux__
627 pid = vfork();
628 #else
626 pid = fork(); 629 pid = fork();
630 #endif
631
627 if (pid < 0) 632 if (pid < 0)
628 return DROPBEAR_FAILURE; 633 return DROPBEAR_FAILURE;
629 634
630 if (!pid) { 635 if (!pid) {
631 /* child */ 636 /* child */
712 if (chansess->master == -1 || chansess->tty == NULL) { 717 if (chansess->master == -1 || chansess->tty == NULL) {
713 dropbear_log(LOG_WARNING, "no pty was allocated, couldn't execute"); 718 dropbear_log(LOG_WARNING, "no pty was allocated, couldn't execute");
714 return DROPBEAR_FAILURE; 719 return DROPBEAR_FAILURE;
715 } 720 }
716 721
722 #ifdef __uClinux__
723 pid = vfork();
724 #else
717 pid = fork(); 725 pid = fork();
726 #endif
718 if (pid < 0) 727 if (pid < 0)
719 return DROPBEAR_FAILURE; 728 return DROPBEAR_FAILURE;
720 729
721 if (pid == 0) { 730 if (pid == 0) {
722 /* child */ 731 /* child */
826 char *argv[4]; 835 char *argv[4];
827 char * usershell = NULL; 836 char * usershell = NULL;
828 char * baseshell = NULL; 837 char * baseshell = NULL;
829 unsigned int i; 838 unsigned int i;
830 839
840 /* with uClinux we'll have vfork()ed, so don't want to overwrite the
841 * hostkey. can't think of a workaround to clear it */
842 #ifndef __uClinux__
831 /* wipe the hostkey */ 843 /* wipe the hostkey */
832 sign_key_free(svr_opts.hostkey); 844 sign_key_free(svr_opts.hostkey);
833 svr_opts.hostkey = NULL; 845 svr_opts.hostkey = NULL;
834 846
835 /* overwrite the prng state */ 847 /* overwrite the prng state */
836 seedrandom(); 848 reseedrandom();
849 #endif
837 850
838 /* close file descriptors except stdin/stdout/stderr 851 /* close file descriptors except stdin/stdout/stderr
839 * Need to be sure FDs are closed here to avoid reading files as root */ 852 * Need to be sure FDs are closed here to avoid reading files as root */
840 for (i = 3; i <= (unsigned int)ses.maxfd; i++) { 853 for (i = 3; i <= (unsigned int)ses.maxfd; i++) {
841 if (m_close(i) == DROPBEAR_FAILURE) { 854 if (m_close(i) == DROPBEAR_FAILURE) {