about summary refs log tree commit homepage
path: root/script/public-inbox-init
diff options
authorEric Wong <e@80x24.org>2020-12-20 06:30:11 +0000
committerEric Wong <e@80x24.org>2020-12-20 20:39:09 +0000
commit9fcce78e40b0a7c61797be2aff6c5afeb474568e (patch)
tree7fe8d8d4748c74cb332f76aa44746ade6959e913 /script/public-inbox-init
parentf1f61f2e7ab16fdf4441e12b4c3cfb98d7e3e3c5 (diff)
We'll try to avoid calling Cwd::abs_path and use
File::Spec->rel2abs instead, since abs_path will resolve
symlinks the user specified on the command-line.

Unfortunately, ->rel2abs still leaves "/.." and "/../"
uncollapsed, so we still need to fall back to Cwd::abs_path in
those cases.

While we are at it, we'll also resolve inboxdir from deep inside
v2 directories instead of misdetecting them as v1 bare git

In any case, stop matching directories by name and instead rely
on the unique combination of st_dev + st_ino on stat() as we
started doing in the extindex code.
Diffstat (limited to 'script/public-inbox-init')
1 files changed, 2 insertions, 8 deletions
diff --git a/script/public-inbox-init b/script/public-inbox-init
index c775eb31..eb605a51 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -138,10 +138,9 @@ close($fh) or die "failed to close $pi_config_tmp: $!\n";
 my $pfx = "publicinbox.$name";
 my @x = (qw/git config/, "--file=$pi_config_tmp");
-require File::Spec;
-$inboxdir = File::Spec->canonpath($inboxdir);
+die "`\\n' not allowed in `$inboxdir'\n" if index($inboxdir, "\n") >= 0;
-die "`\\n' not allowed in `$inboxdir'\n" if $inboxdir =~ /\n/s;
 if (-f "$inboxdir/inbox.lock") {
         if (!defined $version) {
                 $version = 2;
@@ -186,11 +185,6 @@ if ($skip_docdata) {
         $ibx->{-skip_docdata} = $skip_docdata;
 $ibx->init_inbox(0, $skip_epoch, $skip_artnum);
-require Cwd;
-my $tmp = Cwd::abs_path($inboxdir);
-defined($tmp) or die "failed to resolve $inboxdir: $!\n";
-$inboxdir = $tmp;
-die "`\\n' not allowed in `$inboxdir'\n" if $inboxdir =~ /\n/s;
 # needed for git prior to v2.1.0
 umask(0077) if defined $perm;