Mercurial > dropbear
comparison svr-chansession.c @ 273:02a80ce2ead4
Merge of the uClinux-dist patch, should work in inetd mode
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 28 Feb 2006 04:03:49 +0000 |
parents | 541b14504870 |
children | 8438ff0cdb74 |
comparison
equal
deleted
inserted
replaced
266:e37b160c414c | 273:02a80ce2ead4 |
---|---|
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 seedrandom(); |
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) { |