This patch breaks changes restorecond to use setfiles code for checking.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
It also allows restorecond to run inside the user session to watch for file creation within the users homedir.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk0GaPoACgkQrlYvE4MpobNlMQCgoVmmGgnExKZzFkr5SaYnqjcv +WkAoIYGOktUCgTuvjIBNdW5RTsWZCVo
=n3sF
-----END PGP SIGNATURE-----
policycoreutils/restorecond/Makefile +20 -4
@@ -1,17 +1,28 @@ # Installation directories. PREFIX ?= ${DESTDIR}/usr SBINDIR ?= $(PREFIX)/sbin +LIBDIR ?= $(PREFIX)/lib MANDIR = $(PREFIX)/share/man +AUTOSTARTDIR = $(DESTDIR)/etc/xdg/autostart +DBUSSERVICEDIR = $(DESTDIR)/usr/share/dbus-1/services + +autostart_DATA = sealertauto.desktop INITDIR = $(DESTDIR)/etc/rc.d/init.d SELINUXDIR = $(DESTDIR)/etc/selinux +DBUSFLAGS = -DHAVE_DBUS -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/lib/dbus-1.0/include +DBUSLIB = -ldbus-glib-1 -ldbus-1 + CFLAGS ?= -g -Werror -Wall -W -override CFLAGS += -I$(PREFIX)/include -D_FILE_OFFSET_BITS=64 -LDLIBS += -lselinux -L$(PREFIX)/lib +override CFLAGS += -I$(PREFIX)/include $(DBUSFLAGS) -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib/glib-2.0/include + +LDLIBS += -lselinux $(DBUSLIB) -lglib-2.0 -L$(LIBDIR) all: restorecond -restorecond: restorecond.o utmpwatcher.o stringslist.o +restorecond.o utmpwatcher.o stringslist.o user.o watch.o: restorecond.h + +restorecond: ../setfiles/restore.o restorecond.o utmpwatcher.o stringslist.o user.o watch.o $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) install: all
@@ -22,7 +33,12 @@ install: all -mkdir -p $(INITDIR) install -m 755 restorecond.init $(INITDIR)/restorecond -mkdir -p $(SELINUXDIR) - install -m 600 restorecond.conf $(SELINUXDIR)/restorecond.conf + install -m 644 restorecond.conf $(SELINUXDIR)/restorecond.conf + install -m 644 restorecond_user.conf $(SELINUXDIR)/restorecond_user.conf + -mkdir -p $(AUTOSTARTDIR) + install -m 644 restorecond.desktop $(AUTOSTARTDIR)/restorecond.desktop + -mkdir -p $(DBUSSERVICEDIR) + install -m 600 org.selinux.Restorecond.service $(DBUSSERVICEDIR)/org.selinux.Restorecond.service relabel: install /sbin/restorecon $(SBINDIR)/restorecond
policycoreutils/restorecond/org.selinux.Restorecond.service new file +3 -0
@@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.selinux.Restorecond +Exec=/usr/sbin/restorecond -u
policycoreutils/restorecond/restorecond.8 +12 -3
@@ -3,7 +3,7 @@ restorecond \- daemon that watches for file creation and then sets the default SELinux file context .SH "SYNOPSIS" -.B restorecond [\-d] +.B restorecond [\-d] [\-f restorecond_file ] [\-u] [\-v] .P .SH "DESCRIPTION"
@@ -19,13 +19,22 @@ the correct file context associated with the policy. .B \-d Turns on debugging mode. Application will stay in the foreground and lots of debugs messages start printing. +.TP +.B \-f restorecond_file +Use alternative restorecond.conf file. +.TP +.B \-u +Turns on user mode. Runs restorecond in the user session and reads /etc/selinux/restorecond_user.conf. Uses dbus to make sure only one restorecond is running per user session. +.TP +.B \-v +Turns on verbose debugging. (Report missing files) .SH "AUTHOR" -This man page was written by Dan Walsh <[email protected]>. -The program was written by Dan Walsh <[email protected]>. +This man page and program was written by Dan Walsh <[email protected]>. .SH "FILES" /etc/selinux/restorecond.conf +/etc/selinux/restorecond_user.conf .SH "SEE ALSO" .BR restorecon (8),
policycoreutils/restorecond/restorecond.c +77 -350
497 lines not on this page · raw message
policycoreutils/restorecond/restorecond.conf +1 -4
@@ -4,8 +4,5 @@ /etc/mtab /var/run/utmp /var/log/wtmp -~/* -/root/.ssh +/root/* /root/.ssh/* - -
policycoreutils/restorecond/restorecond.desktop new file +7 -0
@@ -0,0 +1,7 @@ +[Desktop Entry] +Name=File Context maintainer +Exec=/usr/sbin/restorecond -u +Comment=Fix file context in owned by the user +Encoding=UTF-8 +Type=Application +StartupNotify=false
policycoreutils/restorecond/restorecond.h +17 -2
@@ -24,7 +24,22 @@#ifndef RESTORED_CONFIG_H #define RESTORED_CONFIG_H -void exitApp (const char *msg); -void watch_list_add (int inotify_fd,const char *path); +extern int debug_mode; +extern const char *homedir; +extern int terminate; +extern int master_wd; +extern int run_as_user; + +extern int start (void ); +extern int server (int ,const char *watch_file); + +extern void exitApp (const char *msg); +extern void read_config (int fd,const char *watch_file); + +extern int watch (int fd,const char *watch_file); +extern void watch_list_add (int inotify_fd,const char *path); +extern int watch_list_find (int wd,const char *file); +extern void watch_list_free (int fd); +extern int watch_list_isempty ();#endif
policycoreutils/restorecond/restorecond.init +3 -4
@@ -26,7 +26,7 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin # Source function library. . /etc/rc.d/init.d/functions -[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 0 +[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 7 # Check that we are root ... so non-root users stop here test $EUID = 0 || exit 4
@@ -75,16 +75,15 @@ case "$1" in status restorecond RETVAL=$? ;; - restart|reload) + force-reload|restart|reload) restart ;; condrestart) [ -e /var/lock/subsys/restorecond ] && restart || : ;; *) - echo $"Usage: $0 {start|stop|restart|reload|condrestart}" + echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart}" RETVAL=3 esac exit $RETVAL -
policycoreutils/restorecond/restorecond_user.conf new file +2 -0
@@ -0,0 +1,2 @@ +~/* +~/public_html/*
policycoreutils/restorecond/user.c new file +239 -0
239 lines not on this page · raw message
policycoreutils/restorecond/utmpwatcher.c +1 -1
@@ -72,8 +72,8 @@ unsigned int utmpwatcher_handle(int inotify_fd, int wd)if (utmp_wd ==-1 )exitApp ("Error watching utmp file." ); + changed =strings_list_diff (prev_utmp_ptr, utmp_ptr);if (prev_utmp_ptr) { - changed =strings_list_diff (prev_utmp_ptr, utmp_ptr);strings_list_free (prev_utmp_ptr); }return changed;
policycoreutils/restorecond/watch.c new file +260 -0
260 lines not on this page · raw message
policycoreutils/setfiles/restore.c +100 -9
171 lines not on this page · raw message
policycoreutils/setfiles/restore.h +4 -0
@@ -27,6 +27,7 @@ struct restore_opts {int hard_links;int verbose;int logging; +int ignore_enoent;char *rootpath;int rootpathlen;char *progname;
@@ -44,7 +45,10 @@ struct restore_opts {void restore_init (struct restore_opts *opts);void restore_finish ();int add_exclude (const char *directory); +int exclude (const char *path);void remove_exclude (const char *directory);int process_one_realpath (char *name,int recurse); +int process_glob (char *name,int recurse); +void exclude_non_seclabel_mounts ();#endif
policycoreutils/setfiles/restorecon.8 +5 -2
@@ -4,10 +4,10 @@ restorecon \- restore file(s) default SELinux security contexts. .SH "SYNOPSIS" .B restorecon -.I [\-o outfilename ] [\-R] [\-n] [\-v] [\-e directory ] pathname... +.I [\-o outfilename ] [\-R] [\-n] [\-p] [\-v] [\-e directory ] pathname... .P .B restorecon -.I \-f infilename [\-o outfilename ] [\-e directory ] [\-R] [\-n] [\-v] [\-F] +.I \-f infilename [\-o outfilename ] [\-e directory ] [\-R] [\-n] [\-p] [\-v] [\-F] .SH "DESCRIPTION" This manual page describes the
@@ -40,6 +40,9 @@ don't change any file labels. .TP .B \-o outfilename save list of files with incorrect context in outfilename. +.TP +.B \-p +show progress by printing * every 1000 files. .TP .B \-v show changes in file labels.
policycoreutils/setfiles/setfiles.8 +3 -0
@@ -31,6 +31,9 @@ log changes in file labels to syslog. .TP .B \-n don't change any file labels. +.TP +.B \-p +show progress by printing * every 1000 files. .TP .B \-q suppress non-error output.
policycoreutils/setfiles/setfiles.c +7 -71
131 lines not on this page · raw message