--- ./BBS/BBS.cgi.org Mon Sep 20 10:21:37 1999
+++ ./BBS/BBS.cgi Sun Sep 26 10:15:26 1999
@@ -4,8 +4,8 @@
BBS.cgi - a sample BBS script for the CGI_Board class library
- Version: 0.66 (beta test version)
- Date: Mon Sep 20 10:14:49 JST 1999
+ Version: 0.66 + no symlink patch 0.01 (beta test version)
+ Date: Sun Sep 26 07:36:03 JST 1999
=head1 Copyright
@@ -20,7 +20,7 @@
#==============================================================================
# Location of CGI_Board
-my $Version_of_CGI_Board = "0.66";
+my $Version_of_CGI_Board = "0.66+NoSymlink0.01";
my $URL_of_CGI_Board = "http://www.math.tohoku.ac.jp/~kuroki/pub/CGI_Board/";
my $Link_to_CGI_Board
= qq!CGI_Board $Version_of_CGI_Board!;
@@ -69,7 +69,7 @@
# Load modules
#
-use CGI_Board;
+use CGI_Board qw( readlink_hack symlink_hack );
use CGI_Board::Misc qw(
check_access check_satisfy check_allow check_require
check_html
@@ -1741,7 +1741,7 @@
chmod $config_perm, $config_file;
my $link = $board_dir . "/" . $board_id . $board_suffix;
- if (-l $link && $config_value{'suffix'} ne $board_suffix) {
+ if (-e $link && $config_value{'suffix'} ne $board_suffix) {
my $linknew = $board_dir . "/" . $board_id . $config_value{'suffix'};
if (-f $linknew) {
print_and_die("$linknew already exists ",
@@ -1812,6 +1812,8 @@
$board->print_htmldata(\*FILE);
close FILE;
chmod $Perm_Board, $update_file;
+ symlink_hack($update_file, $link);
+ chmod $Perm_Board, $link;
fileunlock($link);
return 1;
@@ -1835,16 +1837,16 @@
filelock($link) or print_and_die("$link: locked");
- if (-e $link && ! -l $link) {
- fileunlock($link), print_and_die("$link: not symbolic link");
- }
- if (-e $log_link && ! -l $log_link) {
- fileunlock($link), print_and_die("$log_link: not symbolic link");
- }
- if (-l $link) {
+# if (-e $link && ! -l $link) {
+# fileunlock($link), print_and_die("$link: not symbolic link");
+# }
+# if (-e $log_link && ! -l $log_link) {
+# fileunlock($link), print_and_die("$log_link: not symbolic link");
+# }
+ if (-e $link) {
unlink $link or fileunlock($link), print_and_die("$link: $!");
}
- if (-l $log_link) {
+ if (-e $log_link) {
unlink $log_link or fileunlock($link), print_and_die("$log_link: $!");
}
@@ -1853,14 +1855,15 @@
my ($oldseq) = ( $previous =~ /^$board_id([0-9]*)/ );
my $filename = $board_id . $seq . $board_suffix;
- symlink $filename, $link
+ symlink_hack($filename, $link)
or fileunlock($link), print_and_die("$filename: $!");
+ chmod $Perm_Board, $link;
# my $bin = $board_dir . "/" . $board_id . ".bin";
-# if (-l $bin) {
+# if (-e $bin) {
# unlink $bin or fileunlock($link), print_and_die("$bin: $!");
# }
-# symlink $board_id . $board_suffix, $bin
+# symlink_hack($board_id . $board_suffix, $bin)
# or fileunlock($link), print_and_die("$bin: $!");
my $log_filename = $boardlog_id . $seq . $boardlog_suffix;
@@ -1873,8 +1876,9 @@
$boardlog->print_htmldata(\*LOG);
close LOG;
}
- symlink $log_filename, $log_link
+ symlink_hack($log_filename, $log_link)
or fileunlock($link), print_and_die("$log_link: $!");
+ chmod $Perm_Boardlog, $log_link;
fileunlock($link);
@@ -1898,9 +1902,9 @@
my $link = $board_dir . "/" . $board_id . $board_suffix;
filelock($link) or print_and_die("$link: locked");
- if (-e $link && ! -l $link) {
- fileunlock($link), print_and_die("$link: not symbolic link");
- }
+# if (-e $link && ! -l $link) {
+# fileunlock($link), print_and_die("$link: not symbolic link");
+# }
if (-l $link) {
unlink $link or fileunlock($link), print_and_die("$link: $!");
}
@@ -1914,6 +1918,8 @@
open FILE, ">>$file" or fileunlock($link), print_and_die("$file");
print FILE "";
close FILE;
+ symlink_hack($file, $link);
+ chmod $Perm_Board, $link;
fileunlock($link);
update_current_board_style();
@@ -2626,6 +2632,10 @@
open LOG, ">$log_file" or fileunlock($link), print_and_die("$log_file: $!");
$boardlog->print_htmldata(\*LOG);
close LOG;
+ my $log_link = $boardlog_dir . "/" . $board_id . $boardlog_suffix;
+ symlink_hack($log_file, $log_link)
+ or print_and_die("$log_file, $log_link: $!");
+ chmod $Perm_Boardlog, $log_link;
fileunlock($link);
my (@next, $next);
@@ -2875,6 +2885,10 @@
open LOG, ">$log_file" or fileunlock($link), print_and_die("$log_file: $!");
$boardlog->print_htmldata(\*LOG);
close LOG;
+ my $log_link = $boardlog_dir . "/" . $board_id . $boardlog_suffix;
+ symlink_hack($log_file, $log_link)
+ or print_and_die("$log_file, $log_link: $!");
+ chmod $Perm_Boardlog, $log_link;
fileunlock($link);
my (@next, $next);
@@ -2939,7 +2953,7 @@
sub board_edit_form {
my $filename = $cgi_value{'board_filename'};
my $link = $board_dir . "/" . $board_id . $board_suffix;
- $filename = readlink $link if $filename eq "";
+ $filename = readlink_hack($link) if $filename eq "";
my $file = $board_dir . "/" . $filename;
my ($seq, $suffix) = ( $filename =~ /^\Q$board_id\E([0-9]+)(.*)$/ );
my $log_filename = $board_id . $seq . $boardlog_suffix;
@@ -3476,10 +3490,10 @@
}
if (! defined $filename || $filename =~ /^\s*$/) {
my $link = $board_dir . "/" . $board_id . $board_suffix;
- unless (-l $link) {
- print_and_die("$link: not symbolic link");
- }
- $filename = readlink $link;
+# unless (-l $link) {
+# print_and_die("$link: not symbolic link");
+# }
+ $filename = readlink_hack($link);
}
my ($seq) = ($filename =~ /^\Q$board_id\E([0-9]+)\./);
@@ -3554,10 +3568,10 @@
}
if (! defined $filename || $filename =~ /^\s*$/) {
my $link = $board_dir . "/" . $board_id . $board_suffix;
- unless (-l $link) {
- print_and_die("$link: not symbolic link");
- }
- $filename = readlink $link;
+# unless (-l $link) {
+# print_and_die("$link: not symbolic link");
+# }
+ $filename = readlink_hack($link);
}
my $file = $board_dir . "/" . $filename;
unless (-f $file) {
@@ -3739,10 +3753,10 @@
}
if (! defined $filename || $filename =~ /^\s*$/) {
my $link = $board_dir . "/" . $board_id . $board_suffix;
- unless (-l $link) {
- print_and_die("$link: not symbolic link");
- }
- $filename = readlink $link;
+# unless (-l $link) {
+# print_and_die("$link: not symbolic link");
+# }
+ $filename = readlink_hack($link);
}
my $file = $board_dir . "/" . $filename;
unless (-f $file) {
--- ./CGI_Board/Misc.pm.org Sun Sep 26 08:47:42 1999
+++ ./CGI_Board/Misc.pm Sun Sep 26 08:48:40 1999
@@ -16,8 +16,8 @@
Misc.pm - Perl5 library of miscellaneous functions used in CGI_Board.pm
- Version: 0.64 (beta test version)
- Date: Sun Sep 26 08:40:13 JST 1999
+ Version: 0.64 + no symlink patch 0.01 (beta test version)
+ Date: Sun Sep 26 08:49:21 JST 1999
=cut
@@ -1193,7 +1193,7 @@
$suffix = $default_lock_suffix unless defined $suffix;
$retry = 0 unless defined $retry;
$period = 1 unless defined $period;
- while (!symlink("LOCK", "$file$suffix")) {
+ while (!mkdir "$file$suffix", 0777) {
if (--$retry < 0) {
$Error = "filelock: $file is locked.";
return undef;
@@ -1212,7 +1212,7 @@
sub fileunlock {
my ($file, $suffix) = @_;
$suffix = $default_lock_suffix unless defined $suffix;
- unlink "$file$suffix" or die "$file$suffix: $!";
+ rmdir "$file$suffix" or die "$file$suffix: $!";
return 1;
}
--- ./CGI_Board.pm.org Sun Sep 26 05:25:51 1999
+++ ./CGI_Board.pm Tue Sep 28 04:23:47 1999
@@ -16,8 +16,8 @@
CGI_Board.pm - Perl 5 module to handle CGI and Board
- Version: 0.47 (beta test version)
- Date: Sun Sep 26 05:24:03 JST 1999
+ Version: 0.47 + no symlink patch 0.02 (beta test version)
+ Date: Tue Sep 28 04:23:41 JST 1999
=head1 SYNOPSIS
@@ -1398,8 +1398,8 @@
my $link = $dir . "/" . $bid . $suffix;
my ($filename, $file, $oldfilename, $size, $seq, @boardfilename);
- if (-l $link) {
- $filename = readlink $link or fileunlock($link), die "$link: $!";
+ if (-e $link) {
+ $filename = readlink_hack($link) or fileunlock($link), die "$link: $!";
$size = -s $link;
if ($size == 0) {
($seq) = ( $filename =~ /^$bid([0-9]*)/ );
@@ -1420,7 +1420,7 @@
close FILE;
chmod $perm, $file;
unlink $link or fileunlock($link), die "$link: $!";
- symlink $filename, $link or fileunlock($link), die "$link: $!";
+ symlink_hack($filename, $link) or fileunlock($link), die "$link: $!";
}
return ("new", $filename, $oldfilename);
} else {
@@ -1442,7 +1442,7 @@
$filename = pop @boardfilename;
$oldfilename = pop @boardfilename;
if ($do_rotate) {
- symlink $filename, $link or fileunlock($link), die "$link: $!";
+ symlink_hack($filename, $link) or fileunlock($link), die "$link: $!";
}
return ("recovery", $filename, $oldfilename);
} else {
@@ -1453,7 +1453,7 @@
print FILE "";
close FILE;
chmod $perm, $file;
- symlink $filename, $link or fileunlock($link), die "$link: $!";
+ symlink_hack($filename, $link) or fileunlock($link), die "$link: $!";
}
return ("new", $filename);
}
@@ -1539,6 +1539,7 @@
$self->print_htmldata(\*FILE);
close FILE;
chmod $perm, $file;
+ symlink_hack($file, $link);
fileunlock($link);
@@ -1592,6 +1593,7 @@
$self->print_htmldata(\*FILE);
close FILE;
chmod $perm, $file;
+ symlink_hack($file, $link);
fileunlock($link);
@@ -1650,6 +1652,7 @@
$self->print_htmldata(\*FILE);
close FILE;
chmod $perm, $file;
+ symlink_hack($file, $link);
fileunlock($link);
@@ -1707,6 +1710,7 @@
$self->print_htmldata(\*FILE);
close FILE;
chmod $perm, $file;
+ symlink_hack($file, $link);
fileunlock($link);
@@ -1904,6 +1908,45 @@
my $self = shift;
my $verbose = shift;
print $self->extcode($self->sprint($verbose));
+}
+
+#==============================================================================
+
+use vars qw( @ISA @EXPORT );
+require Exporter;
+@ISA = qw( Exporter );
+
+@EXPORT = qw( readlink_hack symlink_hack );
+
+sub readlink_hack {
+ my ($file) = @_;
+ $file .= "./" . $file unless $file =~ m!^[./]!;
+ my ($dir, $filename) = ( $file =~ m!^(.*)/(.*?)$! );
+ my ($base, $suffix) = ( $filename =~ m!^(\w*)(.*)$! );
+ $base = $filename if $base eq "";
+ opendir DIR, $dir or die "$dir: $!";
+ $filename = (reverse sort grep /^\Q$base\E\d+\Q$suffix\E/, readdir DIR)[0];
+ closedir DIR;
+ return $filename;
+}
+
+sub symlink_hack {
+ my ($file, $link) = @_;
+ unless ($file =~ m!^/!) {
+ my ($dir) = ( $link =~ m!^(.*/)! );
+ $file = $dir . $file;
+ }
+ if (-r $file) {
+ open FILE, $file or die "$file: $!";
+ open LINK, ">$link" or die "$link: $!";
+ while () { print LINK }
+ close LINK;
+ close FILE;
+ } else {
+ open LINK, ">>$link" or die "$link: $!";
+ print LINK "";
+ close LINK;
+ }
}
#==============================================================================