File: confirm

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 (219 lines) | stat: -rw-r--r-- 6,151 bytes parent folder | download | duplicates (6)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/sh

# $Id: confirm,v 1.3 1999/03/11 13:00:33 szhrew Exp szhrew $
# $Log: confirm,v $
# Revision 1.3  1999/03/11 13:00:33  szhrew
# Obsolete comment deleted
#
# Revision 1.2  1999/03/11 12:23:09 
# Changing the command for creating a cookie due to problems with
# the date command on other OS's.
#

##  Author:
##      Werner Reisberger     <werner@free.de> 
##  Description:
##    confirm allows (un)subscriptions to mailing lists running with  
##    SmartList  depending on a confirmation. If automatic subscription is 
##    not allowed the confirmation can be done by the list maintainer(s).
##---------------------------------------------------------------------------##
##    
##    Copyright (C) 1998   Werner Reisberger  <werner@free.de>
##    Copyright (C) 1997   Michelle Dick <artemis@rahul.net> and
##                         Werner Reisberger  <werner@free.de>
##
##    This program is free software; you can redistribute it and/or modify
##    it under the terms of the GNU General Public License as published by
##    the Free Software Foundation; either version 2 of the License, or
##    (at your option) any later version.
##
##    This program is distributed in the hope that it will be useful,
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with this program; if not, write to the Free Software
##    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##---------------------------------------------------------------------------##

test=test		# /bin/test
echo=echo		# /bin/echo
cat=cat			# /bin/cat
sed=sed			# /bin/sed
grep=grep		# /bin/grep
date=date		# /bin/date
ls=ls                   # /bin/ls
rm=rm                   # /bin/rm
mkdir=mkdir             # /bin/mkdir
formail=formail		# /usr/local/bin/formail
multigram=multigram 	# ../.bin/multigram

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

tmprequest=tmp.request
tmpfrom=tmp.from
confirmtxt=confirm.txt
US=$1

$test -d cookies || $mkdir cookies

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=""

if [ "$US" = "unsub" ]
then

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


# create an cookie...this is u for unsubscribe, the date plus the pid
COOKIE="u`$date +%m%d%H%M%S`$$"

else

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

fi

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  [ "$US" != "unsub" ]
then

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

# create a fairly unique cookie...this is the date plus the pid
COOKIE="s`$date +%m%d%H%M%S`$$"

# log the attempt
$echo "$0: subscription request from $fromaddr for"
$echo "`cat $tmpfrom` - assigned cookie $COOKIE" >> log

else

$echo "$0: unsubscription request from $fromaddr for"
$echo "`cat $tmpfrom` - assigned cookie $COOKIE" >> log

fi

# create cookie file in cookies directory containing the address
# to be subscribed
$echo $subscraddr > cookies/$COOKIE

$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.
"
  
  if [ "$US" = "sv" ]; then

  authaddr=`$echo $maintainer|sed 's/,/ /g'`
  
  else

  authaddr=$subscraddr

  fi


( $formail -i"From: SmartList <$listreq>" -rtA"X-Loop: $listaddr" \
           -I"Subject: CONFIRM $COOKIE" <$tmprequest 

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

  $echo "It has been requested that the following address:"
  $echo ""
  $echo "       $subscraddr"
  $echo ""

  if [ "$US" = "unsub" ]; then
  
  $echo "should be deleted from the $list mailing list."
  $echo ""
  $echo "It has NOT yet been unsubscribed from the list."
  $echo "To unsubscribe you need to confirm the unsubscription"

  else

  $echo "should be added to the $list mailing list."
  $echo ""
  $echo "The address has NOT yet been subscribed to the mailing list."
  $echo "To subscribe you need to confirm the subscription"

  fi

  $echo "request by sending an email to the address:"
  $echo ""
  $echo "        $listreq"
  $echo ""
  $echo "with the Subject string:"
  $echo ""
  $echo "         CONFIRM $COOKIE"
  $echo ""
  $echo "With a reasonable good email program a reply to this" 
  $echo "message should be sufficient"
  $echo ""

  $cat $confirmtxt
  $echo ""

  $rm -f _dummy_ `$ls -td cookies/* | $sed -e '1,'$maxcookies' d' `

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