Skip to content

Commit

Permalink
pdf2john: allow symlinked usage by resolving script path
Browse files Browse the repository at this point in the history
This resolves the script's real path which is then used to populate
the perl module include path to the appropriate location of the
vendored lib folder.
This allows using pdf2john anywhere as a symlink, f.e. inside $PATH.

Fixes openwall#4089
  • Loading branch information
anthraxx committed Sep 3, 2019
1 parent 0c2c59c commit 97801c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion run/pdf2john.pl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
my $version = '8.99';

# add our 'lib' directory to the include list BEFORE 'use ExifTool'
use Cwd qw(realpath);
my $exeDir;
BEGIN {
# get exe directory
$exeDir = ($0 =~ /(.*)[\\\/]/) ? $1 : '.';
$exeDir = (realpath($0) =~ /(.*)[\\\/]/) ? $1 : '.';
# add lib directory at start of include path
unshift @INC, "$exeDir/lib";
# load or disable config file if specified
Expand Down

0 comments on commit 97801c5

Please sign in to comment.