1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/usr/bin/perl
#
# An interesting command to run under k5start or krenew to perform various
# tests. It takes on the command-line a file into which to write, and into
# that file, it puts its PID, its current working directory, and its ticket
# cache. When it gets a HUP or INT signal, it writes into that file. When it
# gets a TERM signal, it writes into that file and exits.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2015, 2021 Russ Allbery <eagle@eyrie.org>
# Copyright 2008-2009, 2011-2012
# The Board of Trustees of the Leland Stanford Junior University
#
# SPDX-License-Identifier: MIT
use Cwd;
$| = 1;
$SIG{HUP} = sub { print OUT "got SIGHUP\n" };
$SIG{INT} = sub { print OUT "got SIGINT\n" };
$SIG{QUIT} = sub { print OUT "got SIGQUIT\n"; exit 0 };
$SIG{TERM} = sub { print OUT "got SIGTERM\n"; exit 0 };
print "Starting\n";
my $file = shift;
open (OUT, '>', $file) or die "Cannot write to $file: $!\n";
OUT->autoflush (1);
# Make sure that the ticket cache exists and is non-zero. If so, report its
# value to standard output; otherwise, report the empty string. Either way,
# report the current working directory.
my $cache = '';
if ($ENV{KRB5CCNAME}) {
$path = $ENV{KRB5CCNAME};
$path =~ s/^FILE://;
if (-s $path) {
$cache = $ENV{KRB5CCNAME};
}
}
print OUT "$$\n", getcwd, "\n", $cache, "\n";
sleep 1000 while 1;
|