changeset 179:479b57681014

Subshellize acclog() and sanitize rowid
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 20 Feb 2016 10:03:59 +0859
parents ed2915aa2826
children 59bd085848ec
files s4-funcs.sh
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/s4-funcs.sh	Sat Feb 20 09:13:33 2016 +0859
+++ b/s4-funcs.sh	Sat Feb 20 10:03:59 2016 +0859
@@ -420,14 +420,15 @@
   fi
   echo  "\">`gecos $1`</a>"
 }
-acclog() {
+acclog() (
   # $1=table, $2=rowid
-  if [ -n "$2" ]; then
+  n=${2%%[!0-9]*}	# Remove non-digit chars from $2(should be rowid)
+  if [ -n "$n" ]; then
     now=`date +"%F %T"`
-    query "replace into acclog values('$user', '$1', '$2', '$now');"
-    #query "replace into acclog values('$user', '$1', $2, '$now');"
+    #query "replace into acclog values('$user', '$1', '$n', '$now');"
+    query "replace into acclog values('$user', '$1', $n, '$now');"
   fi
-}
+)
 gecos() (
   u=`sqlquote ${1:-$user}`
   #gecos=`query "select val from user_s where name='$u' and key='gecos';"`

yatex.org