This is against the ZMailer CVS repository at 18-Jan-2001 7 PM local time at Helsinki (UTC+2h). The intention has been to *remove* implicite WHITESPACE (IFS) tokenization when associated with unquoted string expansions at command parameters. Index: libsh/builtins.c =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/libsh/builtins.c,v retrieving revision 1.22 diff -u -r1.22 builtins.c --- libsh/builtins.c 2000/03/28 20:47:41 1.22 +++ libsh/builtins.c 2001/01/18 17:28:13 @@ -59,6 +59,7 @@ static conscell *sh_last CSARGS2; static conscell *sh_lappend CSARGS2; static conscell *sh_lreplace CSARGS2; +static conscell *sh_ifssplit CSARGS2; extern conscell *sh_glob CSARGS2; /* expand.c */ #define CSARGV2 __((int argc, const char *argv[])) @@ -95,6 +96,7 @@ { "elements", NULL, sh_elements, NULL, SH_ARGV }, { "get", NULL, sh_get, NULL, SH_ARGV }, { "length", NULL, sh_length, NULL, SH_ARGV }, +{ "ifssplit", NULL, sh_ifssplit, NULL, SH_ARGV }, { "[", sh_test, NULL, NULL, 0 }, { "test", sh_test, NULL, NULL, 0 }, { "echo", sh_echo, NULL, NULL, 0 }, @@ -451,6 +453,7 @@ return d; } +/* This is NUMBER OF ELEMENTS in a chain! */ static conscell * sh_length(avl, il) conscell *avl, *il; @@ -458,7 +461,8 @@ char buf[10]; int len = 0; - if ((il = cdar(avl)) && LIST(il)) { + il = cdar(avl); + if (il && LIST(il)) { for (il = car(il); il != NULL; il = cdr(il)) ++len; } @@ -469,6 +473,58 @@ return avl; } +/* This splits incoming string at WHITESPACEs to a list of strings */ + +static conscell * +sh_ifssplit(avl, il) + conscell *avl, *il; +{ + int len, l; + conscell *tmp, *reply, *t; + const char *p, *p0; + GCVARS1; + + if (ifs == NULL) + ifs_flush(); + + il = cdar(avl); + /* 'il' is supposedly a single string */ + + if (!il || !STRING(il)) return il; + p0 = il->cstring; + len = il->slen; + if (!p0) return il; + + + reply = t = NULL; + GCPRO1(reply); + + for (;len > 0; ++p0, --len) { + + if (WHITESPACE(*p0)) continue; + p = p0; + while (len > 0 && !WHITESPACE(*p)) ++p, --len; + + l = p - p0; /* Will always be at least 1 ! */ + + tmp = newstring(dupnstr(p0, l), l); + tmp->flags |= QUOTEDSTRING|ELEMENT; + + p0 = p; + + if (!t) + reply = t = tmp; + else { + cdr(t) = tmp; + t = tmp; + } + + } + + UNGCPRO1; + return reply; +} + /* returns -- return ALWAYS a string [mea] */ conscell * sh_returns(avl, il, statusp) @@ -749,7 +805,7 @@ } /* if (buf[0] == '\0') return 1; */ if (eoinp) return 1; -eoinput: +/* eoinput: */ while (argc-- > 0) v_set(*argv++, ""); return 0; } Index: libsh/variables.c =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/libsh/variables.c,v retrieving revision 1.6 diff -u -r1.6 variables.c --- libsh/variables.c 1999/05/30 04:05:58 1.6 +++ libsh/variables.c 2001/01/18 15:31:51 @@ -150,6 +150,9 @@ */ +#define ALWAYS_QUOTE_EXPANDS + + conscell * v_expand(s, caller, retcode) const char *s; /* variable name */ @@ -160,6 +163,7 @@ register int n; register char *cp; char np[CHARSETSIZE+1]; /* each possible option, plus last NUL */ + int noquote = 0; GCVARS3; GCPRO3(d,l,tmp); @@ -172,6 +176,7 @@ */ switch (*s) { case '@': + noquote = NOQUOTEIFQUOTED; case '*': if (caller == NULL || cdar(caller->argv) == NULL) { goto end_v_expand; @@ -180,9 +185,13 @@ for (l = d; l != NULL && cdr(l) != NULL ; l = cdr(l)) { tmp = conststring(" ",1); cdr(tmp) = cdr(l); - l = cdr(l) = tmp; - if (*s == '@') - tmp->flags |= NOQUOTEIFQUOTED; + cdr(l) = tmp; + l = cdr(l); + tmp->flags |= noquote; +#ifdef ALWAYS_QUOTE_EXPANDS + if (!noquote) + tmp->flags |= QUOTEDSTRING; +#endif } /* grindef("ARGW = ", ncons(d)); */ goto end_v_expand; @@ -198,6 +207,9 @@ } d = copycell(d); cdr(d) = NULL; +#ifdef ALWAYS_QUOTE_EXPANDS + d->flags |= QUOTEDSTRING; +#endif /* d = s_copy_tree(d); */ /* XXX: Needed ? */ goto end_v_expand; @@ -260,6 +272,10 @@ if ((d = v_find(s)) != NULL) { d = copycell(cdr(d)); cdr(d) = NULL; +#ifdef ALWAYS_QUOTE_EXPANDS + if (STRING(d)) + d->flags |= QUOTEDSTRING; +#endif } end_v_expand: Index: proto/Makefile.in =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/Makefile.in,v retrieving revision 1.41 diff -u -r1.41 Makefile.in --- proto/Makefile.in 2000/10/20 17:07:30 1.41 +++ proto/Makefile.in 2001/01/17 22:50:04 @@ -220,7 +220,8 @@ clean: FRC rm -f ./+* *~ distclean: clean - rm -f Makefile sm.conf zmailer.sh \ - newfqdnaliases newaliases newdb mailrm.sh \ - scheduler.conf post-install.sh smtp-tls.conf + rm -f Makefile sm.conf zmailer.sh + rm -f newfqdnaliases newaliases newdb mailrm.sh + rm -f scheduler.conf post-install.sh smtp-tls.conf + rm -f smtpserver.conf depend: Index: proto/cf/SMTP+UUCP.cf.in =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/SMTP+UUCP.cf.in,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 SMTP+UUCP.cf.in --- proto/cf/SMTP+UUCP.cf.in 1998/02/10 21:01:49 1.1.1.1 +++ proto/cf/SMTP+UUCP.cf.in 2001/01/18 14:35:28 @@ -16,8 +16,9 @@ squirrel badheader # The transport preference order +# This is a LIST of protocols -protocols='routes smtp uucp' +protocols=(routes smtp uucp) # Will the MAILVAR/lists/listname show out sender identity as # either: owner-listname, or: listname-owner ? @@ -39,8 +40,9 @@ # We may want .forward and mailing list files to be private, i.e., we ignore # the current privileges when checking the privileges of such files. # Don't add 'include' to this list, since anyone can :include: any file. +# This is a LIST of keywords -private='.forward maillist' +private=('.forward' 'maillist') # Set up the dependency checking @@ -55,7 +57,7 @@ # Load the databases so they and the variables defined (e.g. network-specific # node names for this host) can be used in the site specific configuration. -for method in $protocols +for method in $(elements $protocols) do test -f $MAILSHARE/cf/i-${method}.cf && . i-${method}.cf done @@ -109,7 +111,7 @@ . rrouter.cf . crossbar.cf -for method in $protocols +for method in $(elements $protocols) do . p-${method}.cf done Index: proto/cf/SMTP.cf.in =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/SMTP.cf.in,v retrieving revision 1.1 diff -u -r1.1 SMTP.cf.in --- proto/cf/SMTP.cf.in 1998/06/01 09:37:16 1.1 +++ proto/cf/SMTP.cf.in 2001/01/18 14:34:32 @@ -16,8 +16,9 @@ squirrel badheader # The transport preference order +# This is a LIST of protocols -protocols='routes smtp' +protocols=('routes' 'smtp') # Will the MAILVAR/lists/listname show out sender identity as # either: owner-listname, or: listname-owner ? @@ -39,8 +40,9 @@ # We may want .forward and mailing list files to be private, i.e., we ignore # the current privileges when checking the privileges of such files. # Don't add 'include' to this list, since anyone can :include: any file. +# This is a LIST of keywords -private='.forward maillist' +private=('.forward' 'maillist') # Set up the dependency checking @@ -55,9 +57,9 @@ # Load the databases so they and the variables defined (e.g. network-specific # node names for this host) can be used in the site specific configuration. -for method in $protocols +for method in ($elements $protocols) do - test -f $MAILSHARE/cf/i-${method}.cf && . i-${method}.cf + test -f "$MAILSHARE/cf/i-${method}.cf" && . i-${method}.cf done mailconf () { Index: proto/cf/TELE-FI.cf.in =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/TELE-FI.cf.in,v retrieving revision 1.2 diff -u -r1.2 TELE-FI.cf.in --- proto/cf/TELE-FI.cf.in 1998/02/15 04:32:08 1.2 +++ proto/cf/TELE-FI.cf.in 2001/01/18 14:36:05 @@ -17,7 +17,7 @@ # The transport preference order -protocols='routes smtp uucp usenet' +protocols=(routes smtp uucp usenet) # Will the MAILVAR/lists/listname show out sender identity as # either: owner-listname, or: listname-owner ? @@ -40,7 +40,7 @@ # the current privileges when checking the privileges of such files. # Don't add 'include' to this list, since anyone can :include: any file. -private='.forward maillist' +private=(.forward maillist) # Set up the dependency checking @@ -55,7 +55,7 @@ # Load the databases so they and the variables defined (e.g. network-specific # node names for this host) can be used in the site specific configuration. -for method in $protocols +for method in $(elements $protocols) do test -f $MAILSHARE/cf/i-${method}.cf && . i-${method}.cf done @@ -109,7 +109,7 @@ . rrouter.cf . crossbar.cf -for method in $protocols +for method in $(elements $protocols) do . p-${method}.cf done Index: proto/cf/UTAI.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/UTAI.cf,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 UTAI.cf --- proto/cf/UTAI.cf 1998/02/10 21:01:49 1.1.1.1 +++ proto/cf/UTAI.cf 2001/01/18 15:26:36 @@ -35,7 +35,7 @@ # The transport preference order -protocols='routes smtp ean uucp usenet' +protocols=(routes smtp ean uucp usenet) #| The list of protocols given here are exactly the list that will be #| supported in the configuration being loaded, and in the specified @@ -48,7 +48,7 @@ # the current privileges when checking the privileges of such files. # Don't add 'include' to this list, since anyone can :include: any file. -#private='.forward maillist' +#private=(.forward maillist) #| This variable is used in the alias expansion (in the routeuser #| function) to determine how to use the privilege level associated with @@ -78,7 +78,7 @@ #| can be used to declare and check dependencies between modules #| (configuration files). -require siteinfo router crossbar process server +require siteinfo rrouter crossbar process server #| The modules we require here are the configuration files whose contents #| are essential to the proper functioning of the router. @@ -102,7 +102,7 @@ # Load the databases so they and the variables defined (e.g. network-specific # node names for this host) can be used in the site specific configuration. -for method in $protocols +for method in $(elements $protocols) do test -f $MAILSHARE/cf/i-${method}.cf && . i-${method}.cf done @@ -176,7 +176,7 @@ #| and rewrite addresses. They use other manipulation functions that are #| specific to the varius message transfer protocols. -for method in $protocols +for method in $(elements $protocols) do . p-${method}.cf done Index: proto/cf/UTGPU.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/UTGPU.cf,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 UTGPU.cf --- proto/cf/UTGPU.cf 1998/02/10 21:01:49 1.1.1.1 +++ proto/cf/UTGPU.cf 2001/01/18 15:26:44 @@ -36,7 +36,7 @@ # Set up the dependency checking . consist.cf -require siteinfo router crossbar process server +require siteinfo rrouter crossbar process server # The following are standard setup files and must be loaded in this order Index: proto/cf/UTdefault.cf.in =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/UTdefault.cf.in,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 UTdefault.cf.in --- proto/cf/UTdefault.cf.in 1998/02/10 21:01:49 1.1.1.1 +++ proto/cf/UTdefault.cf.in 2001/01/18 14:38:00 @@ -33,7 +33,7 @@ # The transport preference order -protocols='routes smtp uucp' +protocols=(routes smtp uucp) #| The list of protocols given here are exactly the list that will be #| supported in the configuration being loaded, and in the specified @@ -47,7 +47,7 @@ # checking the privileges of such files. Don't add 'include' to this list, # since anyone can :include: any file. -#private='.forward maillist' +#private=('.forward' maillist) #| This variable is used in the alias expansion (in the routeuser #| function) to determine how to use the privilege level associated with @@ -95,7 +95,7 @@ # Load the databases so they and the variables defined (e.g. network-specific # node names for this host) can be used in the site specific configuration. -for method in $protocols +for method in $(elements $protocols) do test -f $MAILSHARE/cf/i-${method}.cf && . i-${method}.cf done @@ -169,7 +169,7 @@ #| and rewrite addresses. They use other manipulation functions that are #| specific to the varius message transfer protocols. -for method in $protocols +for method in $(elements $protocols) do . p-${method}.cf done Index: proto/cf/aliases-new.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/aliases-new.cf,v retrieving revision 1.14 diff -u -r1.14 aliases-new.cf --- proto/cf/aliases-new.cf 2000/10/10 21:00:58 1.14 +++ proto/cf/aliases-new.cf 2001/01/18 14:47:20 @@ -21,7 +21,7 @@ # some other value: if [ -z "$localprotocols" ]; then - localprotocols="include aliases mboxmap lists uid_trap punthost local" + localprotocols=(include aliases mboxmap lists uid_trap punthost local) fi # @@ -336,7 +336,7 @@ ;; tfiss - for func in $localprotocols; do + for func in ($elements $localprotocols); do if [ -z "$didexpand" ]; then a=$(localexpand "$func" "$user" "$host" "$attr" "$key") && return $a @@ -780,7 +780,7 @@ getpriv (maxperm, priv, file, type) { #echo "getpriv($maxperm, $priv, $file, $type)" > /dev/tty - for ptype in $private + for ptype in $(elements $private) do if [ $type = $ptype ]; then filepriv -M $maxperm "$file" Index: proto/cf/aliases.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/aliases.cf,v retrieving revision 1.38 diff -u -r1.38 aliases.cf --- proto/cf/aliases.cf 2000/12/30 12:34:40 1.38 +++ proto/cf/aliases.cf 2001/01/18 16:17:23 @@ -215,9 +215,11 @@ local plustail2 forward priv hashomedir type plustail2="" - attr="$(attributes $quad)" - chan="$(channel $quad)" - host="$(host $quad)" + + attr=$(attributes $quad) + chan=$(channel $quad) + host=$(host $quad) + user=$(user $quad) # For the expansions control tag we can use only # the 'channel', and the 'username' strings, we CAN'T @@ -225,13 +227,12 @@ # will have subsequently DIFFERENT values for it. # Use of 'host' field means we can't use - user="$(user $quad)" key="$user" type="$(get $attr type)" sender="$(get $attr sender)" - case "$type" in + case $type in sender) a=$(userdb "$user:mailname") \ || return ((("$chan" "$host" "$user$plustail$domain" $attr))) @@ -245,22 +246,20 @@ al=() - case "$(channel $quad)" in - #smtp) mxh=$(mxhosts $(host $quad).) - # user="$(user $quad)" - # attr="$(attributes $quad)" + case $chan in + #smtp) mxh=$(mxhosts $host.) # case $#mxh in # [1-9]*) # make the XOR list - # for host in $(elements $mxh) + # for hostx in $(elements $mxh) # do # case $#al in # 0) al=$(rrouter "$address" "$address" $attr "" "") ;; # *) set $(cdr $(last $al)) \ - # (((smtp "$host" "$user" $attr))) ;; + # (((smtp $hostx $user $attr))) ;; # esac # done # return $al - # #a=((x) (smtp '$x' "$(user $quad)" $attr)) + # #a=((x) (smtp '$x' $user $attr)) # #mapcar $a $mxhosts # ;; # esac @@ -270,15 +269,15 @@ ;; esac - user="$(condquote "$(user $quad)")" - host="$(condquote "$(host $quad)")" + user=$(condquote $user) + host=$(condquote $host) # echo "routeuser: host=$host, user=$user" >> /dev/tty [ -n "$FORCEPUNT" ] && return $(rrouter "$user@$FORCEPUNT" "$host" $attr "" "") - ssift "$(dequote "$user")" in + ssift $(dequote $user) in \\(.*) user="\1" # Back-quoted username -- most likely #didexpand=local ;; @@ -290,7 +289,7 @@ # sendmail-like :include: expansion db add expansions "$key.:include:" 1 nattr=$(newattribute $attr privilege $priv) - $(zapDSNnotify $nattr expanded "$sender" "$lcuser$domain") + $(zapDSNnotify $nattr expanded "$sender" "$user$domain") defer='' a=$(runas $priv cat "\1" | \ listexpand -E "postmaster" -e root -p $priv \ @@ -325,7 +324,7 @@ if $(didexpand aliases) && a="$(aliases "$user")" ; then db add expansions "$key.aliases" 1 nattr=$(newattribute $attr privilege $priv) - $(zapDSNnotify $nattr expanded "$sender" "$lcuser$domain") + $(zapDSNnotify $nattr expanded "$sender" "$user$domain") a=$(echo "$a" | \ listaddresses -E "root" \ @@ -342,7 +341,7 @@ if $(didexpand fullnamemap) && a="$(fullnamemap "$user")" ; then db add expansions "$key.fullnamemap" 1 nattr=$(newattribute $attr privilege $priv) - $(zapDSNnotify $nattr expanded "$sender" "$lcuser$domain") + $(zapDSNnotify $nattr expanded "$sender" "$user$domain") a=$(rrouter "$a" "$user" $nattr "$plustail" "$domain") postzapDSNnotify a @@ -781,7 +780,7 @@ getpriv (maxperm, priv, file, type) { #echo "getpriv($maxperm, $priv, $file, $type)" > /dev/tty - for ptype in $private + for ptype in $(elements $private) do if [ $type = $ptype ]; then filepriv -M $maxperm "$file" Index: proto/cf/consist.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/consist.cf,v retrieving revision 1.3 diff -u -r1.3 consist.cf --- proto/cf/consist.cf 1998/05/26 14:31:10 1.3 +++ proto/cf/consist.cf 2001/01/18 15:59:06 @@ -11,22 +11,32 @@ require=() provide=() -declare (plist, modules) { - local a - for m in $modules +declare (plist, m) { + lreplace $plist $m $m +} + +require () { + for x in $@ do - lreplace $plist $m $m - #a=$(setf $(get $plist $m) $m) + declare require $x done } -require (modules) { declare require $modules } -provide (module) { declare provide $module } +provide () { + for x in $@ + do + declare provide $x + done +} consist () { local rval +#grind $require +#grind $provide + rval=0 + # Scan for EVERY SECOND token of the array.. while [ $#require -gt 0 ]; do want=$(car $require) Index: proto/cf/fuzzy-aliases.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/fuzzy-aliases.cf,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 fuzzy-aliases.cf --- proto/cf/fuzzy-aliases.cf 1998/02/10 21:01:49 1.1.1.1 +++ proto/cf/fuzzy-aliases.cf 2001/01/18 14:57:46 @@ -198,7 +198,7 @@ # that they couldn't access otherwise. If private='.forward maillist' then # people stop complainig about the former behaviour... getpriv (priv, file, type) { - for ptype in $private + for ptype in $(elements $private) do if [ $type = $ptype ]; then filepriv "$file" Index: proto/cf/process.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/process.cf,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 process.cf --- proto/cf/process.cf 1998/02/10 21:01:49 1.1.1.1 +++ proto/cf/process.cf 2001/01/18 15:28:24 @@ -18,7 +18,7 @@ #| our feet, we flush the cached information every once in a while (in this #| case, before every message). - LOGMSG='' + LOGMSG=() # This is a LIST of files where to log.. #| The LOGMSG variable is used by the intercept facility (in crossbar.cf) #| to make sure only a single copy of a message is saved when required. @@ -59,7 +59,7 @@ #| list in its entirety, except for the file name, and the message id, both #| of which were logged earlier (in C code). - for f in $LOGMSG + for f in $(elements $LOGMSG) do { echo "==${file}==$(rfc822date)==" ; /bin/cat ../queue/"$file" } >> $f && log saved "$file" in $f @@ -69,3 +69,5 @@ } +provide process +# require XX XX XX Index: proto/cf/rrouter.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/rrouter.cf,v retrieving revision 1.18 diff -u -r1.18 rrouter.cf --- proto/cf/rrouter.cf 2001/01/15 14:29:13 1.18 +++ proto/cf/rrouter.cf 2001/01/18 14:28:58 @@ -178,9 +178,9 @@ didhostexpand=$(hostexpansions "\2") - for method in $protocols + for method in $(elements $protocols) do - tmp=$(${method}_neighbour "\2" "$address" $A) && + tmp=$("${method}_neighbour" "\2" "$address" $A) && return $tmp done Index: proto/cf/server.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/server.cf,v retrieving revision 1.7 diff -u -r1.7 server.cf --- proto/cf/server.cf 1999/11/04 21:44:05 1.7 +++ proto/cf/server.cf 2001/01/18 15:36:19 @@ -151,3 +151,6 @@ esac } + +provide server +require rrouter Index: proto/cf/standard.cf =================================================================== RCS file: /home/mea/src/CVSROOT/zmailer/proto/cf/standard.cf,v retrieving revision 1.19 diff -u -r1.19 standard.cf --- proto/cf/standard.cf 2000/10/10 21:00:58 1.19 +++ proto/cf/standard.cf 2001/01/18 14:23:09 @@ -288,7 +288,7 @@ #| Domains with these toplevels will not be canonicalized via DNS lookup #| This list is from ISOC table of 16-April-95 + "su" + bitnet + uucp -toplevels="ad ae af ag ai al am an ao aq ar as at au aw az ba +toplevels=(ad ae af ag ai al am an ao aq ar as at au aw az ba bb bd be bf bg bh bi bj bm bn bo br bs bt bv bw by bz ca cc cf cg ch ci ck cl cm cn co com cr cu cv cx cy cz de dj dk dm do dz ec edu ee eg eh es et fi fj fk fm fo @@ -301,10 +301,10 @@ pw py qa re ro ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr st su sv sy sz tc td tf tg th tj tk tm tn to tp tr tt tv tw tz ua ug uk um us uy uz va vc ve vg - vi vn vu wf ws ye yu za zm zr zw uucp bitnet" + vi vn vu wf ws ye yu za zm zr zw uucp bitnet) relation -lbt incore istoplevel -for x in $toplevels +for x in $(elements $toplevels) do db add istoplevel $x 1 done