HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/webmin/virtual-server/list-backup-keys.pl
#!/usr/bin/perl

=head1 list-backup-keys.pl

Lists all available backup encryption keys.

When run with no flags, this command outputs a table of backup keys for
use by scheduled and manula backups.  To get a more parsable format with full
details for each shell, use the C<--multiline> parameter. Or to only output
key IDs, use the C<--id-only> flag.

=cut

package virtual_server;
if (!$module_name) {
	$main::no_acl_check++;
	$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
	$ENV{'WEBMIN_VAR'} ||= "/var/webmin";
	if ($0 =~ /^(.*)\/[^\/]+$/) {
		chdir($pwd = $1);
		}
	else {
		chop($pwd = `pwd`);
		}
	$0 = "$pwd/list-backup-keys.pl";
	require './virtual-server-lib.pl';
	$< == 0 || die "list-backup-keys.pl must be run as root";
	}

# Parse command-line args
&parse_common_cli_flags(\@ARGV);
while(@ARGV > 0) {
	local $a = shift(@ARGV);
	&usage("Unknown parameter $a");
	}

@keys = &list_backup_keys();
if ($multiline) {
	# Show full details
	foreach $key (@keys) {
		print $key->{'id'},"\n";
		print "    Description: ",$key->{'desc'},"\n";
		if ($key->{'owner'}) {
			print "    Owner: ",$key->{'owner'},"\n";
			}
		print "    GPG key ID: ",$key->{'key'},"\n";
		print "    Created: ",&make_date($key->{'created'}),"\n";
		}
	}
elsif ($idonly) {
	# Just IDs
	foreach $key (@keys) {
		print $key->{'id'},"\n";
		}
	}
else {
	# One per line
	$fmt = "%-20.20s %-40.40s %-17.17s\n";
	printf $fmt, "Key ID", "Description", "Owner";
	printf $fmt, ("-" x 20), ("-" x 40), ("-" x 17);
	foreach $key (@keys) {
		printf $fmt, $key->{'id'},
			     $key->{'desc'},
			     $key->{'owner'} || "root";
		}
	}

sub usage
{
print "$_[0]\n\n" if ($_[0]);
print "Lists all available backup encryption keys.\n";
print "\n";
print "virtualmin list-backup-keys [--multiline | --json | --xml]\n";
print "                            [--id-only]\n";
exit(1);
}