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