OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall Root: /v/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-src Date: 13-Apr-2005 18:20:20 Branch: HEAD Handle: 2005041317201900 Added files: openpkg-src/ircii ircii.pl Modified files: openpkg-src/ircii ircii.spec Log: add a run-time wrapper which allows ircII to speak IRC-over-SSL via stunnel(1) Summary: Revision Changes Path 1.1 +115 -0 openpkg-src/ircii/ircii.pl 1.47 +13 -8 openpkg-src/ircii/ircii.spec ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/ircii/ircii.pl ============================================================================ $ cvs diff -u -r0 -r1.1 ircii.pl --- /dev/null 2005-04-13 18:15:06 +0200 +++ ircii.pl 2005-04-13 18:20:20 +0200 @@ -0,0 +1,115 @@ [EMAIL PROTECTED]@/bin/perl +## +## ircii.pl -- ircII command line wrapper (for optional SSL support) +## + +require 5.008; +use strict; +use warnings; +use IO::File; +use Getopt::Long; +use File::Temp qw(tempfile tempdir); + +# external programs +my $irc = '@l_prefix@/libexec/ircii/irc'; +my $stunnel = '@l_prefix@/sbin/stunnel'; + +# define command line options +my $opt = {}; +my %options = ( + # standard ircII options + 'c=s' => \$opt->{-c}, + 'p=s' => \$opt->{-p}, + 'P=s' => \$opt->{-P}, + 'f' => \$opt->{-f}, + 'F' => \$opt->{-F}, + 'r' => \$opt->{-r}, + 's' => \$opt->{-s}, + 'S' => \$opt->{-S}, + 'h=s' => \$opt->{-h}, + 'H=s' => \$opt->{-H}, + 'd' => \$opt->{-d}, + 'q' => \$opt->{-q}, + 'a' => \$opt->{-a}, + 'b' => \$opt->{-b}, + 'l=s' => \$opt->{-l}, + 'I=s' => \$opt->{-I}, + 't' => \$opt->{-t}, + 'T' => \$opt->{-T}, + 'i=s' => \$opt->{-i}, + 'help' => \$opt->{-help}, + # add-on wrapper options + 'ssl' => \$opt->{-ssl}, +); + +# parse command line options +{ + local @ARGV = @ARGV; + my $p = new Getopt::Long::Parser; + $p->configure("bundling"); + $p->getoptions(%options) || die "option parsing failed"; +} + +# remove add-on option +if (defined($opt->{-ssl})) { + for (my $i = 0; $i < @ARGV; $i++) { + if ($ARGV[$i] eq '--ssl') { + splice(@ARGV, $i, 1); + last; + } + } +} + +if (defined($opt->{-ssl})) { + # encrypted IRC-over-SSL connection + if (not -x $stunnel) { + print STDERR "irc:ERROR: stunnel(1) required -- please install \"stunnel\" package.\n"; + exit(1); + } + + # determine parameters + srand(time() ^ $$); + my $lhost = $opt->{-h}; + my $lport = 60000 + int(rand() * 1000); + my $rhost = ((defined($ARGV[-1]) and $ARGV[-1] !~ m|^-|) ? $ARGV[-1] : "irc"); + my $rport = ($opt->{-p} || 6667); + + # start an SSL tunnel + my $tmpdir = tempdir("/tmp/ircII-XXXXXX", CLEANUP => 1); + my $pidfile = "$tmpdir/stunnel.pid"; + my $logfile = "$tmpdir/stunnel.log"; + my $cfgfile = "$tmpdir/stunnel.cfg"; + my $io = new IO::File ">$cfgfile" || die; + $io->print( + "client = yes\n" . + "pid = $pidfile\n" . + "output = $logfile\n" . + "[ircs]\n" . + (defined($lhost) ? + "local = $lhost\n" : "") . + "accept = localhost:$lport\n" . + "connect = $rhost:$rport\n" + ); + $io->close(); + system $stunnel, $cfgfile; + sleep(1); + + # manipulate ircII command line arguments + unshift(@ARGV, "-p", $lport); + $ARGV[-1] = "localhost"; + + # start ircII through SSL tunnel + my $rc = system $irc, @ARGV; + + # shutdown SSL tunnel + system("kill `cat $pidfile 2>/dev/null`"); + undef $tmpdir; + + # exit with ircII return code + exit($rc); +} +else { + # unencrypted IRC connection + exec $irc, @ARGV; +} + @@ . patch -p0 <<'@@ .' Index: openpkg-src/ircii/ircii.spec ============================================================================ $ cvs diff -u -r1.46 -r1.47 ircii.spec --- openpkg-src/ircii/ircii.spec 24 Mar 2005 11:19:07 -0000 1.46 +++ openpkg-src/ircii/ircii.spec 13 Apr 2005 16:20:19 -0000 1.47 @@ -33,16 +33,17 @@ Group: Network License: BSD Version: 20040820 -Release: 20040820 +Release: 20050413 # list of sources Source0: ftp://ircii.warped.com/pub/ircII/ircii-%{version}.tar.gz +Source1: ircii.pl # build information Prefix: %{l_prefix} BuildRoot: %{l_buildroot} BuildPreReq: OpenPKG, openpkg >= 20040130, gcc -PreReq: OpenPKG, openpkg >= 20040130 +PreReq: OpenPKG, openpkg >= 20040130, perl AutoReq: no AutoReqProv: no @@ -75,12 +76,16 @@ %install rm -rf $RPM_BUILD_ROOT %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT - rm $RPM_BUILD_ROOT%{l_prefix}/bin/irc - mv $RPM_BUILD_ROOT%{l_prefix}/bin/irc-%{version} \ - $RPM_BUILD_ROOT%{l_prefix}/bin/irc - mv $RPM_BUILD_ROOT%{l_prefix}/man/man1/ircII.1 \ - $RPM_BUILD_ROOT%{l_prefix}/man/man1/irc.1 - strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true + rm $RPM_BUILD_ROOT%{l_prefix}/bin/irc + %{l_shtool} mkdir -f -p -m 755 \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/ircii + mv $RPM_BUILD_ROOT%{l_prefix}/bin/irc-%{version} \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/ircii/irc + strip $RPM_BUILD_ROOT%{l_prefix}/libexec/ircii/irc + mv $RPM_BUILD_ROOT%{l_prefix}/man/man1/ircII.1 \ + $RPM_BUILD_ROOT%{l_prefix}/man/man1/irc.1 + %{l_shtool} install -c -m 755 %{l_value -s -a} \ + %{SOURCE ircii.pl} $RPM_BUILD_ROOT%{l_prefix}/bin/irc rm -f "$RPM_BUILD_ROOT%{l_prefix}/share/irc/help/!" rm -f "$RPM_BUILD_ROOT%{l_prefix}/share/irc/help/:" %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org