aboutsummaryrefslogtreecommitdiff
path: root/examples/inspect
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-02-29 13:47:43 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-02-29 13:47:43 +0200
commitec86e9d545049b0dc83cc6c5b9c7c66f74915f7f (patch)
treef41451d824f2bdc25010324164def9e5a43b391d /examples/inspect
parent4771762b12e16954f94a1da6f49250413686811f (diff)
downloadping903-ec86e9d545049b0dc83cc6c5b9c7c66f74915f7f.tar.gz
ping903-ec86e9d545049b0dc83cc6c5b9c7c66f74915f7f.tar.bz2
Improve authorization support.
* examples/inspect: Special handling for "auth" objects. Print the rest of arrays as here documents. * src/json.c (json_object_filter): new function. * src/json.h (json_object_filter): new proto. * src/ping903.c (try_auth): Don't format HTTP responses if ret_val is NULL. (ept_ident, ept_config): Check individual object attributes using try_auth. Remove those not allowed by auth ACL. (cf_auth): Support for CF_SERIALIZE.
Diffstat (limited to 'examples/inspect')
-rwxr-xr-xexamples/inspect35
1 files changed, 21 insertions, 14 deletions
diff --git a/examples/inspect b/examples/inspect
index f9e21f2..7b10184 100755
--- a/examples/inspect
+++ b/examples/inspect
@@ -116,25 +116,32 @@ unless ($response->is_success) {
my $resp = JSON->new->decode($response->decoded_content);
foreach my $kw (grep { $_ ne 'ip-list' } sort keys %$resp) {
my $val = $resp->{$kw} or next;
- if (ref($val) eq 'ARRAY') {
- foreach my $sv (@$val) {
- print "$kw $sv\n";
+ if ($kw eq 'auth') {
+ my $delim = '';
+ foreach my $acl (@$val) {
+ print "${delim}auth $acl->{type} $acl->{method} $acl->{url}";
+ if (exists($acl->{'passwd-file'})) {
+ print " $acl->{'passwd-file'}";
+ if (exists($acl->{realm})) {
+ print " $acl->{realm}";
+ }
+ }
+ $delim = "\n";
}
} else {
print "$kw ";
- if (JSON::is_bool($val)) {
+
+ if (ref($val) eq 'ARRAY') {
+ print "<<EOF\n";
+ foreach my $ip (@$val) {
+ print " $ip\n";
+ }
+ print "EOF";
+ } elsif (JSON::is_bool($val)) {
print $val ? "on" : "off";
- } else {
+ } else {
print $val
}
- print "\n";
- }
-}
-
-if (@{$resp->{'ip-list'}}) {
- print "ip-list <<EOF\n";
- foreach my $ip (@{$resp->{'ip-list'}}) {
- print " $ip\n";
}
- print "EOF\n";
+ print "\n";
}

Return to:

Send suggestions and report system problems to the System administrator.