forked from proxmox/pve-access-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pveum
executable file
·105 lines (74 loc) · 2.64 KB
/
pveum
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use PVE::Tools qw(run_command);
use PVE::Cluster;
use PVE::SafeSyslog;
use PVE::AccessControl;
use File::Path qw(make_path remove_tree);
use Term::ReadLine;
use PVE::INotify;
use PVE::RPCEnvironment;
use PVE::API2::User;
use PVE::API2::Group;
use PVE::API2::Role;
use PVE::API2::ACL;
use PVE::API2::AccessControl;
use PVE::JSONSchema qw(get_standard_option);
use PVE::CLIHandler;
use base qw(PVE::CLIHandler);
use Data::Dumper; # fixme: remove
$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
initlog('pveum');
#fixme: logging?
my $read_password = sub {
# return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET});
my $term = new Term::ReadLine ('pveum');
my $attribs = $term->Attribs;
$attribs->{redisplay_function} = $attribs->{shadow_redisplay};
my $input = $term->readline('Enter new password: ');
my $conf = $term->readline('Retype new password: ');
die "Passwords do not match.\n" if ($input ne $conf);
return $input;
};
my $cmddef = {
ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
sub {
my ($res) = @_;
print "$res->{ticket}\n";
}],
passwd => [ 'PVE::API2::AccessControl', 'change_passsword', ['userid'] ],
useradd => [ 'PVE::API2::User', 'create_user', ['userid'] ],
usermod => [ 'PVE::API2::User', 'update_user', ['userid'] ],
userdel => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
groupadd => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
groupmod => [ 'PVE::API2::Group', 'update_group', ['groupid'] ],
groupdel => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ],
roleadd => [ 'PVE::API2::Role', 'create_role', ['roleid'] ],
rolemod => [ 'PVE::API2::Role', 'update_role', ['roleid'] ],
roledel => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ],
aclmod => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }],
acldel => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
};
my $cmd = shift;
if (defined($cmd) && $cmd ne 'verifyapi' && $cmd ne 'printmanpod') {
die "please run as root\n" if $> != 0;
PVE::INotify::inotify_init();
my $rpcenv = PVE::RPCEnvironment->init('cli');
$rpcenv->init_request();
$rpcenv->set_language($ENV{LANG});
$rpcenv->set_user('root@pam');
# autmatically generate the private key if it does not already exists
PVE::Cluster::gen_auth_key();
}
PVE::CLIHandler::handle_cmd($cmddef, "pveum", $cmd, \@ARGV, $read_password, $0);
exit 0;
__END__
=head1 NAME
pveum - PVE User Manager
=head1 SYNOPSIS
=include synopsis
=head1 DESCRIPTION
No description available.
=include pve_copyright