#!/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 # Copyright 2015, 2021 Russ Allbery # 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;