From 921e9a76f1ca47d30d765f2f2bf61954e8ac9c9c Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Tue, 21 Jan 2025 16:11:42 -0500 Subject: Avoid requiring root access Make temporary folder generation lazy to postpone requiring root access until needed. --- sboclean | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sboclean') diff --git a/sboclean b/sboclean index f1eb695..980de44 100755 --- a/sboclean +++ b/sboclean @@ -13,7 +13,7 @@ use 5.16.0; use strict; use warnings FATAL => 'all'; -use SBO::Lib qw/ prompt usage_error script_error in show_version %config /; +use SBO::Lib qw/ _ERR_USAGE prompt usage_error script_error in show_version %config /; use File::Basename; use Getopt::Long qw(:config bundling); use File::Path qw(remove_tree); @@ -56,6 +56,11 @@ if ($vers) { show_version(); exit 0 } usage_error("You must specify at least one of -d or -w.") unless ($dist || $work); +unless ($< == 0) { + warn "This script requires root privileges.\n"; + exit _ERR_USAGE; +} + sub rm_full { script_error('rm_full requires an argument.') unless @_ == 1; my $full = shift; -- cgit v1.2.3