Debian Codegraph @

debian/patches/inncheck

raw
1 --- a/samples/inncheck
2 +++ b/samples/inncheck
3 @@ -99,16 +99,16 @@ $newsgroup = 'news';
4 ## The modes of the config files we can check.
5 %modes = (
6 'active', 0644,
7 - 'control.ctl', 0440,
8 - 'expire.ctl', 0440,
9 - 'hosts.nntp', 0440,
10 - 'inn.conf', 0444,
11 - 'moderators', 0444,
12 - 'newsfeeds', 0444,
13 - 'overview.fmt', 0444,
14 - 'nnrp.access', 0440,
15 - 'nntpsend.ctl', 0440,
16 - 'passwd.nntp', 0440
17 + 'control.ctl', 0644,
18 + 'expire.ctl', 0644,
19 + 'hosts.nntp', 0640,
20 + 'inn.conf', 0644,
21 + 'moderators', 0644,
22 + 'newsfeeds', 0644,
23 + 'overview.fmt', 0644,
24 + 'nnrp.access', 0640,
25 + 'nntpsend.ctl', 0644,
26 + 'passwd.nntp', 0640
27 );
28
29
30 @@ -743,6 +743,22 @@ checkperm
31 die "Internal error, undefined mode in perm from ", (caller(0))[2], "\n"
32 if !defined $m;
33
34 + # system files are usually owned by root (or news if suid or sgid)
35 + if ($f !~ m#^/(?:run|var)/#) {
36 + $u = 'root';
37 + $g = $m & 06000 ? 'news' : 'root';
38 + }
39 + # if they are not world readable then they must be owned by group news
40 + if ($f =~ m#^/etc/#) {
41 + $g = $m & 004 ? 'root' : $newsgroup;
42 + }
43 +
44 + # binaries should be 755 (or x744 if suid or sgid)
45 + if ($m & 0100 and not -d $f) {
46 + $m |= $m & 06000 ? 0744 : 0755;
47 + }
48 +
49 +
50 if ( ! -e $f ) {
51 print "$pfx$f:0: missing\n";
52 }
53 @@ -804,7 +820,7 @@ intersect
54 }
55
56 @directories = (
57 - 'archive', 'badnews', 'batchdir', 'ctlprogs', 'most_logs', 'newsbin',
58 + 'archive', 'badnews', 'batchdir', 'ctlprogs', 'most_logs', # 'newsbin',
59 'newslib', 'oldlogs', 'rnewsprogs', 'spooltemp', 'spool', 'spoolnews'
60 );
61 @control_scripts = (
62 @@ -812,7 +828,7 @@ intersect
63 'sendme', 'sendsys', 'senduuname', 'version'
64 );
65 @rnews_programs = (
66 - 'c7unbatch', 'decode', 'encode'
67 + 'decode', 'encode', 'gunbatch', 'xunbatch'
68 );
69 @newsbin_public = (
70 'archive', 'batcher', 'buffchan', 'convdate', 'cvtbatch', 'expire',
71 @@ -822,24 +838,23 @@ intersect
72 );
73 @newsbin_private = (
74 'ctlinnd', 'expirerm', 'inncheck', 'innstat', 'innwatch',
75 - 'makegroup', 'news.daily', 'nntpsend', 'scanlogs', 'sendbatch',
76 - 'tally.control', 'tally.unwanted', 'updatemods', 'writelog'
77 + 'news.daily', 'nntpsend', 'scanlogs', 'sendbatch',
78 + 'tally.control', 'tally.unwanted', 'writelog'
79 );
80 @newslib_private = (
81 'send-ihave', 'send-nntp', 'send-uucp'
82 );
83 @newslib_private_read = (
84 - 'innlog.pl'
85 );
86
87 ## The modes for the various programs.
88 %prog_modes = (
89 - 'inews', 02555,
90 - 'innd', 0555,
91 - 'newsboot', 0550,
92 - 'nnrpd', 0555,
93 - 'parsectl', 0550,
94 - 'rnews', 02555
95 + 'inews', 02755,
96 + 'innd', 0755,
97 + 'newsboot', 0755,
98 + 'nnrpd', 0755,
99 + 'parsectl', 0755,
100 + 'rnews', 02755
101 );
102
103 ## Check the permissions of nearly every file in an INN installation.
104 @@ -852,37 +867,37 @@ check_all_perms
105 local ($newslib) = $paths{'newslib'};
106
107 foreach ( @directories ) {
108 - &checkperm($paths{$_}, 0775);
109 + &checkperm($paths{$_}, $_ =~ /ctlprogs|oldlogs|rnewsprogs/ ? 0755 : 0775);
110 }
111 - &checkperm($paths{'innddir'}, 0770);
112 + &checkperm($paths{'innddir'}, 0755);
113 foreach ( keys %prog_modes ) {
114 - &checkperm($paths{$_}, $prog_modes{$_});
115 + &checkperm($paths{$_}, $prog_modes{$_}, 'root');
116 }
117 - &checkperm($paths{'inndstart'}, 0555, 'root', 'bin');
118 + &checkperm($paths{'inndstart'}, 04754, 'root', 'news');
119 foreach ( keys %paths ) {
120 &checkperm($paths{$_}, $modes{$_})
121 if defined $modes{$_};
122 }
123 - &checkperm($paths{'history'}, 0644);
124 - &checkperm($paths{'history'} . ".dir", 0644);
125 - &checkperm($paths{'history'} . ".pag", 0644);
126 + &checkperm($paths{'history'}, 0664);
127 + &checkperm($paths{'history'} . ".dir", 0664);
128 + &checkperm($paths{'history'} . ".pag", 0664);
129 foreach ( @newslib_private ) {
130 - &checkperm("$newslib/$_", 0550);
131 + &checkperm("/etc/news/scripts/$_", 0755);
132 }
133 foreach ( @newslib_private_read ) {
134 - &checkperm("$newslib/$_", 0440);
135 + &checkperm("$newsbin/$_", 0644, 'root', 'root');
136 }
137 foreach ( @newsbin_private ) {
138 - &checkperm("$newsbin/$_", 0550);
139 + &checkperm("$newsbin/$_", 0755, 'root', 'root');
140 }
141 foreach ( @newsbin_public ) {
142 - &checkperm("$newsbin/$_", 0555);
143 + &checkperm("$newsbin/$_", 0755, 'root', 'root');
144 }
145 foreach ( @control_scripts ) {
146 - &checkperm("$ctlprogs/$_", 0550);
147 + &checkperm("$ctlprogs/$_", 0755);
148 }
149 foreach ( @rnews_programs ) {
150 - &checkperm("$rnewsprogs/$_", 0555);
151 + &checkperm("$rnewsprogs/$_", 0755);
152 }
153
154 ## Also make sure that @rnews_programs are the *only* programs in there;
155 @@ -999,8 +1014,15 @@ action: foreach $workfile ( @todo ) {
156 print "$pfx$workfile:0: can't open $!\n";
157 next action;
158 }
159 - &checkperm($file, $modes{$workfile})
160 - if $noperms == 0 && !$perms && defined $modes{$workfile};
161 + if ($noperms == 0 && !$perms && defined $modes{$workfile}) {
162 + if ($workfile eq 'active') {
163 + &checkperm($file, $modes{$workfile});
164 + } elsif (grep($workfile eq $_, qw(passwd.nntp nnrp.access hosts.nntp))) {
165 + &checkperm($file, $modes{$workfile}, 'root', 'news');
166 + } else {
167 + &checkperm($file, $modes{$workfile}, 'root', 'root');
168 + }
169 + }
170 $line = 0;
171 eval "&$checklist{$workfile}" || warn "$@";
172 close(IN);