perl -MWin32::TieRegistry=Delimiter,/ -e"$Registry->{'CUser/Software/Microsoft/Command Processor//AutoRun'}= 'agency -t 12h';" #### @rem = '--*-Perl-*-- @echo off if "%OS%" == "Windows_NT" goto WinNT perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT perl -x -S %0 %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto endofperl @rem '; #!/usr/bin/perl -w #line 15 use strict; # Since perl last read DATA w/o binmode, this value could be a byte or few # too high. So we call tell() before reading from ... (see below) my $pos= tell( DATA ) or die "Can't tell(DATA): $!\n"; my $label= .'' or die "Found no label in DATA\n"; my @env= ; my( $pid )= map { $ENV{$1}= $2 if /(\w+)=([^\r\n]*)/; /PID=(\d+)/; } @env; if( $pid && kill 0, $pid ) { for my $line ( qx< ssh-add -l > ) { if( $line =~ /^\d/ ) { printf "Using %s\n", ( split ' ', $line )[2]; } else { print $line; } } exit; } @env= grep { if( s{(\w+)=([^;]+);.*}{set $1=$2\r} ) { $ENV{$1}= $2; 1; } else { 0; } } qx< ssh-agent @ARGV >; system( "ssh-add" ); open DATA, "+<", $0 or die "Can't re-open $0: $!\n"; binmode DATA or warn "re-binmode DATA failed: $!\n"; # ...(see above) Seek to the start of the ":endofperl" label, or perhaps a few # bytes past the start of it due to non-binmode reading of DATA by perl... seek( DATA, $pos, 0 ) or die "Can't seek DATA: $!\n"; # ... read to the end of the label /in binmode/ so tell() will be exact. $label= ; seek( DATA, 0, 1 ) or die "Can't re-seek DATA: $!\n"; print DATA @env; $pos= tell( DATA ) or die "Can't re-tell(DATA): $!\n"; truncate( DATA, $pos ) or die "Can't truncate DATA: $!\n"; __END__ :endofperl #### # Persist our ssh-agent settings to each shell we open: ssh_env="$HOME/.ssh/agent.env" if [ -f "$ssh_env" ]; then . "$ssh_env" if kill -CONT $SSH_AGENT_PID 2>/dev/null; then ssh-add -l | awk '{ if($5){ print }else{ print "Using",$3 } }' else rm "$ssh_env" fi fi if [ ! -f "$ssh_env" ]; then echo "Restarting ssh-agent; run ssh-add." > "$ssh_env" chmod 600 "$ssh_env" if [ -s "$ssh_env" ]; then mv "$ssh_env" "$ssh_env.$$" echo "Somebody raced a hack into $ssh_env.$$ !" 1>&2 else ssh-agent | sed -e 's/^echo/#echo/' >> "$ssh_env" . "$ssh_env" fi fi