[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Patch to `smartlist' for `rel' archive search.



 Anyone want this?  It will add `rel' support to `smartlist-3.10', and
will allow whitspace in egrep regular expressions when doing an
archive search.  I might be a good thing to add to the Debian mailing
list smartlist archive searcher.

 I would like someone to verify that it is not possible to cause it to
execute an arbitrary command via an email sent to it.  I'm pretty sure
it won't, but want to be certain.

 It works.  It might be a better way to find things than just egrep.
I haven't got enough data to search in here, so can't say for sure.


--- .etc/archive.txt.orig	Sat May 17 12:20:20 1997
+++ .etc/archive.txt	Tue Jul 15 04:04:57 1997
@@ -3,12 +3,15 @@
 get filename ...
 ls directory ...
 egrep case_insensitive_regular_expression filename ...
+egrep "case insensitive regular expression with spaces or tabs in it" filename ...
+rel "expression" filename ...
 maxfiles nnn
 version
 
 Aliases for 'get': send, sendme, getme, gimme, retrieve, mail
 Aliases for 'ls': dir, directory, list, show
 Aliases for 'egrep': search, grep, fgrep, find
+Aliases for 'rel': relevant
 
 Lines starting with a '#' are ignored.
 Multiple commands per mail are allowed.
@@ -20,3 +23,5 @@
 ls latest
 get latest/12
 egrep some.word latest/*
+egrep "some[	]word" latest/*
+rel "(permissions & read)" latest/
--- .etc/rc.request.orig	Wed Jul  2 03:55:14 1997
+++ .etc/rc.request	Mon Jul 14 22:27:27 1997
@@ -73,7 +73,7 @@
   * ^^(.+$)*Subject:[	 ]*(([(<]none[>)])?$(.+$)*(^[	 ]*)+)?\
      (archive:?([	 ]|$)|\
      ((send|get)(me)?|gimme|retrieve|mail|ls|dir(ectory)?|list|show|\
-      search|[fe]?grep|find|maxfiles|version)([	 ]+[^	 ]*)?$)
+      rel|relevan|search|[fe]?grep|find|maxfiles|version)([	 ]+[^	 ]*)?$)
   {
     :0 W
     * 1^1 $${restrict_archive:+!}
--- .bin/arch_retrieve.orig	Mon Jun 23 22:27:14 1997
+++ .bin/arch_retrieve	Tue Jul 15 03:50:30 1997
@@ -10,6 +10,8 @@
 sed=sed			# /bin/sed
 cat=cat			# /bin/cat
 egrep=egrep		# /bin/egrep
+rel=rel			# /bin/rel
+perl=perl		# /bin/perl
 nice=nice		# /bin/nice
 date=date		# /bin/date
 touch=touch		# /bin/touch
@@ -213,6 +215,32 @@
 		   ) | $SENDMAIL $sendmailOPT -t
 		  $sleep $waitsleep ;;
 	    esac ;;
+	rel|REL|relevant)
+	    shift
+	    eval $(echo $line | \
+		$perl -n -e 'm/"((?:\\.|[^"\\])*)"(.*)/;\
+		    print("exp=\"",$1,"\";set",$2);')
+	    case "$*" in
+		*[/\ ]..[/\ ]*|..[/\ ]*|*[/\ ]..|..|[-/]*|*\ /*)
+		    $echo "$from ILLEGAL $line" >>$tmpfrom
+		    $test -z "$ILLEGAL" && ILLEGAL="$line";;
+		*) $touch tmp.lock
+		    $echo "$from $line" >>$tmpfrom
+		    ( $formail -rt -I"Subject: archive retrieval: $line" \
+		    -i"From: $listreq" -A"X-Loop: $listaddr" \
+-i"Reply-To: Please.write.a.new.mail.instead.of.replying@FIRST.WORD.archive" \
+		    -I"Precedence: bulk" <$tmprequest
+		    $test ! -z "$wrongaddress" && $echo "$wrongaddress"
+		    cd $archivedir
+		    $echo "$line"
+		    $echo "BEGIN---------------cut here------------------"
+		    $nice $rel "$exp" $* \
+		      2>&1 | $sed -e $breakoff_search'a\
+Truncating after '$breakoff_search' matches...' -e ${breakoff_search}q
+		    $echo "END-----------------cut here------------------"
+		    ) | $SENDMAIL $sendmailOPT -t
+		    $sleep $waitsleep ;;
+	    esac ;;
 	 search|grep|egrep|fgrep|find|\
 	 SEARCH|GREP|EGREP|FGREP|FIND)
 	    iflag="-i"; nflag="-n"; flags=""; ready=no
@@ -227,8 +255,9 @@
 		  *) ready="" ;;
 	       esac
 	    done
-	    regxp="$1"
-	    shift
+	    eval $(echo $line | \
+		$perl -n -e 'm/"((?:\\.|[^"\\])*)"(.*)/;\
+		    print("regxp=\"",$1,"\";set",$2);')
 	    case "$*" in
 	       *[/\ ]..[/\ ]*|..[/\ ]*|*[/\ ]..|..|[-/]*|*\ /*)
 		  $echo "$from ILLEGAL $line" >>$tmpfrom
@@ -243,7 +272,7 @@
 		  cd $archivedir
 		  $echo "$line"
 		  $echo "BEGIN---------------cut here------------------"
-		  $nice $search $nflag $iflag $flags -e $regxp $* \
+		  $nice $search $nflag $iflag $flags -e "$regxp" $* \
 		   </dev/null 2>&1 | $sed -e $breakoff_search'a\
 Truncating after '$breakoff_search' matches...' -e ${breakoff_search}q
 		  $echo "END-----------------cut here------------------"
mailto:karlheg+sig@inetarena.com (Karl M. Hegbloom)
http://www.inetarena.com/~karlheg
Portland, OR  USA
Debian GNU 1.3  Linux 2.1.36 AMD K5 PR-133


Reply to: