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