cloudflare/Cloudflare-CPanel
Publicmirrored fromhttps://github.com/cloudflare/Cloudflare-CPanel
APIKey
29lines · modecode
| 1 | #!/usr/local/cpanel/3rdparty/bin/perl |
| 2 | |
| 3 | use strict; |
| 4 | use Cpanel::AdminBin::Serializer (); |
| 5 | use Cpanel::Logger (); |
| 6 | use Cpanel::PwCache (); |
| 7 | use Cpanel::LoadFile (); |
| 8 | |
| 9 | my $HOST_API_KEY_FILE = "/root/.cpanel/datastore/cf_api"; |
| 10 | |
| 11 | my $stdin = <STDIN>; |
| 12 | chomp $stdin; |
| 13 | my ( $uid, $function, $data ) = split( / /, $stdin, 3 ); |
| 14 | |
| 15 | my $logger = Cpanel::Logger->new(); |
| 16 | |
| 17 | if ( $function eq 'getHostApiKey' ) { |
| 18 | my $hostApiKey = Cpanel::LoadFile::loadfile($HOST_API_KEY_FILE) or do { |
| 19 | $logger->info("Failed to load Host API key: $!"); |
| 20 | }; |
| 21 | print $hostApiKey; |
| 22 | exit(0); |
| 23 | } |
| 24 | else { |
| 25 | print "Invalid function specified to APIKey adminbin"; |
| 26 | exit(1); |
| 27 | } |
| 28 | |
| 29 | 1; #Ah, perl |