Index: Makefile.in =================================================================== RCS file: /home/tshiozak/project/sfw/cvs/openssh/Makefile.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -u -r1.1.1.1 -r1.2 --- Makefile.in 2002/09/18 17:10:33 1.1.1.1 +++ Makefile.in 2002/09/18 17:50:22 1.2 @@ -40,7 +40,7 @@ CC=@CC@ LD=@LD@ CFLAGS=@CFLAGS@ -CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@ +CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@ -DSFW LIBS=@LIBS@ LIBPAM=@LIBPAM@ LIBWRAP=@LIBWRAP@ @@ -58,7 +58,7 @@ @NO_SFTP@SFTP_PROGS=sftp-server$(EXEEXT) sftp$(EXEEXT) -TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keyscan${EXEEXT} ssh-keysign${EXEEXT} ssh-agent$(EXEEXT) scp$(EXEEXT) ssh-rand-helper${EXEEXT} $(SFTP_PROGS) +TARGETS=ssh$(EXEEXT) sfw$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keyscan${EXEEXT} ssh-keysign${EXEEXT} ssh-agent$(EXEEXT) scp$(EXEEXT) ssh-rand-helper${EXEEXT} $(SFTP_PROGS) LIBSSH_OBJS=atomicio.o authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o dh.o dispatch.o fatal.o mac.o msg.o hostfile.o key.o kex.o kexdh.o kexgex.o log.o match.o misc.o mpaux.o nchan.o packet.o radix.o rijndael.o entropy.o readpass.o rsa.o scard.o scard-opensc.o ssh-dss.o ssh-rsa.o tildexpand.o ttymodes.o uidswap.o uuencode.o xmalloc.o monitor_wrap.o monitor_fdpass.o @@ -111,6 +111,9 @@ $(RANLIB) $@ ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS) + $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) + +sfw$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS) $(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) sshd$(EXEEXT): libssh.a $(LIBCOMPAT) $(SSHDOBJS) Index: ssh.c =================================================================== RCS file: /home/tshiozak/project/sfw/cvs/openssh/ssh.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -u -r1.1.1.1 -r1.2 --- ssh.c 2002/09/18 17:10:33 1.1.1.1 +++ ssh.c 2002/09/18 17:50:22 1.2 @@ -146,6 +146,12 @@ /* # of replies received for global requests */ static int client_global_request_id = 0; +/* ssh forwarder */ +#ifdef SFW +#define SFW_CMD "sfw" +int issfw = 0; +#endif + /* Prints a help message to the user. This function never returns. */ static void @@ -489,6 +495,18 @@ } } +#ifdef SFW + i = strlen(__progname) - (sizeof(SFW_CMD)-1); + if (i>=0 && !strcmp(__progname+i, SFW_CMD)) { + issfw = 1; + no_shell_flag = 1; + no_tty_flag = 1; + options.protocol = SSH_PROTO_2; + stdin_null_flag = 1; + debug("sfwm mode on."); + } +#endif + ac -= optind; av += optind; @@ -1122,6 +1140,35 @@ return c->self; } +#ifdef SFW +void +ssh_enter_sfw_mode(void) +{ + pid_t sshpid, pid; + int len; + char *buf; + + sshpid = getpid(); + pid = fork(); + if (pid==0) { + /* child */ + len = buffer_len(&command); + buf = xmalloc(len+1); + if (buf==NULL) + _exit(0); + memcpy(buf, buffer_ptr(&command), len); + buf[len] = 0; + sleep(1); + system(buf); + sleep(1); + kill(sshpid, SIGTERM); + _exit(0); + } else if (pid<0) { + fatal("cannot fork."); + } +} +#endif + static int ssh_session2(void) { @@ -1130,6 +1177,11 @@ /* XXX should be pre-session */ ssh_init_forwarding(); +#ifdef SFW + if (issfw) { + ssh_enter_sfw_mode(); + } +#endif if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN)) id = ssh_session2_open();