]>
git.proxmox.com Git - pmg-api.git/blob - PMG/API2/ClamAV.pm
1 package PMG
::API2
::ClamAV
;
9 use PVE
::Exception
qw(raise_param_exc);
11 use PMG
::RESTEnvironment
;
12 use PVE
::JSONSchema
qw(get_standard_option);
16 use base
qw(PVE::RESTHandler);
19 __PACKAGE__-
>register_method ({
23 description
=> "Directory index.",
24 permissions
=> { check
=> [ 'admin', 'audit' ] },
26 additionalProperties
=> 0,
28 node
=> get_standard_option
('pve-node'),
37 links
=> [ { rel
=> 'child', href
=> "{subdir}" } ],
44 push @$res, { subdir
=> "database" };
49 __PACKAGE__-
>register_method({
50 name
=> 'database_status',
53 description
=> "ClamAV virus database status.",
55 additionalProperties
=> 0,
57 node
=> get_standard_option
('pve-node'),
60 permissions
=> { check
=> [ 'admin', 'audit' ] },
67 type
=> { type
=> 'string' },
68 build_time
=> { type
=> 'string' },
69 version
=> { type
=> 'string', optional
=> 1 },
70 nsigs
=> { type
=> 'integer' },
77 return PMG
::Utils
::clamav_dbstat
();
80 __PACKAGE__-
>register_method({
81 name
=> 'update_database',
84 description
=> "Update ClamAV virus databases.",
85 permissions
=> { check
=> [ 'admin' ] },
89 additionalProperties
=> 0,
91 node
=> get_standard_option
('pve-node'),
94 returns
=> { type
=> 'string' },
98 my $rpcenv = PMG
::RESTEnvironment-
>get();
99 my $authuser = $rpcenv->get_user();
104 # remove mirrors.dat so freshclam checks all servers again
106 unlink "/var/lib/clamav/mirrors.dat";
108 my $cmd = ['/usr/bin/freshclam', '--stdout'];
110 PVE
::Tools
::run_command
($cmd);
113 return $rpcenv->fork_worker('avupdate', undef, $authuser, $realcmd);