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. --- sbocheck | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sbocheck') diff --git a/sbocheck b/sbocheck index f10ced7..bf2ddff 100755 --- a/sbocheck +++ b/sbocheck @@ -13,7 +13,7 @@ use 5.16.0; use strict; use warnings FATAL => 'all'; -use SBO::Lib qw/ update_tree get_available_updates script_error open_fh is_local show_version get_local_outdated_versions /; +use SBO::Lib qw/ _ERR_USAGE update_tree get_available_updates script_error open_fh is_local show_version get_local_outdated_versions /; use Getopt::Long; use File::Basename; use List::Util 'max'; @@ -42,6 +42,11 @@ GetOptions('help|h' => \$help, 'version|v' => \$vers); if ($help) { show_usage(); exit 0 } if ($vers) { show_version(); exit 0 } +unless ($< == 0) { + warn "This script requires root privileges.\n"; + exit +} + update_tree(); # retrieve and format list of available updates -- cgit v1.2.3