A couple of minor coverity fixes for a potential leaked file descriptor

An an unchecked return code.
Add ~/.local/share/* to restorecond_user watches
This commit is contained in:
Dan Walsh 2011-10-28 16:47:40 -04:00
parent 4f4e4913d7
commit 2392ca1483
2 changed files with 44 additions and 26 deletions

View File

@ -221,7 +221,7 @@ index 4952632..89f5d97 100644
-#define EVENT_SIZE (sizeof (struct inotify_event)) -#define EVENT_SIZE (sizeof (struct inotify_event))
-/* reasonable guess as to size of 1024 events */ -/* reasonable guess as to size of 1024 events */
-#define BUF_LEN (1024 * (EVENT_SIZE + 16)) -#define BUF_LEN (1024 * (EVENT_SIZE + 16))
-
-static int debug_mode = 0; -static int debug_mode = 0;
-static int verbose_mode = 0; -static int verbose_mode = 0;
- -
@ -248,11 +248,7 @@ index 4952632..89f5d97 100644
- return 0; - return 0;
- return (strcmp(rest_a, rest_b) == 0); - return (strcmp(rest_a, rest_b) == 0);
-} -}
+static char *server_watch_file = "/etc/selinux/restorecond.conf"; -
+static char *user_watch_file = "/etc/selinux/restorecond_user.conf";
+static char *watch_file;
+static struct restore_opts r_opts;
-/* -/*
- A file was in a direcroty has been created. This function checks to - A file was in a direcroty has been created. This function checks to
- see if it is one that we are watching. - see if it is one that we are watching.
@ -428,9 +424,13 @@ index 4952632..89f5d97 100644
- FILE *cfg = NULL; - FILE *cfg = NULL;
- if (debug_mode) - if (debug_mode)
- printf("Read Config\n"); - printf("Read Config\n");
-
- watch_list_free(fd); - watch_list_free(fd);
- +static char *server_watch_file = "/etc/selinux/restorecond.conf";
+static char *user_watch_file = "/etc/selinux/restorecond_user.conf";
+static char *watch_file;
+static struct restore_opts r_opts;
- cfg = fopen(watch_file_path, "r"); - cfg = fopen(watch_file_path, "r");
- if (!cfg) - if (!cfg)
- exitApp("Error reading config file."); - exitApp("Error reading config file.");
@ -479,22 +479,22 @@ index 4952632..89f5d97 100644
- if (event->len) - if (event->len)
- watch_list_find(event->wd, event->name); - watch_list_find(event->wd, event->name);
- break; - break;
- +#include <selinux/selinux.h>
- case 1: /* utmp has changed need to reload */ - case 1: /* utmp has changed need to reload */
- read_config(fd); - read_config(fd);
- break; - break;
+#include <selinux/selinux.h> +int debug_mode = 0;
+int terminate = 0;
+int master_wd = -1;
+int run_as_user = 0;
- default: /* No users logged in or out */ - default: /* No users logged in or out */
- break; - break;
- } - }
- } - }
- } - }
+int debug_mode = 0; -
+int terminate = 0;
+int master_wd = -1;
+int run_as_user = 0;
- i += EVENT_SIZE + event->len; - i += EVENT_SIZE + event->len;
- } - }
- return 0; - return 0;
@ -773,10 +773,10 @@ index b966db6..775c52b 100644
- -
diff --git a/policycoreutils/restorecond/restorecond_user.conf b/policycoreutils/restorecond/restorecond_user.conf diff --git a/policycoreutils/restorecond/restorecond_user.conf b/policycoreutils/restorecond/restorecond_user.conf
new file mode 100644 new file mode 100644
index 0000000..e0c2871 index 0000000..b4debed
--- /dev/null --- /dev/null
+++ b/policycoreutils/restorecond/restorecond_user.conf +++ b/policycoreutils/restorecond/restorecond_user.conf
@@ -0,0 +1,7 @@ @@ -0,0 +1,8 @@
+~/* +~/*
+~/public_html/* +~/public_html/*
+~/.gnome2/* +~/.gnome2/*
@ -784,6 +784,7 @@ index 0000000..e0c2871
+~/.fonts/* +~/.fonts/*
+~/.cache/* +~/.cache/*
+~/.config/* +~/.config/*
+~/.local/share/*
diff --git a/policycoreutils/restorecond/user.c b/policycoreutils/restorecond/user.c diff --git a/policycoreutils/restorecond/user.c b/policycoreutils/restorecond/user.c
new file mode 100644 new file mode 100644
index 0000000..4257058 index 0000000..4257058
@ -1362,6 +1363,18 @@ index 4764987..924999d 100644
-mkdir -p $(SBINDIR) -mkdir -p $(SBINDIR)
install -m 4755 seunshare $(SBINDIR)/ install -m 4755 seunshare $(SBINDIR)/
-mkdir -p $(SHAREDIR) -mkdir -p $(SHAREDIR)
diff --git a/policycoreutils/sandbox/sandbox.init b/policycoreutils/sandbox/sandbox.init
index d1ccdc2..11c391c 100644
--- a/policycoreutils/sandbox/sandbox.init
+++ b/policycoreutils/sandbox/sandbox.init
@@ -19,6 +19,7 @@
#
# Source function library.
+. /etc/init.d/functions
LOCKFILE=/var/lock/subsys/sandbox
diff --git a/policycoreutils/sandbox/seunshare.c b/policycoreutils/sandbox/seunshare.c diff --git a/policycoreutils/sandbox/seunshare.c b/policycoreutils/sandbox/seunshare.c
index a52b6f1..c493e98 100644 index a52b6f1..c493e98 100644
--- a/policycoreutils/sandbox/seunshare.c --- a/policycoreutils/sandbox/seunshare.c
@ -1468,10 +1481,10 @@ index 0000000..e15a877
+ rm -rf build *~ + rm -rf build *~
diff --git a/policycoreutils/semanage/default_encoding/default_encoding.c b/policycoreutils/semanage/default_encoding/default_encoding.c diff --git a/policycoreutils/semanage/default_encoding/default_encoding.c b/policycoreutils/semanage/default_encoding/default_encoding.c
new file mode 100644 new file mode 100644
index 0000000..2ba4870 index 0000000..023b8f4
--- /dev/null --- /dev/null
+++ b/policycoreutils/semanage/default_encoding/default_encoding.c +++ b/policycoreutils/semanage/default_encoding/default_encoding.c
@@ -0,0 +1,59 @@ @@ -0,0 +1,57 @@
+/* +/*
+ * Authors: + * Authors:
+ * John Dennis <jdennis@redhat.com> + * John Dennis <jdennis@redhat.com>
@ -1526,10 +1539,8 @@ index 0000000..2ba4870
+PyMODINIT_FUNC +PyMODINIT_FUNC
+initdefault_encoding_utf8(void) +initdefault_encoding_utf8(void)
+{ +{
+ PyObject* m;
+
+ PyUnicode_SetDefaultEncoding("utf-8"); + PyUnicode_SetDefaultEncoding("utf-8");
+ m = Py_InitModule3("default_encoding_utf8", methods, "Forces the default encoding to utf-8"); + Py_InitModule3("default_encoding_utf8", methods, "Forces the default encoding to utf-8");
+} +}
diff --git a/policycoreutils/semanage/default_encoding/policycoreutils/__init__.py b/policycoreutils/semanage/default_encoding/policycoreutils/__init__.py diff --git a/policycoreutils/semanage/default_encoding/policycoreutils/__init__.py b/policycoreutils/semanage/default_encoding/policycoreutils/__init__.py
new file mode 100644 new file mode 100644
@ -1949,7 +1960,7 @@ index f84cd7e..3565f5e 100644
indent: indent:
../../scripts/Lindent $(wildcard *.[ch]) ../../scripts/Lindent $(wildcard *.[ch])
diff --git a/policycoreutils/setfiles/restore.c b/policycoreutils/setfiles/restore.c diff --git a/policycoreutils/setfiles/restore.c b/policycoreutils/setfiles/restore.c
index ce44c04..f08f8e5 100644 index ce44c04..373c9b9 100644
--- a/policycoreutils/setfiles/restore.c --- a/policycoreutils/setfiles/restore.c
+++ b/policycoreutils/setfiles/restore.c +++ b/policycoreutils/setfiles/restore.c
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
@ -1982,12 +1993,14 @@ index ce44c04..f08f8e5 100644
if (!r_opts->hnd) { if (!r_opts->hnd) {
perror(r_opts->selabel_opt_path); perror(r_opts->selabel_opt_path);
exit(1); exit(1);
@@ -104,8 +105,7 @@ static int restore(FTSENT *ftsent) @@ -103,9 +104,8 @@ static int match(const char *name, struct stat *sb, char **con)
static int restore(FTSENT *ftsent)
{ {
char *my_file = strdupa(ftsent->fts_path); char *my_file = strdupa(ftsent->fts_path);
int ret; - int ret;
- char *context, *newcon; - char *context, *newcon;
- int user_only_changed = 0; - int user_only_changed = 0;
+ int ret = -1;
+ security_context_t curcon = NULL, newcon = NULL; + security_context_t curcon = NULL, newcon = NULL;
if (match(my_file, ftsent->fts_statp, &newcon) < 0) if (match(my_file, ftsent->fts_statp, &newcon) < 0)

View File

@ -7,7 +7,7 @@
Summary: SELinux policy core utilities Summary: SELinux policy core utilities
Name: policycoreutils Name: policycoreutils
Version: 2.1.7 Version: 2.1.7
Release: 4%{?dist} Release: 5%{?dist}
License: GPLv2 License: GPLv2
Group: System Environment/Base Group: System Environment/Base
# Based on git repository with tag 20101221 # Based on git repository with tag 20101221
@ -352,6 +352,11 @@ fi
/bin/systemctl try-restart restorecond.service >/dev/null 2>&1 || : /bin/systemctl try-restart restorecond.service >/dev/null 2>&1 || :
%changelog %changelog
* Fri Oct 28 2011 Dan Walsh <dwalsh@redhat.com> - 2.1.7-5
- A couple of minor coverity fixes for a potential leaked file descriptor
- An an unchecked return code.
- Add ~/.local/share/* to restorecond_user watches
* Thu Oct 13 2011 Dan Walsh <dwalsh@redhat.com> - 2.1.7-4 * Thu Oct 13 2011 Dan Walsh <dwalsh@redhat.com> - 2.1.7-4
- Have sepolgen return name field in AVC - Have sepolgen return name field in AVC