From 0a07a7639c85709a565ff1567d90e00e240e9571 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Fri, 20 Jul 2007 11:27:13 -0700 Subject: [PATCH] Add support for octal, hexadecimal in restore.pl script. --- restore.pl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/restore.pl b/restore.pl index 309fb73..ad1f594 100755 --- a/restore.pl +++ b/restore.pl @@ -140,6 +140,15 @@ sub load_ref { # iterate_objects is a helper function used to iterate over the set of object # references that contain the file data for a regular file. +sub parse_int { + my $str = shift; + if ($str =~ /^0/) { + return oct($str); + } else { + return $str + 0; + } +} + sub uri_decode { my $str = shift; $str =~ s/%([0-9a-f]{2})/chr(hex($1))/ge; @@ -197,6 +206,8 @@ sub unpack_file { die "File $name is missing checksum or size"; } + $info{size} = parse_int($info{size}); + # Open the file to be recreated. The data will be written out by the call # to iterate_objects. open FILE, ">", "$DEST_DIR/$name" @@ -274,17 +285,17 @@ sub process_file { my $gid = -1; if (defined $info{user}) { my @items = split /\s/, $info{user}; - $uid = $items[0] + 0 if exists $items[0]; + $uid = parse_int($items[0]) if exists $items[0]; } if (defined $info{group}) { my @items = split /\s/, $info{group}; - $gid = $items[0] + 0 if exists $items[0]; + $gid = parse_int($items[0]) if exists $items[0]; } chown $uid, $gid, $dest or warn "Unable to change ownership for $dest"; if (defined $info{mode}) { - my $mode = $info{mode}; + my $mode = parse_int($info{mode}); chmod $mode, $dest or warn "Unable to change permissions for $dest"; } -- 2.20.1