From 1f0b02fbbe5adaea1054672d7cf9d6a37ff9178e Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 29 Oct 2009 13:14:12 +0100 Subject: [PATCH] Drop usage of $UID in scripts; Do not use a negative exit value in shellscripts --- debian/changelog | 7 +++++++ usr_bin/caps-ctrl | 4 ++-- usr_bin/grml-lang | 2 +- usr_bin/say | 2 +- usr_sbin/grml-setservices | 4 ++-- usr_sbin/grml-tpm | 2 +- usr_sbin/ndiswrapper.sh | 2 +- usr_sbin/prepare_ramdisk.sh | 2 +- usr_sbin/prepare_tmpfs.sh | 2 +- 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index 93c1ec8..9460639 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml-scripts (1.1.29) unstable; urgency=low + + * Drop usage of $UID in scripts. + * Do not use a negative exit value in shellscripts. + + -- Michael Prokop Thu, 29 Oct 2009 13:13:41 +0100 + grml-scripts (1.1.28) unstable; urgency=low [ Ulrich Dangel ] diff --git a/usr_bin/caps-ctrl b/usr_bin/caps-ctrl index b0d8f64..8096e42 100755 --- a/usr_bin/caps-ctrl +++ b/usr_bin/caps-ctrl @@ -15,9 +15,9 @@ emulate zsh autoload -U colors ; colors if [[ -z $DISPLAY ]] ; then # test if X is not running when calling us - if [[ $UID != 0 ]] ; then # test if user root did invoke this command + if [ $(id -u) != 0 ] ; then # test if user root did invoke this command eerror "As of Linux 2.6.15 you need root permissions for changing" - eerror "the keyboard on console using loadkeys for security reasons." + eerror "the keyboard on console using loadkeys for security reasons." eerror "Run this program with root permissions. Exiting." ; eend 1 exit 1 fi diff --git a/usr_bin/grml-lang b/usr_bin/grml-lang index 3376d4c..ee8bcd3 100755 --- a/usr_bin/grml-lang +++ b/usr_bin/grml-lang @@ -26,7 +26,7 @@ setvalue(){ if [ $# -lt "1" ] ; then usage - exit -1 + exit 1 fi [ -d /etc/sysconfig ] || sudo mkdir /etc/sysconfig diff --git a/usr_bin/say b/usr_bin/say index 4d18e44..0f3bf16 100755 --- a/usr_bin/say +++ b/usr_bin/say @@ -8,7 +8,7 @@ if [ $# -eq 0 ] ; then echo "Usage: $0 " - exit -1 + exit 1 fi if [ -x /usr/bin/flite ] ; then diff --git a/usr_sbin/grml-setservices b/usr_sbin/grml-setservices index 633ea9b..1d8e146 100755 --- a/usr_sbin/grml-setservices +++ b/usr_sbin/grml-setservices @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Filename: grml-setservices # Purpose: interface for basic configuration of system startup # Authors: grml-team (grml.org), (c) Michael Prokop @@ -21,7 +21,7 @@ bailout(){ exit 0 } -trap bailout SIGHUP SIGINT SIGQUIT SIGTERM +trap bailout HUP INT QUIT TERM is_value_set(){ [ -n "$1" ] || return 2 diff --git a/usr_sbin/grml-tpm b/usr_sbin/grml-tpm index 17000ef..07e2093 100755 --- a/usr_sbin/grml-tpm +++ b/usr_sbin/grml-tpm @@ -8,7 +8,7 @@ . /etc/grml/lsb-functions -if [ $UID != 0 ] ; then +if [ $(id -u) != 0 ] ; then eerror Error: become root before starting $0 >& 2 ; eend 1 exit 100 fi diff --git a/usr_sbin/ndiswrapper.sh b/usr_sbin/ndiswrapper.sh index 38e03d1..f0531af 100755 --- a/usr_sbin/ndiswrapper.sh +++ b/usr_sbin/ndiswrapper.sh @@ -10,7 +10,7 @@ PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin" export PATH # Get root -if [ $UID != 0 ] ; then +if [ $(id -u) != 0 ] ; then echo Error: become root before starting $0 >& 2 exit 100 fi diff --git a/usr_sbin/prepare_ramdisk.sh b/usr_sbin/prepare_ramdisk.sh index 7e94187..e7018fb 100755 --- a/usr_sbin/prepare_ramdisk.sh +++ b/usr_sbin/prepare_ramdisk.sh @@ -6,7 +6,7 @@ # License: This file is licensed under the GPL v2. ################################################################################ -if [ $UID != 0 ]; then +if [ $(id -u) != 0 ] ; then echo "Error: $0 requires root permissions. Exiting." exit 1 fi diff --git a/usr_sbin/prepare_tmpfs.sh b/usr_sbin/prepare_tmpfs.sh index 3208fcc..229fa79 100755 --- a/usr_sbin/prepare_tmpfs.sh +++ b/usr_sbin/prepare_tmpfs.sh @@ -6,7 +6,7 @@ # License: This file is licensed under the GPL v2. ################################################################################ -if [ $UID != 0 ]; then +if [ $(id -u) != 0 ] ; then echo "Error: $0 requires root permissions. Exiting." exit 1 fi -- 2.1.4