]> git.proxmox.com Git - pve-access-control.git/blame - PVE/CLI/pveum.pm
d/control: remove outdated dependencies
[pve-access-control.git] / PVE / CLI / pveum.pm
CommitLineData
09281ad7
DM
1package PVE::CLI::pveum;
2
3use strict;
4use warnings;
5use Getopt::Long;
6use PVE::Tools qw(run_command);
7use PVE::Cluster;
8use PVE::SafeSyslog;
9use PVE::AccessControl;
10use File::Path qw(make_path remove_tree);
09281ad7
DM
11use PVE::INotify;
12use PVE::RPCEnvironment;
13use PVE::API2::User;
14use PVE::API2::Group;
15use PVE::API2::Role;
16use PVE::API2::ACL;
17use PVE::API2::AccessControl;
18use PVE::JSONSchema qw(get_standard_option);
19use PVE::CLIHandler;
b34d76e7 20use PVE::PTY;
09281ad7
DM
21
22use base qw(PVE::CLIHandler);
23
e623414a
DM
24sub setup_environment {
25 PVE::RPCEnvironment->setup_default_cli_env();
26}
27
b34d76e7
DC
28sub param_mapping {
29 my ($name) = @_;
98007830 30
b34d76e7
DC
31 my $mapping = {
32 'change_password' => [
33 PVE::CLIHandler::get_standard_mapping('pve-password'),
34 ],
35 'create_ticket' => [
36 PVE::CLIHandler::get_standard_mapping('pve-password', {
37 func => sub {
38 # do not accept values given on cmdline
39 return PVE::PTY::read_password('Enter password: ');
40 },
41 }),
42 ]
43 };
44
45 return $mapping->{$name};
98007830
DM
46}
47
09281ad7 48our $cmddef = {
1e41cdc9
PA
49 user => {
50 add => [ 'PVE::API2::User', 'create_user', ['userid'] ],
51 modify => [ 'PVE::API2::User', 'update_user', ['userid'] ],
52 delete => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
53 },
54 group => {
55 add => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
56 modify => [ 'PVE::API2::Group', 'update_group', ['groupid'] ],
57 delete => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ],
58 },
59 role => {
60 add => [ 'PVE::API2::Role', 'create_role', ['roleid'] ],
61 modify => [ 'PVE::API2::Role', 'update_role', ['roleid'] ],
62 delete => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ],
63 },
64 acl => {
65 modify => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }],
66 delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
67 },
09281ad7
DM
68 ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
69 sub {
70 my ($res) = @_;
71 print "$res->{ticket}\n";
72 }],
73
765305e2 74 passwd => [ 'PVE::API2::AccessControl', 'change_password', ['userid'] ],
09281ad7 75
1e41cdc9
PA
76 useradd => { alias => 'user add' },
77 usermod => { alias => 'user modify' },
78 userdel => { alias => 'user delete' },
09281ad7 79
1e41cdc9
PA
80 groupadd => { alias => 'group add' },
81 groupmod => { alias => 'group modify' },
82 groupdel => { alias => 'group delete' },
09281ad7 83
1e41cdc9
PA
84 roleadd => { alias => 'role add' },
85 rolemod => { alias => 'role modify' },
86 roledel => { alias => 'role delete' },
09281ad7 87
1e41cdc9
PA
88 aclmod => { alias => 'acl modify' },
89 acldel => { alias => 'acl delete' },
09281ad7
DM
90};
91
921;