summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-01-29 08:56:48 +0100
committerJim Meyering <meyering@redhat.com>2008-01-29 09:23:51 +0100
commit533391a2a75f49da27adc71214caeeb4ef07d81c (patch)
tree9844aa22b4d1ce561e46e7b5973b7f2ed88b8309 /src
parenta6228c5437e9f07d9f72828436b75e3358443a1c (diff)
downloadcoreutils-533391a2a75f49da27adc71214caeeb4ef07d81c.tar.xz
ls: don't segfault on files in /proc with an old libselinux
* src/ls.c (gobble_file): Work around a bug in libselinux1-2.0.15 whereby getfilecon returns 0 yet sets the context to NULL. Reported by Jan Moringen via Michael Stone in http://bugs.debian.org/463043 * tests/ls/Makefile.am (TESTS): Add proc-selinux-segfault. * tests/ls/proc-selinux-segfault: Test for the above fix. * NEWS: Mention the fix.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 83fac90d4..46713f26c 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1,5 +1,5 @@
/* `dir', `vdir' and `ls' directory listing programs for GNU.
- Copyright (C) 85, 88, 90, 91, 1995-2007 Free Software Foundation, Inc.
+ Copyright (C) 85, 88, 90, 91, 1995-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2667,6 +2667,17 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
: lgetfilecon (absolute_name, &f->scontext));
err = (attr_len < 0);
+ /* Contrary to its documented API, getfilecon may return 0,
+ yet set f->scontext to NULL (on at least Debian's libselinux1
+ 2.0.15-2+b1), so work around that bug.
+ FIXME: remove this work-around in 2011, or whenever affected
+ versions of libselinux are long gone. */
+ if (attr_len == 0)
+ {
+ err = 0;
+ f->scontext = xstrdup ("unlabeled");
+ }
+
if (err == 0)
have_acl = ! STREQ ("unlabeled", f->scontext);
else