File: subscribe

package info (click to toggle)
smartlist 3.15-25
  • links: PTS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 2,192 kB
  • ctags: 1,837
  • sloc: ansic: 9,239; sh: 4,947; makefile: 145
file content (141 lines) | stat: -rwxr-xr-x 3,685 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#! /bin/sh
:
# Copyright (c) 1993-1996, S.R. van den Berg, The Netherlands
#$Id: subscribe,v 1.36 1996/12/21 03:28:11 srb Exp $

test=test		# /bin/test
echo=echo		# /bin/echo
cat=cat			# /bin/cat
sed=sed			# /bin/sed
grep=grep		# /bin/grep
date=date		# /bin/date
formail=formail		# /usr/local/bin/formail
multigram=multigram	# ../.bin/multigram
arch_retrieve=arch_retrieve	# ../.bin/arch_retrieve

$test -z "$listaddr" &&
 $echo "Don't start this script directly, it is used in rc.request" && exit 64

tmprequest=tmp.request
tmpfrom=tmp.from
subscribetxt=subscribe.txt
subscribefiles=subscribe.files

if $test ! -r dist
then
  $echo "subscribe: Where did the dist file go?" 1>&2
  $echo "(Only addresses below this line can be automatically removed)" >>dist
fi

case "$X_ENVELOPE_TO" in
  *$list-request*) wrongaddress="" ;;
  *) wrongaddress="WARNING:
	Please try to use '$listreq'
	the next time when issuing (un)subscribe requests.
" ;;
esac

subscraddr=""

address=`$formail -k -xSubject: |
 $sed -n -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
  -e '/^[	 ]*[^	 a-z]/ q' \
  -e 's/^[^@]*add[	 ]*'\
'[^	 ]*[	 ]\([^	 ]*[-a-z0-9_][@!][a-z0-9][^	 ]*\).*/\1/p' \
  -e 's/^[^@]*address[	 ]*'\
'[^	 ]*[	 ]\([^	 ]*[-a-z0-9_][@!][a-z0-9][^	 ]*\).*/\1/p' \
  -e 's/^[^@]*sub[	 ]*'\
'[^	 ]*[	 ]\([^	 ]*[-a-z0-9_][@!][a-z0-9][^	 ]*\).*/\1/p' \
  -e 's/^[^@]*subscribe[	 ]*'\
'[^	 ]*[	 ]\([^	 ]*[-a-z0-9_][@!][a-z0-9][^	 ]*\).*/\1/p' `

fromaddr=`$cat $tmpfrom`

for a in $address ""
do
  if $test -z "$subscraddr"
  then
     case $a in
	$listreq|$listaddr) ;;
	?*) subscraddr=$a
	   $echo " $subscraddr" >$tmpfrom ;;
     esac
  fi
done

subscraddr=""	# let multigram eliminate trailing and leading punctuation

address=`$formail -k -xSubject: <$tmprequest |
 $multigram -b1 -x$listreq -x$listaddr -l$off_threshold $tmpfrom |
 $sed -e 's/^  *[^ ][^ ]*  *[^ ][^ ]*  *[^ ][^ ]*  *\([^ ][^ ]*\)/\1/' `

for a in $address ""
do
  $test -z "$subscraddr" && subscraddr=$a
done

$test -z "$subscraddr" && subscraddr=$fromaddr

if $test -f subscreen
then
  ./subscreen "$subscraddr" || exit 1
fi

$grep '^Subject: Re:' <$tmprequest >/dev/null &&
  wrongaddress="${wrongaddress}WARNING:
	Send in a new mail, INSTEAD OF REPLYING
	the next time when issuing (un)subscribe requests.
"

NOT_METOO=""

#$formail -k -xSubject: <$tmprequest |
# $grep 'no.*[^a-z]cop.*[^a-z]please' >/dev/null && NOT_METOO=" (-n)"

$multigram -a "$subscraddr$NOT_METOO" dist >/dev/null

sender=`$formail -rtzcxTo: <$tmprequest`

$test -z "$subscribe_log" ||
 $echo "subscribe: $subscraddr by: $sender  `$date`" >>$subscribe_log

case $subscraddr in
   *$sender*) sender="$subscraddr" ;;
   *) sender="$sender $subscraddr" ;;
esac

( $formail -i"From: SmartList <$listreq>" -rtA"X-Loop: $listaddr" <$tmprequest

  $test ! -z "$wrongaddress" && $echo "$wrongaddress" && wrongaddress=""

  $echo "You have added to the subscriber list of:"
  $echo ""
  $echo "	$listaddr"
  $echo ""
  $echo "the following mail address:"
  $echo ""
  $echo "	$subscraddr"
  $echo ""
# if $test -z "$NOT_METOO"
# then
     $echo "By default, copies of your own submissions will be returned."
# else
#    $echo "As requested, copies of your own submissions will not be returned."
# fi
  $echo ""

  $cat $subscribetxt

  $sed -e 's/^/>/' $tmprequest
) | $SENDMAIL $sendmailOPT $sender

if $test -f $subscribefiles
then
  $formail -X "" -i "Reply-To: $subscraddr" -i "Subject: archive" \
   <$tmprequest >$tmpfrom
  $cat $tmpfrom >$tmprequest
  $echo "" >>$tmprequest
  $cat $subscribefiles >>$tmprequest		# setup fake archive commands
  $echo $subscraddr >$tmpfrom
  exec $arch_retrieve <$tmprequest		# the point of no return
fi