OSSP CVS Repository

ossp - Difference in ossp-pkg/shtool/sh.echo versions 1.25 and 1.26
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/shtool/sh.echo 1.25 -> 1.26

--- sh.echo      2001/06/13 08:54:50     1.25
+++ sh.echo      2001/06/13 21:30:05     1.26
@@ -99,7 +99,7 @@
 
 #   determine user name
 username=''
-if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uU]'`" != . ]; then
+if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uUgG]'`" != . ]; then
     username="$LOGNAME"
     if [ ".$username" = . ]; then
         username="$USER"
@@ -141,6 +141,35 @@
     fi
 fi
 
+#   determine (primary) group id
+groupid=''
+if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[gG]'`" != . ]; then
+    groupid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
+             sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
+    if [ ".$groupid" = . ]; then
+        groupid=`(ypcat passwd) 2>/dev/null | egrep "^${username}:" | \
+                 sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
+        if [ ".$groupid" = . ]; then
+            groupid='?'
+        fi
+    fi
+fi
+
+#   determine (primary) group name
+groupname=''
+if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%g'`" != . ]; then
+    groupname=`egrep "^[^:]*:[^:]*:${groupid}:" /etc/group 2>/dev/null | \
+               sed -e 's/:.*$//'`
+    if [ ".$groupname" = . ]; then
+        groupname=`(ypcat group) 2>/dev/null | \
+                   egrep "^[^:]*:[^:]*:${groupid}:" | \
+                   sed -e 's/:.*$//'`
+        if [ ".$groupname" = . ]; then
+            groupname='?'
+        fi
+    fi
+fi
+
 #   determine host and domain name
 hostname=''
 domainname=''
@@ -220,6 +249,8 @@
               -e "s/%b/${term_norm}/g" \
               -e "s/%u/${username}/g" \
               -e "s/%U/${userid}/g" \
+              -e "s/%g/${groupname}/g" \
+              -e "s/%G/${groupid}/g" \
               -e "s/%h/${hostname}/g" \
               -e "s/%d/${domainname}/g" \
               -e "s/%D/${time_day}/g" \

CVSTrac 2.0.1