commit e5de9347f708792a7ea7b293f3539b3ae34268d8 from: jrmu date: Tue Mar 07 15:46:26 2023 UTC Make writes safer with backups commit - 0c4b2feaac7334c0ef11355e6871b0396579ed07 commit + e5de9347f708792a7ea7b293f3539b3ae34268d8 blob - 593d7626fde38c45f380c5ebda7690fe4b17e0cf blob + d5722b6ec40404ce17a8e4a369b0bb6935abe7e6 --- botnow +++ botnow @@ -39,7 +39,7 @@ sub readstr { sub writefile { my ($filename, $str) = @_; my $date = date(); - copy($filename, basename($filename).date()) or die "Could not make backup of $filename"; + copy($filename, "/home/botnow/".basename($filename).date()) or die "Could not make backup of $filename"; open(my $fh, '>', "$filename") or die "Could not write to $filename"; print $fh $str; close $fh; @@ -82,6 +82,7 @@ return "true"; # Path to configuration file my $confpath = "botnow.conf"; +my $homepath = "/home/botnow"; # Configuration variables will be stored in key => value pairs our %conf; @@ -197,6 +198,7 @@ my $expires = $conf{expires}; unveil("./", "r") or die "Unable to unveil $!"; unveil("$confpath", "r") or die "Unable to unveil $!"; +unveil("$homepath", "rwc") or die "Unable to unveil $!"; unveil() or die "Unable to lock unveil $!"; #dns and inet for sockets, proc and exec for figlet