1 # ===================================================================== 2 # updateGroup.awk: RPC I/O function for rpclib/updateGroup. 3 # 4 # Copyright (c) 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,i,save) { 26 27 if (mode == _O_REQUEST) { # request. 28 29 nodestem() 30 31 # target group. 32 value = substr(_request("1",1),1,ENVIRON["TNS_GROUP_MAXLEN"]) 33 34 # group must not be null and it may not contain 35 # the ``.'' character. 36 37 if (value != _NULL && value !~ /\./) { 38 save = unixify(value) 39 _rcset("cgi.group",save) 40 _rcset("cgi.group.literal",value) 41 _rcset("cgi.group.uri",_uriencode(value,_O_PATHINFO)) 42 } 43 44 # Optional group charter/description. 45 value = substr(_request("2",1),1,ENVIRON["TNS_GROUP_MAXTITLE"]) 46 if (value ~ /[a-zA-Z0-9]/) _rcset("cgi.group.descr",value) 47 48 # Optional comma-separated list of group editor(s), which is 49 # cleaned-up here as appropriate before being passed to the 50 # underlying shell script. 51 52 value = _strip(_request("3",1),_O_MIDDLE) 53 gsub(/ +/,",",value) 54 len = length(value) 55 i = split(value,a,",") 56 value = _NULL 57 _sort(a,i) 58 i = _uniq(a,i) 59 while (i > 0) { 60 value = value "," a[i] 61 i-- 62 } 63 sub(/^,+/,_NULL,value) 64 _rcset("cgi.group.editor",value) 65 66 # Current group record checksum. 67 value = _request("checksum",1) 68 if (value ~ /^[a-zA-Z0-9]*$/) _rcset("cgi.checksum",value) 69 70 # The following test is necessary since the address could, 71 # at least in theory, have been set to any string by the 72 # remote user, due to how it is handled to cope with stunnel(8) 73 # and the lack of transproxy support in kernel 2.4.x. 74 75 if (_isipaddr(ENVIRON["REMOTE_ADDR"]) == _TRUE) 76 value = ENVIRON["REMOTE_ADDR"] 77 else value = "0.0.0.0" 78 79 _rcset("REMOTE_ADDR",value) 80 } 81 82 else { # response 83 84 # generic template conditionals. 85 86 ifsections() 87 88 # Remove surrounding commas from displayed value. 89 value = _rcget("tpl.var.tw.group.editor",1) 90 sub(/^,+/,"",value); sub(/,+$/,"",value) 91 _response("tpl.var.tw.group.editor",value) 92 } 93 } 94 95 # EOF