Skip to contentSkip to conversation

[Fwd: Bug#231561: setfiles ignores patterns beginning with a meta-character]

Fwd: Bug#231561: setfiles ignores patterns beginning with a meta-character Colin Walters 2 participants 2 messages Feb 14, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,

Here's a patch I got from a Debian user for setfiles. It makes sense to me. What do you think?

Package: policycoreutils
Version: 1.4-2.rb1
Severity: normal
Tags: patch

get_stem_from_spec() assumes that that the first character of a path pattern is not a regexp meta-character. If it is, it may return a wrong stem, preventing a match. Patch below.

For example, this pattern did not match correctly:

(/usr(/local|/X11R6)?)?/lib/lib[^/]*\.so.* system_u:object_r:shlib_t

setfiles/setfiles.c +2 -2
diff -ruN policycoreutils-1.4/setfiles/setfiles.c policycoreutils-1.4+/setfiles/setfiles.c
@@ -121,13 +121,13 @@
  * if there is no identifiable stem */
 int get_stem_from_spec(const char * const buf)
 {
-	const char *tmp = strchr(buf + 1, '/');
+	const char *tmp = strchr(buf, '/');
 	const char *ind;
 
 	if(!tmp)
 		return 0;
 
-	for(ind = buf + 1; ind < tmp; ind++)
+	for(ind = buf; ind < tmp; ind++)
 	{
 		if(strchr(regex_chars, (int)*ind))
 			return 0;

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux hoss 2.6.0-h3 #3 Tue Jan 6 20:03:18 CET 2004 i686
Locale: LANG=de_AT@euro, LC_CTYPE=de_AT

Versions of packages policycoreutils depends on:

ii  expect                      5.39.0-1     A program that "talks" to other pr
ii  libc6                       2.3.2.ds1-11 GNU C Library: Shared libraries an
ii  libpam0g                    0.76-15      Pluggable Authentication Modules l
ii  libselinux1                 1.4-0.1      SELinux shared libraries

-- no debconf information

#1 lore raw
Quoted 4 lines · Colin Walters

Hi,

Here's a patch I got from a Debian user for setfiles. It makes sense to me. What do you think?

The first change means that "tmp - buf" will always be 0, therefore no stem will ever be recognised. A quick test of labeling /lib on one of my machines showed this as making setfiles take 25.8s on my laptop instead of 0.8s.

The second change means that the first character regular expression will be found thus giving correct behavior. Make the second change not the first and the user should be happy.

* if there is no identifiable stem */
int get_stem_from_spec(const char * const buf)
{
- const char *tmp = strchr(buf + 1, '/');

+       const char *tmp = strchr(buf, '/');
        const char *ind;
 
        if(!tmp)
                return 0;

- for(ind = buf + 1; ind < tmp; ind++)
+ for(ind = buf; ind < tmp; ind++)

        {
                if(strchr(regex_chars, (int)*ind))
                        return 0;
Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.