From 709c19f12b1703c1cfb163dce465fc1908f9ab0f Mon Sep 17 00:00:00 2001
From: Leigh B Stoller <stoller@flux.utah.edu>
Date: Sat, 22 Feb 2025 11:10:04 -0700
Subject: [PATCH] Option to duplicate ExecuteAs() output to stdout.

---
 db/User.pm.in | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/db/User.pm.in b/db/User.pm.in
index 5918f20f78..ff18210901 100644
--- a/db/User.pm.in
+++ b/db/User.pm.in
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -wT
 #
-# Copyright (c) 2005-2024 University of Utah and the Flux Group.
+# Copyright (c) 2005-2025 University of Utah and the Flux Group.
 # 
 # {{{EMULAB-LICENSE
 # 
@@ -2032,9 +2032,10 @@ sub FlipTo($$)
 #
 # Execute a command as user and then return to original. 
 #
-sub ExecuteAs($$;$)
+sub ExecuteAs($$;$$)
 {
-    my ($self, $command, $default_gid) = @_;
+    my ($self, $command, $default_gid, $quiet) = @_;
+    $quiet = 1 if (!defined($quiet));
 
     my $current_uid  = $UID;
     my $current_euid = $EUID;
@@ -2044,7 +2045,13 @@ sub ExecuteAs($$;$)
     my $LOGNAME      = $ENV{'LOGNAME'};
 
     $self->FlipTo($default_gid);
-    my $output = emutil::ExecQuiet($command);
+    my $output;
+    if ($quiet) {
+	$output = emutil::ExecQuiet($command);
+    }
+    else {
+	$output = emutil::ExecVerbose($command);
+    }
     my $status = $?;
 
     $EUID   = 0;
-- 
GitLab