From 9d4874a617805fd376dedac3bce3272951c02397 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 30 May 2012 16:45:08 +1200 Subject: Require root only for actual actions --- clubber | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/clubber b/clubber index 4e871d1..fda8039 100755 --- a/clubber +++ b/clubber @@ -23,13 +23,6 @@ use Digest::MD5; use File::Basename; use Getopt::Long; -# -# Bail if we're not root. -# -if ($< != 0 || $> != 0) { - error("You must have root permissions to use this script."); -} - # # Check ldd is available. # @@ -164,7 +157,7 @@ if ($chroot) { # # If we're just supposed to print what we do, all the better, do - # that and then quit. + # that and then quit; and for that, we don't require root privileges. # if ($dry) { if (keys %$directories) { @@ -181,9 +174,20 @@ if ($chroot) { } # - # Otherwise, we'd best get started. + # Otherwise, we'd best get started, and we need root privileges. # } else { + + # + # Bail if we're not root. + # + if ($< != 0 || $> != 0) { + error("You must have root permissions to use the --chroot parameter."); + } + + # + # Create directories and import libraries. + # foreach my $directory (keys(%$directories)) { system("mkdir -pv ${chroot}${directory}"); } -- cgit v1.2.3