|
|
ffc4fff |
diff -up patch-2.5.4/common.h.selinux patch-2.5.4/common.h
|
|
|
ffc4fff |
--- patch-2.5.4/common.h.selinux 1999-08-30 07:20:08.000000000 +0100
|
|
|
ffc4fff |
+++ patch-2.5.4/common.h 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
@@ -39,6 +39,8 @@
|
|
|
ffc4fff |
#include <sys/types.h>
|
|
|
ffc4fff |
#include <time.h>
|
|
|
3db4109 |
|
|
|
ffc4fff |
+#include <selinux/selinux.h>
|
|
|
ffc4fff |
+
|
|
|
ffc4fff |
#include <sys/stat.h>
|
|
|
ffc4fff |
#if ! defined S_ISDIR && defined S_IFDIR
|
|
|
ffc4fff |
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
|
|
ffc4fff |
@@ -168,6 +170,7 @@ XTERN char *outfile;
|
|
|
ffc4fff |
XTERN int inerrno;
|
|
|
ffc4fff |
XTERN int invc;
|
|
|
ffc4fff |
XTERN struct stat instat;
|
|
|
ffc4fff |
+XTERN security_context_t incontext;
|
|
|
ffc4fff |
XTERN bool dry_run;
|
|
|
ffc4fff |
XTERN bool posixly_correct;
|
|
|
ffc4fff |
|
|
|
ffc4fff |
diff -up patch-2.5.4/inp.c.selinux patch-2.5.4/inp.c
|
|
|
ffc4fff |
--- patch-2.5.4/inp.c.selinux 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
+++ patch-2.5.4/inp.c 2009-02-17 15:33:13.000000000 +0000
|
|
|
638a40a |
@@ -154,7 +154,20 @@ get_input_file (char const *filename, ch
|
|
|
638a40a |
char *getbuf;
|
|
|
638a40a |
|
|
|
638a40a |
if (inerrno == -1)
|
|
|
638a40a |
- inerrno = stat (inname, &instat) == 0 ? 0 : errno;
|
|
|
638a40a |
+ {
|
|
|
638a40a |
+ inerrno = stat (inname, &instat) == 0 ? 0 : errno;
|
|
|
638a40a |
+ if (inerrno == 0)
|
|
|
638a40a |
+ {
|
|
|
638a40a |
+ inerrno = getfilecon (inname, &incontext) == -1 ? errno : 0;
|
|
|
638a40a |
+ if (inerrno == ENODATA || inerrno == ENOTSUP)
|
|
|
638a40a |
+ {
|
|
|
638a40a |
+ inerrno = 0;
|
|
|
638a40a |
+ incontext = NULL;
|
|
|
638a40a |
+ }
|
|
|
638a40a |
+ }
|
|
|
638a40a |
+ else
|
|
|
638a40a |
+ incontext = NULL;
|
|
|
638a40a |
+ }
|
|
|
638a40a |
|
|
|
638a40a |
/* Perhaps look for RCS or SCCS versions. */
|
|
|
638a40a |
if (patch_get
|
|
|
638a40a |
@@ -196,7 +209,7 @@ get_input_file (char const *filename, ch
|
|
|
638a40a |
}
|
|
|
638a40a |
|
|
|
638a40a |
if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf,
|
|
|
638a40a |
- &instat))
|
|
|
638a40a |
+ &instat, &incontext))
|
|
|
638a40a |
inerrno = 0;
|
|
|
638a40a |
|
|
|
638a40a |
free (getbuf);
|
|
|
638a40a |
@@ -213,6 +226,7 @@ get_input_file (char const *filename, ch
|
|
|
638a40a |
{
|
|
|
638a40a |
instat.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
|
|
|
638a40a |
instat.st_size = 0;
|
|
|
638a40a |
+ incontext = NULL;
|
|
|
638a40a |
}
|
|
|
638a40a |
else if (! S_ISREG (instat.st_mode))
|
|
|
638a40a |
fatal ("File %s is not a regular file -- can't patch",
|
|
|
ffc4fff |
diff -up patch-2.5.4/Makefile.in.selinux patch-2.5.4/Makefile.in
|
|
|
ffc4fff |
--- patch-2.5.4/Makefile.in.selinux 1999-08-30 07:37:54.000000000 +0100
|
|
|
ffc4fff |
+++ patch-2.5.4/Makefile.in 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
@@ -36,7 +36,7 @@ DEFS = @DEFS@
|
|
|
ffc4fff |
EXEEXT = @EXEEXT@
|
|
|
ffc4fff |
LDFLAGS = @LDFLAGS@
|
|
|
ffc4fff |
LIBOBJS = @LIBOBJS@
|
|
|
ffc4fff |
-LIBS = @LIBS@
|
|
|
ffc4fff |
+LIBS = @LIBS@ -lselinux
|
|
|
ffc4fff |
PACKAGE = @PACKAGE@
|
|
|
ffc4fff |
U = @U@
|
|
|
ffc4fff |
VERSION = @VERSION@
|
|
|
ffc4fff |
diff -up patch-2.5.4/patch.c.selinux patch-2.5.4/patch.c
|
|
|
ffc4fff |
--- patch-2.5.4/patch.c.selinux 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
+++ patch-2.5.4/patch.c 2009-02-17 15:34:42.000000000 +0000
|
|
|
ffc4fff |
@@ -414,6 +414,16 @@ main (int argc, char **argv)
|
|
|
ffc4fff |
if (! inerrno && chmod (outname, instat.st_mode) != 0)
|
|
|
ffc4fff |
pfatal ("Can't set permissions on file %s",
|
|
|
ffc4fff |
quotearg (outname));
|
|
|
ffc4fff |
+ if (! inerrno && incontext) {
|
|
|
ffc4fff |
+ security_context_t outcontext;
|
|
|
9389e19 |
+ if (! getfilecon (outname, &outcontext) && outcontext &&
|
|
|
9389e19 |
+ strcmp(outcontext, incontext) &&
|
|
|
ffc4fff |
+ setfilecon (outname, incontext) != 0) {
|
|
|
ffc4fff |
+ if (errno != ENOTSUP && errno != EPERM)
|
|
|
ffc4fff |
+ pfatal ("Can't set security context on file %s",
|
|
|
ffc4fff |
+ quotearg (outname));
|
|
|
ffc4fff |
+ }
|
|
|
ffc4fff |
+ }
|
|
|
ffc4fff |
}
|
|
|
ffc4fff |
}
|
|
|
ffc4fff |
}
|
|
|
ffc4fff |
diff -up patch-2.5.4/pch.c.selinux patch-2.5.4/pch.c
|
|
|
ffc4fff |
--- patch-2.5.4/pch.c.selinux 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
+++ patch-2.5.4/pch.c 2009-02-17 15:33:13.000000000 +0000
|
|
|
3db4109 |
@@ -258,7 +258,12 @@ there_is_another_patch (void)
|
|
|
3db4109 |
{
|
|
|
3db4109 |
if (stat (inname, &instat) == 0)
|
|
|
3db4109 |
{
|
|
|
3db4109 |
- inerrno = 0;
|
|
|
638a40a |
+ inerrno = getfilecon (inname, &incontext) == -1 ? errno : 0;
|
|
|
3db4109 |
+ if (inerrno == ENODATA || inerrno == ENOTSUP)
|
|
|
3db4109 |
+ {
|
|
|
3db4109 |
+ inerrno = 0;
|
|
|
3db4109 |
+ incontext = NULL;
|
|
|
3db4109 |
+ }
|
|
|
3db4109 |
invc = -1;
|
|
|
3db4109 |
}
|
|
|
3db4109 |
else
|
|
|
3db4109 |
@@ -573,7 +578,7 @@ intuit_diff_type (void)
|
|
|
3db4109 |
if (cs)
|
|
|
3db4109 |
{
|
|
|
3db4109 |
if (version_get (name[i], cs, 0, readonly,
|
|
|
3db4109 |
- getbuf, &st[i]))
|
|
|
3db4109 |
+ getbuf, &st[i], NULL))
|
|
|
3db4109 |
stat_errno[i] = 0;
|
|
|
3db4109 |
else
|
|
|
3db4109 |
version_controlled[i] = 0;
|
|
|
638a40a |
@@ -641,6 +646,7 @@ intuit_diff_type (void)
|
|
|
638a40a |
inerrno = stat_errno[i];
|
|
|
638a40a |
invc = version_controlled[i];
|
|
|
638a40a |
instat = st[i];
|
|
|
638a40a |
+ getfilecon (inname, &incontext);
|
|
|
638a40a |
}
|
|
|
638a40a |
|
|
|
638a40a |
for (i = OLD; i <= INDEX; i++)
|
|
|
ffc4fff |
diff -up patch-2.5.4/util.c.selinux patch-2.5.4/util.c
|
|
|
ffc4fff |
--- patch-2.5.4/util.c.selinux 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
+++ patch-2.5.4/util.c 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
@@ -375,7 +375,8 @@ version_controller (char const *filename
|
|
|
ffc4fff |
Return nonzero if successful. */
|
|
|
ffc4fff |
int
|
|
|
ffc4fff |
version_get (char const *filename, char const *cs, int exists, int readonly,
|
|
|
ffc4fff |
- char const *getbuf, struct stat *filestat)
|
|
|
ffc4fff |
+ char const *getbuf, struct stat *filestat,
|
|
|
ffc4fff |
+ security_context_t *filecontext)
|
|
|
ffc4fff |
{
|
|
|
ffc4fff |
if (patch_get < 0)
|
|
|
ffc4fff |
{
|
|
|
ffc4fff |
@@ -400,6 +401,13 @@ version_get (char const *filename, char
|
|
|
ffc4fff |
fatal ("Can't get file %s from %s", quotearg (filename), cs);
|
|
|
ffc4fff |
if (stat (filename, filestat) != 0)
|
|
|
ffc4fff |
pfatal ("%s", quotearg (filename));
|
|
|
ffc4fff |
+ if (filecontext && getfilecon (filename, filecontext) == -1)
|
|
|
ffc4fff |
+ {
|
|
|
ffc4fff |
+ if (errno == ENODATA || errno == ENOTSUP)
|
|
|
ffc4fff |
+ *filecontext = NULL;
|
|
|
ffc4fff |
+ else
|
|
|
ffc4fff |
+ pfatal ("%s", quotearg (filename));
|
|
|
ffc4fff |
+ }
|
|
|
ffc4fff |
}
|
|
|
638a40a |
|
|
|
ffc4fff |
return 1;
|
|
|
ffc4fff |
diff -up patch-2.5.4/util.h.selinux patch-2.5.4/util.h
|
|
|
ffc4fff |
--- patch-2.5.4/util.h.selinux 1999-08-30 07:20:08.000000000 +0100
|
|
|
ffc4fff |
+++ patch-2.5.4/util.h 2009-02-17 15:33:13.000000000 +0000
|
|
|
ffc4fff |
@@ -21,7 +21,7 @@ char *fetchname PARAMS ((char *, int, ti
|
|
|
ffc4fff |
char *savebuf PARAMS ((char const *, size_t));
|
|
|
ffc4fff |
char *savestr PARAMS ((char const *));
|
|
|
ffc4fff |
char const *version_controller PARAMS ((char const *, int, struct stat const *, char **, char **));
|
|
|
ffc4fff |
-int version_get PARAMS ((char const *, char const *, int, int, char const *, struct stat *));
|
|
|
ffc4fff |
+int version_get PARAMS ((char const *, char const *, int, int, char const *, struct stat *, security_context_t *));
|
|
|
ffc4fff |
int create_file PARAMS ((char const *, int, mode_t));
|
|
|
ffc4fff |
int systemic PARAMS ((char const *));
|
|
|
ffc4fff |
char *format_linenum PARAMS ((char[LINENUM_LENGTH_BOUND + 1], LINENUM));
|