]>
Commit | Line | Data |
---|---|---|
b6ac5609 | 1 | --- kdelibs/kio/misc/fileshareset.orig 2003-11-21 19:38:11.000000000 +0100 |
2 | +++ kdelibs/kio/misc/fileshareset 2003-11-21 19:41:50.000000000 +0100 | |
3 | @@ -80,15 +80,19 @@ | |
4 | $< = $>; | |
5 | @ARGV == 2 && ($cmd eq '--add' || $cmd eq '--remove') or error($usage); | |
6 | ||
7 | - verify_mntpoint($dir); | |
8 | - | |
9 | if ($cmd eq '--add') { | |
10 | - my @errs = map { eval { $_->add($dir) }; $@ } @exports; | |
11 | - grep { !$_ } @errs or error("already exported"); | |
12 | - } else { | |
13 | - my @errs = map { eval { $_->remove($dir) }; $@ } @exports; | |
14 | - grep { !$_ } @errs or error("not exported"); | |
15 | - } | |
16 | + verify_mntpoint($dir); | |
17 | + my @errs = map { eval { $_->add($dir) }; $@ } @exports; | |
18 | + grep { !$_ } @errs or error("already exported"); | |
19 | + } | |
20 | + elsif ($cmd eq '--remove') { | |
21 | + verify_mntpoint($dir, 1); | |
22 | + my @errs = map { eval { $_->remove($dir) }; $@ } @exports; | |
23 | + grep { !$_ } @errs or error("not exported"); | |
24 | + } | |
25 | + else { | |
26 | + die("42?"); | |
27 | + } | |
28 | foreach my $export (@exports) { | |
29 | $export->write; | |
30 | $export->update_server; | |
31 | @@ -101,13 +105,24 @@ | |
32 | sub own { $uid == 0 || (stat($_[0]))[4] == $uid } | |
33 | ||
34 | sub verify_mntpoint { | |
35 | - local ($_) = @_; | |
36 | + $_ = shift; | |
37 | + my $mercy = shift; # true if dir doesn't have to exist | |
38 | my $ok = 1; | |
39 | - $ok &&= m|^/|; | |
fcedb2cc | 40 | - $ok &&= !m|/\.\./|; |
b6ac5609 | 41 | - $ok &&= !m|[\0\n\r]|; |
42 | - $ok &&= -d $_; | |
43 | - $ok &&= own($_); | |
44 | + $ok &&= length $_; | |
45 | + $ok &&= m#^/#; | |
fcedb2cc | 46 | + $ok &&= !m#/\.\./#; |
b6ac5609 | 47 | + $ok &&= !m#[\0\n\r]#; |
48 | + if ($ok && $mercy && !-d && m#^/#) { | |
49 | + my $tmp = $_; | |
50 | + $tmp =~ s#/*$##; | |
51 | + 1 while $tmp =~ s#/[^/]*$## && length $tmp && !-d $tmp; | |
52 | + $ok &&= length $tmp; | |
53 | + $ok &&= own($tmp); | |
54 | + } | |
55 | + else { | |
56 | + $ok &&= -d; | |
57 | + $ok &&= own($_); | |
58 | + } | |
59 | $ok or error("invalid mount point"); | |
60 | } | |
61 | ||
62 | @@ -276,16 +291,16 @@ | |
63 | my ($s, @l); | |
64 | local *F; | |
65 | open F, $conf_file; | |
66 | - local $_; | |
67 | while (<F>) { | |
68 | - if (/^\s*\[.*\]/ || eof F) { | |
69 | - #- first line in the category | |
70 | - my ($label) = $s =~ /^\s*\[(.*)\]/; | |
71 | - my ($mntpoint) = $s =~ /^\s*path\s*=\s*(.*)/m; | |
72 | - push @l, { mntpoint => $mntpoint, raw => $s, label => $label }; | |
73 | - $s = ''; | |
74 | - } | |
75 | - $s .= $_; | |
76 | + if (/^\s*\[.*\]/ || eof F) { | |
77 | + #- first line in the category | |
78 | + my ($label) = $s =~ /^\s*\[(.*)\]/; | |
79 | + my ($mntpoint) = $s =~ /^\s*path\s*=\s*(.*)/m; | |
80 | + $s .= $_ if eof F; | |
81 | + push @l, { mntpoint => $mntpoint, raw => $s, label => $label }; | |
82 | + $s = ''; | |
83 | + } | |
84 | + $s .= $_; | |
85 | } | |
86 | bless \@l, 'smb_exports'; | |
87 | } | |
88 | @@ -387,3 +402,5 @@ | |
89 | exit 0; | |
90 | } | |
91 | } | |
92 | + | |
93 | +# vim: ts=4 sw=4 noet |