From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 908FA1FF177 for ; Fri, 2 Aug 2024 15:27:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6A640DB3D; Fri, 2 Aug 2024 15:27:40 +0200 (CEST) From: Max Carrara To: pve-devel@lists.proxmox.com Date: Fri, 2 Aug 2024 15:26:40 +0200 Message-Id: <20240802132656.270077-3-m.carrara@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240802132656.270077-1-m.carrara@proxmox.com> References: <20240802132656.270077-1-m.carrara@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v1 pve-common 02/18] pbsclient: use parentheses when calling most inbuilts X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" .. except for really common cases like `die`, `warn`, `keys`. Signed-off-by: Max Carrara --- src/PVE/PBSClient.pm | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/PVE/PBSClient.pm b/src/PVE/PBSClient.pm index a1536e6..3e98dd1 100644 --- a/src/PVE/PBSClient.pm +++ b/src/PVE/PBSClient.pm @@ -49,11 +49,11 @@ sub new { $secret_dir = '/etc/pve/priv/storage' if !defined($secret_dir); - my $self = bless { + my $self = bless({ scfg => $scfg, storeid => $storeid, secret_dir => $secret_dir - }, $class; + }, $class); return $self; } @@ -67,7 +67,7 @@ sub set_password { my ($self, $password) = @_; my $pwfile = password_file_name($self); - mkdir $self->{secret_dir}; + mkdir($self->{secret_dir}); PVE::Tools::file_set_contents($pwfile, "$password\n", 0600); }; @@ -98,7 +98,7 @@ sub set_encryption_key { my ($self, $key) = @_; my $encfile = $self->encryption_key_file_name(); - mkdir $self->{secret_dir}; + mkdir($self->{secret_dir}); PVE::Tools::file_set_contents($encfile, "$key\n", 0600); }; @@ -108,7 +108,7 @@ sub delete_encryption_key { my $encfile = $self->encryption_key_file_name(); - if (!unlink $encfile) { + if (!unlink($encfile)) { return if $! == ENOENT; die "failed to delete encryption key! $!\n"; } @@ -144,7 +144,7 @@ my $USE_CRYPT_PARAMS = { my sub do_raw_client_cmd { my ($self, $client_cmd, $param, %opts) = @_; - my $client_bin = (delete $opts{binary}) || 'proxmox-backup-client'; + my $client_bin = delete($opts{binary}) || 'proxmox-backup-client'; my $use_crypto = $USE_CRYPT_PARAMS->{$client_bin}->{$client_cmd} // 0; my $client_exe = "/usr/bin/$client_bin"; @@ -153,13 +153,13 @@ my sub do_raw_client_cmd { my $scfg = $self->{scfg}; my $repo = get_repository($scfg); - my $userns_cmd = delete $opts{userns_cmd}; + my $userns_cmd = delete($opts{userns_cmd}); my $cmd = []; - push @$cmd, @$userns_cmd if defined($userns_cmd); + push(@$cmd, @$userns_cmd) if defined($userns_cmd); - push @$cmd, $client_exe, $client_cmd; + push(@$cmd, $client_exe, $client_cmd); # This must live in the top scope to not get closed before the `run_command` my $keyfd; @@ -169,17 +169,17 @@ my sub do_raw_client_cmd { // die "failed to get file descriptor flags: $!\n"; fcntl($keyfd, F_SETFD, $flags & ~FD_CLOEXEC) or die "failed to remove FD_CLOEXEC from encryption key file descriptor\n"; - push @$cmd, '--crypt-mode=encrypt', '--keyfd='.fileno($keyfd); + push(@$cmd, '--crypt-mode=encrypt', '--keyfd='.fileno($keyfd)); } else { - push @$cmd, '--crypt-mode=none'; + push(@$cmd, '--crypt-mode=none'); } } - push @$cmd, @$param if defined($param); + push(@$cmd, @$param) if defined($param); - push @$cmd, "--repository", $repo; + push(@$cmd, "--repository", $repo); if (defined(my $ns = delete($opts{namespace}))) { - push @$cmd, '--ns', $ns; + push(@$cmd, '--ns', $ns); } local $ENV{PBS_PASSWORD} = $self->get_password(); @@ -266,7 +266,7 @@ sub get_snapshots { } my $param = []; - push @$param, $group if defined($group); + push(@$param, $group) if defined($group); return run_client_cmd($self, "snapshots", $param, undef, undef, $namespace); }; @@ -337,16 +337,16 @@ sub prune_group { my $param = []; - push @$param, "--quiet"; + push(@$param, "--quiet"); if (defined($opts->{'dry-run'}) && $opts->{'dry-run'}) { - push @$param, "--dry-run", $opts->{'dry-run'}; + push(@$param, "--dry-run", $opts->{'dry-run'}); } foreach my $keep_opt (keys %$prune_opts) { - push @$param, "--$keep_opt", $prune_opts->{$keep_opt}; + push(@$param, "--$keep_opt", $prune_opts->{$keep_opt}); } - push @$param, "$group"; + push(@$param, "$group"); return run_client_cmd($self, 'prune', $param, undef, undef, $namespace); }; @@ -381,7 +381,7 @@ sub file_restore_list { my $cmd = [ $snapshot, $filepath, "--base64", $base64 ? 1 : 0]; if (my $timeout = $extra_params->{timeout}) { - push $cmd->@*, '--timeout', $timeout; + push($cmd->@*, '--timeout', $timeout); } return run_client_cmd( @@ -406,9 +406,9 @@ sub file_restore_extract_prepare { # allow reading data for proxy user my $wwwid = getpwnam('www-data') || die "getpwnam failed"; - chown $wwwid, -1, "$tmpdir" + chown($wwwid, -1, "$tmpdir") or die "changing permission on fifo dir '$tmpdir' failed: $!\n"; - chown $wwwid, -1, "$tmpdir/fifo" + chown($wwwid, -1, "$tmpdir/fifo") or die "changing permission on fifo '$tmpdir/fifo' failed: $!\n"; return "$tmpdir/fifo"; @@ -432,7 +432,7 @@ sub file_restore_extract { my $cmd = [ $snapshot, $filepath, "-", "--base64", $base64 ? 1 : 0]; if ($tar) { - push @$cmd, '--format', 'tar', '--zstd', 1; + push(@$cmd, '--format', 'tar', '--zstd', 1); } return run_raw_client_cmd( -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel