1 # ===================================================================== 2 # confirmSubscription.awk: RPC I/O function for rpclib/confirmSubscription. 3 # 4 # Copyright (c) 2007,2008,2009,2010 Carlo Strozzi 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 dated June, 1991. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 # 19 # ===================================================================== 20 21 # ===================================================================== 22 # void _userproc(int mode) 23 # ===================================================================== 24 25 function _userproc(mode, value,len,a) { 26 27 if (mode == _O_REQUEST) { # request. 28 29 nodestem() 30 31 # target group 32 value = _request("1",1) 33 34 # group must not be null and it may not contain the 35 # unescaped ``.'' character. 36 37 if (value != _NULL && value !~ /\./) { 38 _rcset("cgi.group",unixify(value)) 39 _rcset("cgi.group.literal",value) 40 } 41 42 # user-id will always be considered lower-case and using 43 # an e-mail should not be allowed, to prevent breaking 44 # privacy when a user-id is virtually cancelled. 45 value = tolower(_strip(_request("2",1))) 46 len = length(value) 47 if (value ~ /^[a-z][-_a-z0-9.]*$/ && len > 4 && len < 17) { 48 _rcset("cgi.reg.userid",value) 49 50 # escape grep(1) regexp chars in user-id. 51 gsub(/[][\\^$.*|()]/,"\\\&",value) 52 _rcset("cgi.grep.user",value) 53 } 54 55 # GUID file, in TagURI format. 56 if ((value=_request("3",1)) ~ /^tag:[-:,.a-zA-Z0-9]+$/) 57 _rcset("cgi.reg.guid",value) 58 59 # Captcha code. 60 if ((value=_request("captcha",1)) != _NULL) { 61 gsub(/[\t\r\n<>]+/," ",value) 62 value = substr(_strip(value,_O_MIDDLE),1,32) 63 _rcset("cgi.reg.captcha",value) 64 } 65 66 # The following test is necessary since the address could, 67 # at least in theory, have been set to any string by the 68 # remote user, due to how it is handled to cope with stunnel(8) 69 # and the lack of transproxy support in kernel 2.4.x. 70 71 if (_isipaddr(ENVIRON["REMOTE_ADDR"]) == _TRUE) 72 value = ENVIRON["REMOTE_ADDR"] 73 else value = "0.0.0.0" 74 75 _rcset("REMOTE_ADDR",value) 76 } 77 } 78 79 # EOF