* Several improvements to restore: cancel now reports the correct
[BackupPC.git] / lib / BackupPC / Lib.pm
index 0da9356..43870b8 100644 (file)
@@ -29,7 +29,7 @@
 #
 #========================================================================
 #
-# Version 2.0.0beta2, released 13 Apr 2003.
+# Version 2.0.0beta3, released 1 Jun 2003.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -52,13 +52,13 @@ use Digest::MD5;
 sub new
 {
     my $class = shift;
-    my($topDir, $installDir) = @_;
+    my($topDir, $installDir, $noUserCheck) = @_;
 
     my $bpc = bless {
         TopDir  => $topDir || '/data/BackupPC',
         BinDir  => $installDir || '/usr/local/BackupPC',
         LibDir  => $installDir || '/usr/local/BackupPC',
-        Version => '2.0.0beta2',
+        Version => '2.0.0beta3',
         BackupFields => [qw(
                     num type startTime endTime
                     nFiles size nFilesExist sizeExist nFilesNew sizeNew
@@ -86,7 +86,8 @@ sub new
     #
     # Verify we are running as the correct user
     #
-    if ( $bpc->{Conf}{BackupPCUserVerify}
+    if ( !$noUserCheck
+           && $bpc->{Conf}{BackupPCUserVerify}
            && $> != (my $uid = (getpwnam($bpc->{Conf}{BackupPCUser}))[2]) ) {
        print("Wrong user: my userid is $>, instead of $uid"
            . " ($bpc->{Conf}{BackupPCUser})\n");
@@ -1003,7 +1004,7 @@ sub cmdVarSubstitute
         $arg =~ s{\$(\w+)(\+?)}{
             exists($vars->{$1}) && ref($vars->{$1}) ne "ARRAY"
                 ? ($2 eq "+" ? $bpc->shellEscape($vars->{$1}) : $vars->{$1})
-                : "\$$1"
+                : "\$$1$2"
         }eg;
         #
         # Now replicate any array arguments; this just works for just one
@@ -1047,7 +1048,7 @@ sub cmdExecOrEval
        print("cmdExecOrEval: about to exec ",
              $bpc->execCmd2ShellCmd(@$cmd), "\n")
                        if ( $bpc->{verbose} );
-        exec(@$cmd);
+        exec(map { m/(.*)/ } @$cmd);           # untaint
         print(STDERR "Exec failed for @$cmd\n");
         exit(1);
     }
@@ -1101,7 +1102,7 @@ sub cmdSystemOrEval
            #
             close(STDERR);
            open(STDERR, ">&STDOUT");
-           exec(@$cmd);
+           exec(map { m/(.*)/ } @$cmd);                # untaint
             print("Exec of @$cmd failed\n");
             exit(1);
        }