Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/top bring in fixes from beta12:



details:   https://anonhg.NetBSD.org/src/rev/92e10caa49de
branches:  trunk
changeset: 510201:92e10caa49de
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 22 15:38:22 2001 +0000

description:
bring in fixes from beta12:
        - better error checking for read/write failures
        - new install/configure/Makefile and support scripts (we don't use)
        - don't allow 0 delay for non-root accounts
XXX: Someone needs to coordinate to feed back our prototype fixes to Jeff!

diffstat:

 usr.bin/top/Configure    |   69 +++++++++++++----
 usr.bin/top/Makefile.X   |    7 +-
 usr.bin/top/getans       |  186 +++++++++++++++++++++++++++-------------------
 usr.bin/top/machine.h    |   10 ++-
 usr.bin/top/patchlevel.h |    4 +-
 usr.bin/top/top.c        |   31 +++++--
 6 files changed, 197 insertions(+), 110 deletions(-)

diffs (truncated from 496 to 300 lines):

diff -r 281b2c14c056 -r 92e10caa49de usr.bin/top/Configure
--- a/usr.bin/top/Configure     Tue May 22 15:29:30 2001 +0000
+++ b/usr.bin/top/Configure     Tue May 22 15:38:22 2001 +0000
@@ -262,9 +262,16 @@
 echo ""
 
 set rand = 0
-ypwhich >&/dev/null
-if ($status == 0 || -e /etc/passwd.dir || -e /etc/pwd.db) then
-   set rand = 1
+if (-e /etc/nsswitch.conf) then
+   set rand = `grep '^passwd:.*nis' /etc/nsswitch.conf | wc -l`
+   if ($rand > 1) then
+      set rand = 1
+   endif
+else
+   ypwhich >&/dev/null
+   if ($status == 0 || -e /etc/passwd.dir || -e /etc/pwd.db) then
+      set rand = 1
+   endif
 endif
 
 if ($rand == 1) then
@@ -299,8 +306,15 @@
    set cnt = `wc -l </tmp/$$.a`
    set mapfile = "NIS map"
 else
-   set cnt = `wc -l </etc/passwd`
-   set mapfile = "file"
+   rm /tmp/$$.a
+   niscat passwd.org_dir >&/tmp/$$.a
+   if ($status == 0) then
+      set cnt = `wc -l </tmp/$$.a`
+      set mapfile = "NISPLUS map"
+   else
+      set cnt = `wc -l </etc/passwd`
+      set mapfile = "file"
+   endif
 endif
 rm /tmp/$$.a
 set double = `expr $cnt \* 2`
@@ -341,15 +355,11 @@
 set t_group = `$ls -d /usr/bin | awk ' { print $4 }'`
 if (-e /proc) then
    cat <<EOF
-Uh oh!  I see /proc out there.  Some new Unix variants provide the
-/proc file system as a mechanism to get to a process's address space.
-This directory is typically only accessible by root.  However, there
-are a few systems (such as DG/UX) on which this directory exists, but
-isn't used.  I'm going to assume that top needs to run setuid to root,
-but you should double check and use mode 2755 (set group id) if top
-doesn't really need root access.  If you are running SunOS 5.0 - SunOS
-5.5.1 then you will need to install top setuid root (owner root and
-mode 4711).  In SunOS 5.6 top only requires set-gid sys permissions.
+I see /proc out there.  Many Unix variants provide the /proc file
+system as a mechanism to get to a process's address space.  This
+directory is typically only accessible by root.  However, there are a
+few systems (such as DG/UX) on which this directory exists, but isn't
+used.
 
 EOF
    if (-r /proc/0/psinfo) then
@@ -357,9 +367,24 @@
        set mode = 2711
        set t_group = sys
        set group = sys
+       cat <<EOF
+It looks like this system is running Solaris 2.6 or greater.  If this
+is the case, then top can function just fine installed set group id to
+sys.  It does not need to be installed set-uid to root.
+
+EOF
    else
        set t_mode = 4711
        set mode = 4711
+       cat <<EOF
+I'm going to assume that top needs to run setuid to root, but you
+should double check and use mode 2755 (set group id) if top doesn't
+really need root access.  If you are running SunOS 5.0 through SunOS
+5.5.1 (that's Solaris 2.0 through Solaris 2.5.1) then you will need to
+install top setuid root (owner root and mode 4711).  In SunOS 5.6 
+and higher top only requires set group id sys permissions.
+
+EOF
     endif
 else if (-e /dev/kmem) then
    $ls /dev/kmem >/tmp/$$.b
@@ -418,13 +443,14 @@
 # Some Unix environments are so poor that their csh doesn't even support
 # the "eval" builtin.  Check for this before relying on its use to save
 # the current configuration.
-/bin/csh -c "eval echo foo" >&/dev/null
+/bin/csh -fc "eval echo foo" >&/dev/null
 if ($status == 1) then
    echo "Can't save configuration (nonfatal)"
 else
    echo "Saving configuration..."
 # save settings to use as defaults the next time
    rm -f .defaults
+   touch .defaults
    foreach v ($vars)
       set tmp = `eval echo \$$v`
       echo set $v = "'$tmp'" >>.defaults
@@ -444,6 +470,7 @@
 set libs = `grep LIBS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
 set cflgs = `grep CFLAGS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
 set tcap = `grep TERMCAP: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
+set math = `grep MATH: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
 
 # get osrev defition, if we can
 set uname=""
@@ -464,6 +491,15 @@
 # default for tcap (termcap)
 if ("$tcap" == "") then
     set tcap="-ltermcap"
+else if ("$tcap" == "none") then
+    set tcap=""
+endif
+
+# allow for the module to override or remove -lm
+if ("$math" == "") then
+    set math="-lm"
+else if ("$math" == "none") then
+    set math=""
 endif
 
 if ( { grep -s SIGKILL /usr/include/signal.h } ) then
@@ -487,6 +523,7 @@
     -e "s|%libs%|$libs|" \
     -e "s|%cflgs%|$cflgs|" \
     -e "s|%termcap%|$tcap|" \
+    -e "s|%math%|$math|" \
     -e "s|%cdefs%|$cdefs|" \
     -e "s|%signal%|$signal|" \
     -e "s|%cc%|$Cmdcc|" \
@@ -494,7 +531,7 @@
     -e "s|%install%|$Cmdinstall|" \
     -e "s|%shell%|$Cmdshell|" \
     -e "s|%osrev%|$osrev|" \
-       Makefile.X > /dev/null
+       Makefile.X >Makefile
 
 echo "Building top.local.h..."
 sed -e "s|%LoadMax%|$LoadMax|" \
diff -r 281b2c14c056 -r 92e10caa49de usr.bin/top/Makefile.X
--- a/usr.bin/top/Makefile.X    Tue May 22 15:29:30 2001 +0000
+++ b/usr.bin/top/Makefile.X    Tue May 22 15:38:22 2001 +0000
@@ -53,6 +53,7 @@
 CDEFS = %cdefs%
 LIBS = %libs%
 TERMCAP = %termcap%
+MATH = %math%
 
 CFLAGS = %cflgs% $(CDEFS)
 LINTFLAGS = -x $(CDEFS)
@@ -69,14 +70,14 @@
 
 top: $(OBJS)
        rm -f top
-       $(CC) -o top $(OBJS) $(TERMCAP) -lm $(LIBS)
+       $(CC) $(CDEFS) -o top $(OBJS) $(TERMCAP) $(MATH) $(LIBS)
 
 lint: sigdesc.h
        $(LINT) $(LINTFLAGS) $(CFILES)
 
 # include file dependencies
 top.o: boolean.h display.h screen.h top.h top.local.h utils.h machine.h 
-commands.o: boolean.h sigdesc.h utils.h
+commands.o: boolean.h sigdesc.h top.h utils.h
 display.o: boolean.h display.h layout.h screen.h top.h top.local.h utils.h
 screen.o: boolean.h screen.h
 utils.o: top.h
@@ -84,7 +85,7 @@
 username.o: top.local.h utils.h
 
 # when compiling machine.c, include os revision definition
-machine.o: top.h machine.h utils.h
+machine.o: machine.c top.h machine.h utils.h
        $(CC) "%osrev%" $(CFLAGS) -c machine.c
 
 # automatically built include file
diff -r 281b2c14c056 -r 92e10caa49de usr.bin/top/getans
--- a/usr.bin/top/getans        Tue May 22 15:29:30 2001 +0000
+++ b/usr.bin/top/getans        Tue May 22 15:38:22 2001 +0000
@@ -1,90 +1,118 @@
-#!/bin/csh -f
-set ny = (no yes)
-if ($2 == "yesno") then
-    @ i = $3 + 1
-    set pmpt = "$1 [$ny[$i]]: "
-else
-    if ("$3" == "") then
-        set pmpt = "${1}"
-    else
-        set pmpt = "$1 [$3]: "
-    endif
-endif
-rpt:
-echo -n "$pmpt"
-if ( "`uname -s`" == SCO_SV ) then
-    set input = `sh -c 'read word; echo $word'`
+#!/bin/sh
+# getans prompt type default  results_filename
+#  type is one of 
+#   number  
+#   integer
+#   neginteger
+#   file    default=default filename
+#   path        
+#   yesno   default=0,1 corres yes or no 
+#   string (default)
+
+RAWPMPT=$1
+TYP=$2
+DFLT=$3
+OFNM=$4
+
+ny0="no"; ny1="yes"
+if [ ${TYP} = "yesno" ]; then
+    eval ny=\$ny${DFLT}
+    pmpt="${RAWPMPT} [$ny]: "
 else
-    set input = $<
-endif
-switch ($2)
-    case number:
-       set tmp = `echo $input | tr -d 0123456789.`
-       if ("x$tmp" != x) then
-           echo "Invalid number.  Please try again."
-           goto rpt
-       endif
-       breaksw
+    if [ -z "${DFLT}" ]; then
+        pmpt="${RAWPMPT}"
+    else
+        pmpt="${RAWPMPT} [${DFLT}]: "
+    fi
+fi
+if [ x"`echo -n`" = x-n ]
+then
+    c=\\c
+else
+    n=-n
+fi
 
-    case integer:
-       set tmp = `echo $input | tr -d 0123456789`
-       if ("x$tmp" != x) then
+while :
+do
+    echo $n "$pmpt"$c
+    read input
+    case "$TYP" in
+    number)
+       tmp=`echo $input | tr -d 0123456789.`
+       if [ -n "$tmp" ]; then
+           echo "Invalid number.  Please try again."
+           continue
+       fi
+       ;;
+
+    integer)
+       tmp=`echo $input | tr -d 0123456789`
+       if [ -n "$tmp" ]; then
            echo "Invalid integer.  Please try again."
-           goto rpt
-       endif
-       breaksw
+           continue
+       fi
+       ;;
 
-    case neginteger:
-       if ("x$input" != x-1) then
-           set tmp = `echo $input | tr -d 0123456789`
-           if ("x$tmp" != x) then
+    neginteger)
+       if [ "x$input" != "x-1" ]; then
+           tmp=`echo $input | tr -d 0123456789`
+           if [ -n "$tmp" ]; then
                echo "Invalid integer.  Please try again."
-               goto rpt
-           endif
-       endif
-       breaksw
+               continue
+           fi
+       fi
+        ;;
 
-    case file:
-       if ("x$input" == "x") then
-           set input = $3
-       endif
-       if (! -e "$input") then
-           echo The file $input "does not exist.  Please try again."
-           goto rpt
-       endif
-       breaksw
+    file)



Home | Main Index | Thread Index | Old Index