summaryrefslogtreecommitdiff
path: root/misc/mc/files/patch-vfs-extfs-apt.in
blob: e5857faaa26ec82def6cb7152aad7ea8ac2eab4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
--- vfs/extfs/apt.in.orig	Tue Dec 24 12:33:46 2002
+++ vfs/extfs/apt.in	Fri Sep 10 16:09:30 2004
@@ -6,6 +6,12 @@
 #
 # apt
 
+sub quote {
+    $_ = shift(@_);
+    s/([^\w\/.+-])/\\$1/g;
+    return($_);
+}
+
 sub bt
 {
     my ($dt) = @_;
@@ -229,14 +235,16 @@
 sub copyout
 {
     my($archive,$filename) = @_;
+    my $qarchive = quote($archive);
+    my $qfilename = quote($filename);
     if( $archive eq 'CHECK' ) {
-       system("apt-get -q check > $filename");
+       system("apt-get -q check > $qfilename");
     } elsif( $archive eq 'AVAILABLE' ) {
-       system("apt-cache dumpavail > $filename");
+       system("apt-cache dumpavail > $qfilename");
     } elsif( $archive eq 'STATS' ) {
-       system("apt-cache stats > $filename");
+       system("apt-cache stats > $qfilename");
     } elsif( $archive eq 'CONFIG' ) {
-       system("(apt-config dump 2>&1) > $filename");
+       system("(apt-config dump 2>&1) > $qfilename");
     } elsif( $archive eq 'UPDATE' ) {
        open O, ">$filename";
        print O $pressupdate;
@@ -246,12 +254,12 @@
        print O $pressupgrade;
        close O;
     } elsif( $archive eq 'apt.conf' ) {
-       system("cp /etc/apt/apt.conf $filename");
+       system("cp /etc/apt/apt.conf $qfilename");
     } elsif( $archive eq 'sources.list' ) {
-       system("cp /etc/apt/sources.list $filename");
+       system("cp /etc/apt/sources.list $qfilename");
     } elsif( $archive =~ /^CACHE\// ) {
        $archive =~ s%^CACHE/%/var/cache/apt/archives/%;
-       system("cp $archive $filename");
+       system("cp $qarchive $qfilename");
     } else {
        open O, ">$filename";
        print O $archive, "\n";
@@ -262,15 +270,17 @@
 sub copyin
 {
     my($archive,$filename) = @_;
+    my $qarchive = quote($archive);
+    my $qfilename = quote($filename);
     if( $archive =~ /\.deb$/ ) {
-       system("dpkg -i $filename>/dev/null");
+       system("dpkg -i $qfilename>/dev/null");
     } elsif( $archive eq 'apt.conf' ) {
-       system("cp $filename /etc/apt/apt.conf");
+       system("cp $qfilename /etc/apt/apt.conf");
     } elsif( $archive eq 'sources.list' ) {
-       system("cp $filename /etc/apt/sources.list");
+       system("cp $qfilename /etc/apt/sources.list");
     } elsif( $archive =~ /^CACHE\// ) {
-       $archive =~ s%^CACHE/%/var/cache/apt/archives/%;
-       system("cp $filename $archive");
+       $qarchive =~ s%^CACHE/%/var/cache/apt/archives/%;
+       system("cp $qfilename $qarchive");
     } else {
        die "extfs: cannot create regular file \`$archive\': Permission denied\n";
     }
@@ -293,19 +303,20 @@
 sub rm
 {
     my($archive) = @_;
+    my $qarchive = quote($archive);
     if( $archive =~ /^CACHE\// ) {
-       $archive =~ s%^CACHE/%/var/cache/apt/archives/%;
-       system("rm -f $archive");
+       $qarchive =~ s%^CACHE/%/var/cache/apt/archives/%;
+       system("rm -f $qarchive");
     } elsif( $archive eq 'apt.conf' ) {
        system("rm -f /etc/apt/apt.conf");
     } elsif( $archive eq 'sources.list' ) {
        system("rm -f /etc/apt/sources.list");
     } elsif( $archive =~ /\.debd?$/ ) {
        # uncommented and changed to use dpkg - alpha
-       my $name = $archive;
-       $name =~ s%.*/%%g;
-       $name =~ s%_.*%%g;
-       system("dpkg --remove $name >/dev/null");
+       my $qname = $qarchive;
+       $qname =~ s%.*/%%g;
+       $qname =~ s%_.*%%g;
+       system("dpkg --remove $qname >/dev/null");
        die("extfs: $archive: Operation not permitted\n") if $? != 0;
     } else {
        die "extfs: $archive: Operation not permitted\n";