Date: Thu, 31 May 2012 12:04:40 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r236809 - soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport Message-ID: <20120531120440.6BE0C106566C@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tzabal Date: Thu May 31 12:04:39 2012 New Revision: 236809 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236809 Log: crashreport: Only root can execute the script and function error for messages to stderr has been added. Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Modified: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh ============================================================================== --- soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Thu May 31 11:43:41 2012 (r236808) +++ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Thu May 31 12:04:39 2012 (r236809) @@ -1,22 +1,43 @@ #!/bin/sh +# +# Crashreport is a program that is responsible to locate, collect and send +# the debugging information of a FreeBSD kernel crash to a central machine +# that collects these reports for analysis from the FreeBSD community and +# the FreeBSD developers. +# . /etc/rc.conf +PROG=`/usr/bin/basename $0` print_usage() { - echo "usage: $(basename $0) [-d dumpdir] [-f file] [-e email]" + echo "usage: ${PROG} [-d dumpdir] [-f file] [-e email]" +} + +error() +{ + echo "${PROG}: ERROR: $*" 1>&2 } # Default dump directory DUMPDIR='/var/crash' -_dumpdir="" -_file="" -_email="" +_dumpdir= +_file= +_email= + + +## Check if the user that executes the script is root +user=`/usr/bin/id -u` +if [ "${user}" != "0" ]; then + error 'Only the superuser (uid 0) can use this program.' + exit 1 +fi +## Get positional parameters while getopts "d:f:e:" opt; do case "$opt" in d) @@ -30,7 +51,7 @@ ;; *) print_usage - exit 1 + exit 2 ;; esac done @@ -47,19 +68,19 @@ fi if [ ! -d "${_dumpdir}" ]; then - echo "crashreport: Dump directory ${_dumpdir} does not exist." - exit 1 + error "Dump directory ${_dumpdir} does not exist." + exit 3 fi if [ -z "`ls ${_dumpdir}`" ]; then - echo "crashreport: Dump directory ${_dumpdir} is empty." - exit 2 + error "Dump directory ${_dumpdir} is empty." + exit 4 fi ## Find the file that contains the debugging information -## It is either a core.txt.X or a textdump.tar.X -X="" +## Normally, it is either a core.txt.X or a textdump.tar.X +X= BOUNDS="${_dumpdir}/bounds" CORE="${_dumpdir}/core.txt" TEXTDUMP="${_dumpdir}/textdump.tar" @@ -82,8 +103,8 @@ fi if [ ! -f "${_dumpdir}/${_file}" ]; then - echo "crashreport: Unable to locate file with debugging information." - exit 3 + error 'Unable to locate file with debugging information.' + exit 5 fi @@ -94,8 +115,8 @@ fi if [ -z "$_email" ]; then - echo 'crashreport: No email address for contact is specified.' - exit 4 + error 'No email address for contact is specified.' + exit 6 fi # Check if the given email address is valid based on its format. @@ -103,8 +124,8 @@ > /dev/null if [ "$?" -ne "0" ]; then - echo "crashreport: Email address ${_email} is invalid." - exit 5 + error "Email address ${_email} is invalid." + exit 7 fi
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120531120440.6BE0C106566C>