I've encountered a problem with the openpkg/shtool script when running the
mysql daily program, openpkg-20030203-20030203. Around line 1816,
``optionally take logfile size into account'', it's using what seems to me
to be a fairly comples combination of ``set, ls, and sed'' to compute the
file size which actually is returning the user or group name on a SuSE 8.1
Linux system.
It seems to me that this would be much simpler using something like this:
size=`ls -l $ldir/$file | awk '{printf "%d\n", $5}'`
I'm attaching a diff for shtool that does this.
The patch also includes ``id'' calls to fix problems that occur when
running on a Linux system using nss_ldap and nss_ldap where the openpkg
users aren't in the /etc/{passwd,group} files or found with ypcat.
Bill
--
INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC
UUCP: camco!bill PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/
``Things in our country run in spite of government. Not by aid of it!''
Will Rogers
--- /tmp/shtool 2003-02-21 09:59:14.000000000 -0800
+++ /home/csoft/suse81/lib/openpkg/shtool 2003-02-21 09:58:01.000000000 -0800
@@ -677,6 +677,9 @@
if [ ".$userid" = . ]; then
userid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
+ if [ ".$userid" = . ]; then #{
+ userid="`(id -u ${username}) 2>/dev/null`"
+ fi #}
if [ ".$userid" = . ]; then
userid=`(ypcat passwd) 2>/dev/null |
egrep "^${username}:" | \
@@ -694,6 +697,9 @@
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="`(id -g ${username}) 2>/dev/null`"
+ fi #}
if [ ".$groupid" = . ]; then
groupid=`(ypcat passwd) 2>/dev/null | egrep "^${username}:" | \
sed -e 's/[^:]*:[^:]*:[^:]*://' -e 's/:.*$//'`
@@ -708,6 +714,9 @@
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="`(id -gn ${username}) 2>/dev/null`"
+ fi #}
if [ ".$groupname" = . ]; then
groupname=`(ypcat group) 2>/dev/null | \
egrep "^[^:]*:[^:]*:${groupid}:" | \
@@ -1807,10 +1816,7 @@
# optionally take logfile size into account
if [ ".$opt_s" != . ]; then
# determine size of logfile
- set -- `ls -l $ldir/$file | sed -e 's; -> .*$;;' -e 's;[ ][ ]*; ;g'`
- n=`expr $# - 4`
- eval "size=\`echo \${$n}\`"
-
+ size=`ls -l $ldir/$file | awk '{printf "%d\n", $5}'`
# skip logfile if size is still too small
if [ $size -lt $opt_s ]; then
if [ ".$opt_v" = .yes ]; then