#!/bin/bash # version 1.2 # Peter Poeml # This is a public domain software. Use it at your oun risk. # a wrapper for stunnel 4, so it can be used just as stunnel 3 # (with cmdline arguments instead of a config file. A config file is # written on the fly.) # Version 1.1 # Minor edits to 'daemon_{host,port}' substitutions and added # 'break' to the execargs section to be compatible with non # bash Bourne shells. # -- bri@stunnel.org 16-Jun-2003 # Version 1.2 # In an attempt to merge with the stunnel3_concert script for maintenance # reasons, allow to be called as "stunnel3_convert" -- showing the suggested # configuration without actually spawning stunnel. # -- poeml@suse.de, 30-Jul-2003 # # defaults : ${STUNNEL_DEBUG:=false} quiet=false foreground_mode= overwrite_random_seed= pty= function usage() { cat >&2 <<-EOF Usage: ${0##*/} [-V] [-c | -T] [-D level] [-C cipherlist] [-p pemfile] [-v level] [-A certfile] [-a directory] [-t timeout] [-u ident_username] [-s setuid_user] [-g setgid_group] [-n protocol] [-R randfile] [-E egdsock] [-B bytes] [-P filename ] [-d [host:]port [-f] ] [-r [host:]port | { -l | -L } program [-- args] ] -S is not supported. -P only takes filenames. EOF } while getopts d:r:P:s:g:cD:fN:u:n:p:E:R:WB:v:a:A:C:t:Tl:L:V opt; do case $opt in d) daemon_host_port=$OPTARG;; r) rem_host_port=$OPTARG;; P) pid=$OPTARG;; s) setuid_user=$OPTARG;; g) setgid_user=$OPTARG;; c) client_mode=true;; D) debug=$OPTARG;; f) foreground_mode=true;; N) service_name=$OPTARG;; u) ident_username=$OPTARG;; n) protocol=$OPTARG;; E) eg_daemon=$OPTARG;; W) overwrite_random_seed=false;; B) rnd_bytes=$OPTARG;; R) rnd_file=$OPTARG;; p) pem_file=$OPTARG;; v) verify=$OPTARG;; a) ca_path=$OPTARG;; A) ca_file=$OPTARG;; C) cipher_list=$OPTARG;; t) session_timeout=$OPTARG;; T) transparent_mode=true;; l) program=$OPTARG;; L) program=$OPTARG; pty=true;; V) stunnel -version; exit 0;; q) quiet=true;; *) usage; exit 1;; esac done if [ -z "$daemon_host_port" -a -z "$rem_host_port" ]; then echo >&2 Error: Either program or remote service must be specified usage exit 1 fi daemon_port=$daemon_host_port case $daemon_host_port in *:*) daemon_host=${daemon_host_port%:*} daemon_port=${daemon_host_port#*:} ;; esac for i in $*; do case $i in --) shift; exec=$1; shift; execargs=$@; break;; *) shift;; esac done if $STUNNEL_DEBUG; then for i in daemon_host_port rem_host_port pid setuid_user setgid_user client_mode debug exec execargs; do eval 'printf "%-20s = %s \n"' $i \$$i; done fi tmpconf=`mktemp /tmp/stunnel.conf.XXXXXXX` || exit 1 (uniq | grep -v "^[[:space:]]*$") >$tmpconf <" cat $tmpconf echo "<-----------------------" echo executing \'stunnel $tmpconf\' stunnel $tmpconf ;; esac rm -f $tmpconf # vim: ai