Blob Blame History Raw
diff -urNp coreutils-6.10-orig/src/mkdir.c coreutils-6.10/src/mkdir.c
--- coreutils-6.10-orig/src/mkdir.c	2008-03-27 14:42:40.000000000 +0100
+++ coreutils-6.10/src/mkdir.c	2008-03-27 14:51:48.000000000 +0100
@@ -211,7 +211,7 @@ main (int argc, char **argv)
   if (scontext && setfscreatecon (scontext) < 0)
     error (EXIT_FAILURE, errno,
 	   _("failed to set default file creation context to %s"),
-	   quote (optarg));
+	   quote (scontext));
 
   if (options.make_ancestor_function || specified_mode)
     {
diff -urNp coreutils-6.10-orig/src/mkfifo.c coreutils-6.10/src/mkfifo.c
--- coreutils-6.10-orig/src/mkfifo.c	2008-03-29 17:53:27.000000000 +0100
+++ coreutils-6.10/src/mkfifo.c	2008-03-29 17:55:44.000000000 +0100
@@ -1,5 +1,5 @@
 /* mkfifo -- make fifo's (named pipes)
-   Copyright (C) 90, 91, 1995-2007 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -123,7 +123,7 @@ main (int argc, char **argv)
   if (scontext && setfscreatecon (scontext) < 0)
     error (EXIT_FAILURE, errno,
 	   _("failed to set default file creation context to %s"),
-	   quote (optarg));
+	   quote (scontext));
 
   newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
   if (specified_mode)
diff -urNp coreutils-6.10-orig/src/mknod.c coreutils-6.10/src/mknod.c
--- coreutils-6.10-orig/src/mknod.c	2008-03-29 17:53:27.000000000 +0100
+++ coreutils-6.10/src/mknod.c	2008-03-29 17:55:36.000000000 +0100
@@ -175,7 +175,7 @@ main (int argc, char **argv)
   if (scontext && setfscreatecon (scontext) < 0)
     error (EXIT_FAILURE, errno,
 	   _("failed to set default file creation context to %s"),
-	   quote (optarg));
+	   quote (scontext));
 
   /* Only check the first character, to allow mnemonic usage like
      `mknod /dev/rst0 character 18 0'. */
Binární soubory coreutils-6.10-orig/src/.mknod.c.swp a coreutils-6.10/src/.mknod.c.swp jsou různé
diff -urNp coreutils-6.10-orig/tests/mkdir/Makefile.am coreutils-6.10/tests/mkdir/Makefile.am
--- coreutils-6.10-orig/tests/mkdir/Makefile.am	2007-11-25 14:23:31.000000000 +0100
+++ coreutils-6.10/tests/mkdir/Makefile.am	2008-03-29 17:56:51.000000000 +0100
@@ -8,6 +8,7 @@ TESTS = \
   p-v \
   parents \
   perm \
+  selinux \
   special-1 \
   t-slash \
   writable-under-readonly
diff -urNp coreutils-6.10-orig/tests/mkdir/selinux coreutils-6.10/tests/mkdir/selinux
--- coreutils-6.10-orig/tests/mkdir/selinux	1970-01-01 01:00:00.000000000 +0100
+++ coreutils-6.10/tests/mkdir/selinux	2008-03-29 17:58:25.000000000 +0100
@@ -0,0 +1,53 @@
+#!/bin/sh
+# ensure that an invalid context doesn't cause a segfault
+
+# Copyright (C) 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+  set -x
+  mkdir --version
+  mkfifo --version
+  mknod --version
+fi
+
+. $srcdir/../envvar-check
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+
+c=invalid-selinux-context
+
+fail=0
+mkdir -Z $c dir-arg 2> out && fail=1
+cat <<EOF > exp || fail=1
+mkdir: failed to set default file creation context to \`$c': Invalid argument
+EOF
+compare out exp || fail=1
+
+# Until coreutils-6.10.150, mknod and mkfifo had the same problem:
+
+mknod -Z $c b p 2> out && fail=1
+cat <<EOF > exp || fail=1
+mknod: failed to set default file creation context to \`$c': Invalid argument
+EOF
+compare out exp || fail=1
+
+mkfifo -Z $c f 2> out && fail=1
+cat <<EOF > exp || fail=1
+mkfifo: failed to set default file creation context to \`$c': Invalid argument
+EOF
+compare out exp || fail=1
+
+(exit $fail); exit $fail