]> git.proxmox.com Git - pve-client.git/blame - PVE/APIClient/Config.pm
PVE/APIClient/Config.pm: new class to handle configuration file
[pve-client.git] / PVE / APIClient / Config.pm
CommitLineData
a31c7b27
DM
1package PVE::APIClient::Config;
2
3use strict;
4use warnings;
5use JSON;
6use File::HomeDir;
7
8use PVE::Tools;
9
10sub 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
231;