diff -ur stunnel-3.22/options.c stunnel-3.22-sg1/options.c --- stunnel-3.22/options.c Sun Dec 23 15:08:51 2001 +++ stunnel-3.22-sg1/options.c Wed May 15 03:55:41 2002 @@ -89,6 +89,7 @@ while ((c = getopt(argc, argv, "A:a:cp:v:d:fTl:L:r:s:g:t:u:n:N:hC:D:O:E:R:WB:VP:S:o:I:" "/:" "i" + "F:" )) != EOF) switch (c) { case 'A': @@ -140,6 +145,10 @@ case 'f': options.option|=OPT_FOREGROUND; break; + case 'F': + options.option|=OPT_FDS; + options.use_fd=atoi(optarg); + break; case 'T': options.option|=OPT_TRANSPARENT; break; @@ -257,8 +272,8 @@ print_info(); } #endif - if(!(options.option&(OPT_REMOTE|OPT_PROGRAM))) { - log(LOG_ERR, "Either -r, -l (or -L) option must be used"); + if(!(options.option&(OPT_REMOTE|OPT_PROGRAM|OPT_FDS))) { + log(LOG_ERR, "Either -r, -l (or -L), or -F option must be used"); print_info(); } if((options.option&OPT_REMOTE) && (options.option&OPT_PROGRAM) @@ -345,7 +363,7 @@ #ifndef USE_WIN32 "[-P { dir/ | filename | none } ] " "\n\t[-d [host:]port [-f] ] " - "\n\t[-r [host:]port | { -l | -L } program [-- args] ] " + "\n\t[-r [host:]port | { -l | -L } program [-- args] | -F fd-num ] " #else "\n\t-d [host:]port -r [host:]port" #endif @@ -360,6 +378,7 @@ #ifndef USE_WIN32 "\n -l program\texecute local inetd-type program" "\n -L program\topen local pty and execute program" + "\n -F fd-num\tuse the already-open socket on file descriptor fd-num" #endif "\n" "\n -c\t\tclient mode (remote service uses SSL)" diff -ur stunnel-3.22/prototypes.h stunnel-3.22-sg1/prototypes.h --- stunnel-3.22/prototypes.h Sun Nov 11 14:16:01 2001 +++ stunnel-3.22-sg1/prototypes.h Sun May 12 05:00:52 2002 @@ -79,6 +79,7 @@ #define OPT_REMOTE 0x20 #define OPT_TRANSPARENT 0x40 #define OPT_PTY 0x80 +#define OPT_FDS 0x100 typedef struct { char pem[STRLEN]; /* pem (priv key/cert) filename */ @@ -111,6 +113,7 @@ int cert_defaults; char *output_file; u32 *local_ip; + int use_fd; } server_options; typedef enum { diff -ur stunnel-3.22/client.c stunnel-3.22-sg1/client.c --- stunnel-3.22/client.c Sun Dec 23 14:41:32 2001 +++ stunnel-3.22-sg1/client.c Wed May 15 03:51:34 2002 @@ -220,7 +220,9 @@ else c->ip=0; /* Setup c->remote_fd, now */ - if(options.option&OPT_REMOTE) + if (options.option&OPT_FDS) + fd=options.use_fd; + else if(options.option&OPT_REMOTE) fd=connect_remote(c); else /* NOT in remote mode */ fd=connect_local(c);