Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't run scripts as root when it's not needed to

Most scripts don't have to be run as root and so they shouldn't be run
as root. Display an error message and bail out if these are lauched by
the root user.
  • Loading branch information...
commit 08e16da78881a9911d4c1cb7804510bd96fcf514 1 parent 8707209
@gapan authored
View
5 02-arrangepackages.sh
@@ -1,5 +1,10 @@
#/bin/sh
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
rm -rf iso
rm -rf temp
mkdir -p iso/salix/{kernels,core,basic,full,settings}
View
5 03-createdep.sh
@@ -3,6 +3,11 @@
export LANG=C
export ARCH=${ARCH:-i486}
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
for pkg in `find ./iso/salix -type f -name '*.t[gx]z' -print`
do
PKGNAME=`basename $pkg | sed "s/\(.*\)-\(.*\)-\(.*\)-\(.*\)\.t[gx]z/\1/"`
View
5 04-md5andlist.sh
@@ -1,5 +1,10 @@
#/bin/sh
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
rm -f iso/CHECKSUMS.md5 iso/PACKAGELIST iso/PACKAGELIST-TEMP
for pkg in `find ./iso/salix -type f -name '*.t[gx]z' -print`
View
5 05-packagestxt.sh
@@ -2,6 +2,11 @@
export LANG=C
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
function gen_packages_txt {
echo '' > iso/PACKAGES.TXT
find ./iso/salix -type f -name '*.meta' -exec cat {} \; >> iso/PACKAGES.TXT
View
5 06-cleanup.sh
@@ -1,5 +1,10 @@
#!/bin/sh
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
find ./iso/salix -name "*.dep" -exec rm {} \;
find ./iso/salix -name "*.txt" -exec rm {} \;
find ./iso/salix -name "*.meta" -exec rm {} \;
View
6 08-isolinux.sh
@@ -2,6 +2,12 @@
#
# This scripts creates the isolinux directory for using in salix iso.
+
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
set -e
if [ ! $# -eq 2 ]; then
View
5 09-kernel.sh
@@ -5,6 +5,11 @@
#
# You will first need to install curlftpfs to use it.
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
set -e
if [ ! $# -eq 2 ]; then
View
5 10-gatherfiles.sh
@@ -1,5 +1,10 @@
#!/bin/sh
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
if [ ! $# -eq 1 ]; then
echo "ERROR. Syntax is: $0 ARCH"
exit 1
View
5 99-createiso.sh
@@ -1,5 +1,10 @@
#!/bin/sh
+if [ "$UID" -eq "0" ]; then
+ echo "Don't run this script as root"
+ exit 1
+fi
+
if [ ! $# -eq 4 ]; then
echo "ERROR. Syntax is: $0 EDITION ARCH VERSION ISO_FILENAME"
exit 1
Please sign in to comment.
Something went wrong with that request. Please try again.