]> git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Config.pm
PVE/APIClient/Config.pm: new class to handle configuration file
[pve-client.git] / PVE / APIClient / Config.pm
1 package PVE::APIClient::Config;
2
3 use strict;
4 use warnings;
5 use JSON;
6 use File::HomeDir;
7
8 use PVE::Tools;
9
10 sub load_config {
11
12 my $filename = home() . '/.pveclient';
13 my $conf_str = PVE::Tools::file_get_contents($filename);
14
15 my $filemode = (stat($filename))[2] & 07777;
16 if ($filemode != 0600) {
17 die sprintf "wrong permissions on '$filename' %04o (expected 0600)\n", $filemode;
18 }
19
20 return decode_json($conf_str);
21 };
22
23 1;