Ticket #50421: patch-rename-server-wallet-admin.diff
File patch-rename-server-wallet-admin.diff, 13.1 KB (added by akkornel (A. Karl Kornel), 8 years ago) |
---|
-
deleted file server/wallet-admin
+ - 1 #!/usr/bin/perl2 #3 # Wallet server administrative commands.4 5 use 5.008;6 use strict;7 use warnings;8 9 use Wallet::Admin;10 11 ##############################################################################12 # Implementation13 ##############################################################################14 15 # Parse and execute a command. We wrap this in a subroutine call for easier16 # testing.17 sub command {18 die "Usage: wallet-admin <command> [<args> ...]\n" unless @_;19 my $admin = Wallet::Admin->new;20 21 # Parse command-line options and dispatch to the appropriate calls.22 my ($command, @args) = @_;23 if ($command eq 'destroy') {24 die "too many arguments to destroy\n" if @args;25 print 'This will delete all data in the wallet database. Are you'26 . ' sure (N/y)? ';27 my $response = <STDIN>;28 unless ($response and $response =~ /^y/i) {29 die "Aborted\n";30 }31 $admin->destroy or die $admin->error, "\n";32 } elsif ($command eq 'initialize') {33 die "too many arguments to initialize\n" if @args > 1;34 die "too few arguments to initialize\n" if @args < 1;35 die "invalid admin principal $args[0]\n"36 unless $args[0] =~ /^[^\@\s]+\@\S+$/;37 $admin->initialize (@args) or die $admin->error, "\n";38 } elsif ($command eq 'register') {39 die "too many arguments to register\n" if @args > 3;40 die "too few arguments to register\n" if @args < 3;41 my ($object, $type, $class) = @args;42 if ($object eq 'object') {43 unless ($admin->register_object ($type, $class)) {44 die $admin->error, "\n";45 }46 } elsif ($object eq 'verifier') {47 unless ($admin->register_verifier ($type, $class)) {48 die $admin->error, "\n";49 }50 } else {51 die "only object or verifier is supported for register\n";52 }53 } elsif ($command eq 'upgrade') {54 die "too many arguments to upgrade\n" if @args;55 $admin->upgrade or die $admin->error, "\n";56 } else {57 die "unknown command $command\n";58 }59 }60 command (@ARGV);61 __END__62 63 ##############################################################################64 # Documentation65 ##############################################################################66 67 =for stopwords68 metadata ACL hostname backend acl acls wildcard SQL Allbery verifier69 MERCHANTABILITY NONINFRINGEMENT sublicense70 71 =head1 NAME72 73 wallet-admin - Wallet server administrative commands74 75 =head1 SYNOPSIS76 77 B<wallet-admin> I<command> [I<args> ...]78 79 =head1 DESCRIPTION80 81 B<wallet-admin> provides a command-line interface for performing82 administrative actions for the wallet system, such as setting up a new83 database or running reports. It is intended to be run on the wallet84 server as a user with access to the wallet database and configuration.85 86 This program is a fairly thin wrapper around Wallet::Admin that translates87 command strings into method calls and returns the results.88 89 =head1 OPTIONS90 91 B<wallet-admin> takes no traditional options.92 93 =head1 COMMANDS94 95 =over 496 97 =item destroy98 99 Deletes all data in the wallet database and drops all of the100 wallet-created tables, restoring the database to its state prior to an101 C<initialize> command. Since this command is destructive and cannot be102 easily recovered from, B<wallet-admin> will prompt first to be sure the103 user intends to do this.104 105 =item initialize <principal>106 107 Given an empty database, initializes it for use with the wallet server by108 creating the necessary tables and initial metadata. Also creates an ACL109 with the name ADMIN, used for administrative privileges to the wallet110 system, and adds an ACL entry to it with a scheme of C<krb5> and an111 instance of <principal>. This bootstraps the authentication system and112 allows that user to make further changes to the ADMIN ACL and the rest of113 the wallet database. C<initialize> uses C<localhost> as the hostname and114 <principal> as the user when logging the history of the ADMIN ACL creation115 and for any subsequent actions required to initialize the database.116 117 Before running C<initialize>, the wallet system has to be configured. See118 Wallet::Config(3) for more details. Depending on the database backend119 used, the database may also have to be created in advance.120 121 =item register (object | verifier) <type> <class>122 123 Registers an implementation of a wallet object or ACL verifier in the124 wallet database. The Perl class <class> is registered as the125 implementation of an object of type <type> or an ACL verifier of scheme126 <type>, allowing creation of objects with that type or ACL lines with that127 scheme.128 129 All object and ACL implementations that come with wallet are registered by130 default as part of database initialization, so this command is used131 primarily to register local implementations of additional object types or132 ACL schemes.133 134 =item upgrade135 136 Upgrades the database to the latest schema version, preserving data as137 much as possible.138 139 =back140 141 =head1 AUTHOR142 143 Russ Allbery <eagle@eyrie.org>144 145 =head1 COPYRIGHT AND LICENSE146 147 Copyright 2008, 2009, 2010, 2011, 2013 The Board of Trustees of the Leland148 Stanford Junior University149 150 Permission is hereby granted, free of charge, to any person obtaining a151 copy of this software and associated documentation files (the "Software"),152 to deal in the Software without restriction, including without limitation153 the rights to use, copy, modify, merge, publish, distribute, sublicense,154 and/or sell copies of the Software, and to permit persons to whom the155 Software is furnished to do so, subject to the following conditions:156 157 The above copyright notice and this permission notice shall be included in158 all copies or substantial portions of the Software.159 160 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR161 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,162 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL163 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER164 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING165 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER166 DEALINGS IN THE SOFTWARE.167 168 =head1 SEE ALSO169 170 Wallet::Admin(3), Wallet::Config(3), wallet-backend(8)171 172 This program is part of the wallet system. The current version is173 available from L<http://www.eyrie.org/~eagle/software/wallet/>.174 175 =cut -
new file server/wallet-admin.in
- + 1 #!@PERL@ 2 # 3 # Wallet server administrative commands. 4 5 use 5.008; 6 use strict; 7 use warnings; 8 9 use Wallet::Admin; 10 11 ############################################################################## 12 # Implementation 13 ############################################################################## 14 15 # Parse and execute a command. We wrap this in a subroutine call for easier 16 # testing. 17 sub command { 18 die "Usage: wallet-admin <command> [<args> ...]\n" unless @_; 19 my $admin = Wallet::Admin->new; 20 21 # Parse command-line options and dispatch to the appropriate calls. 22 my ($command, @args) = @_; 23 if ($command eq 'destroy') { 24 die "too many arguments to destroy\n" if @args; 25 print 'This will delete all data in the wallet database. Are you' 26 . ' sure (N/y)? '; 27 my $response = <STDIN>; 28 unless ($response and $response =~ /^y/i) { 29 die "Aborted\n"; 30 } 31 $admin->destroy or die $admin->error, "\n"; 32 } elsif ($command eq 'initialize') { 33 die "too many arguments to initialize\n" if @args > 1; 34 die "too few arguments to initialize\n" if @args < 1; 35 die "invalid admin principal $args[0]\n" 36 unless $args[0] =~ /^[^\@\s]+\@\S+$/; 37 $admin->initialize (@args) or die $admin->error, "\n"; 38 } elsif ($command eq 'register') { 39 die "too many arguments to register\n" if @args > 3; 40 die "too few arguments to register\n" if @args < 3; 41 my ($object, $type, $class) = @args; 42 if ($object eq 'object') { 43 unless ($admin->register_object ($type, $class)) { 44 die $admin->error, "\n"; 45 } 46 } elsif ($object eq 'verifier') { 47 unless ($admin->register_verifier ($type, $class)) { 48 die $admin->error, "\n"; 49 } 50 } else { 51 die "only object or verifier is supported for register\n"; 52 } 53 } elsif ($command eq 'upgrade') { 54 die "too many arguments to upgrade\n" if @args; 55 $admin->upgrade or die $admin->error, "\n"; 56 } else { 57 die "unknown command $command\n"; 58 } 59 } 60 command (@ARGV); 61 __END__ 62 63 ############################################################################## 64 # Documentation 65 ############################################################################## 66 67 =for stopwords 68 metadata ACL hostname backend acl acls wildcard SQL Allbery verifier 69 MERCHANTABILITY NONINFRINGEMENT sublicense 70 71 =head1 NAME 72 73 wallet-admin - Wallet server administrative commands 74 75 =head1 SYNOPSIS 76 77 B<wallet-admin> I<command> [I<args> ...] 78 79 =head1 DESCRIPTION 80 81 B<wallet-admin> provides a command-line interface for performing 82 administrative actions for the wallet system, such as setting up a new 83 database or running reports. It is intended to be run on the wallet 84 server as a user with access to the wallet database and configuration. 85 86 This program is a fairly thin wrapper around Wallet::Admin that translates 87 command strings into method calls and returns the results. 88 89 =head1 OPTIONS 90 91 B<wallet-admin> takes no traditional options. 92 93 =head1 COMMANDS 94 95 =over 4 96 97 =item destroy 98 99 Deletes all data in the wallet database and drops all of the 100 wallet-created tables, restoring the database to its state prior to an 101 C<initialize> command. Since this command is destructive and cannot be 102 easily recovered from, B<wallet-admin> will prompt first to be sure the 103 user intends to do this. 104 105 =item initialize <principal> 106 107 Given an empty database, initializes it for use with the wallet server by 108 creating the necessary tables and initial metadata. Also creates an ACL 109 with the name ADMIN, used for administrative privileges to the wallet 110 system, and adds an ACL entry to it with a scheme of C<krb5> and an 111 instance of <principal>. This bootstraps the authentication system and 112 allows that user to make further changes to the ADMIN ACL and the rest of 113 the wallet database. C<initialize> uses C<localhost> as the hostname and 114 <principal> as the user when logging the history of the ADMIN ACL creation 115 and for any subsequent actions required to initialize the database. 116 117 Before running C<initialize>, the wallet system has to be configured. See 118 Wallet::Config(3) for more details. Depending on the database backend 119 used, the database may also have to be created in advance. 120 121 =item register (object | verifier) <type> <class> 122 123 Registers an implementation of a wallet object or ACL verifier in the 124 wallet database. The Perl class <class> is registered as the 125 implementation of an object of type <type> or an ACL verifier of scheme 126 <type>, allowing creation of objects with that type or ACL lines with that 127 scheme. 128 129 All object and ACL implementations that come with wallet are registered by 130 default as part of database initialization, so this command is used 131 primarily to register local implementations of additional object types or 132 ACL schemes. 133 134 =item upgrade 135 136 Upgrades the database to the latest schema version, preserving data as 137 much as possible. 138 139 =back 140 141 =head1 AUTHOR 142 143 Russ Allbery <eagle@eyrie.org> 144 145 =head1 COPYRIGHT AND LICENSE 146 147 Copyright 2008, 2009, 2010, 2011, 2013 The Board of Trustees of the Leland 148 Stanford Junior University 149 150 Permission is hereby granted, free of charge, to any person obtaining a 151 copy of this software and associated documentation files (the "Software"), 152 to deal in the Software without restriction, including without limitation 153 the rights to use, copy, modify, merge, publish, distribute, sublicense, 154 and/or sell copies of the Software, and to permit persons to whom the 155 Software is furnished to do so, subject to the following conditions: 156 157 The above copyright notice and this permission notice shall be included in 158 all copies or substantial portions of the Software. 159 160 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 162 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 163 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 164 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 165 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 166 DEALINGS IN THE SOFTWARE. 167 168 =head1 SEE ALSO 169 170 Wallet::Admin(3), Wallet::Config(3), wallet-backend(8) 171 172 This program is part of the wallet system. The current version is 173 available from L<http://www.eyrie.org/~eagle/software/wallet/>. 174 175 =cut