libselinux/libselinux-rhat.patch

84 lines
2.3 KiB
Diff
Raw Normal View History

diff --git a/libselinux/src/callbacks.c b/libselinux/src/callbacks.c
index b245364..7c47222 100644
--- a/libselinux/src/callbacks.c
+++ b/libselinux/src/callbacks.c
@@ -16,6 +16,7 @@ default_selinux_log(int type __attribute__((unused)), const char *fmt, ...)
2008-07-09 20:57:21 +00:00
{
int rc;
va_list ap;
+ if (is_selinux_enabled() == 0) return 0;
va_start(ap, fmt);
rc = vfprintf(stderr, fmt, ap);
va_end(ap);
diff --git a/libselinux/src/matchpathcon.c b/libselinux/src/matchpathcon.c
index 9717b14..df83b30 100644
--- a/libselinux/src/matchpathcon.c
+++ b/libselinux/src/matchpathcon.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <syslog.h>
#include "selinux_internal.h"
#include "label_internal.h"
#include "callbacks.h"
@@ -62,7 +63,7 @@ static void
{
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ vsyslog(LOG_ERR, fmt, ap);
va_end(ap);
}
@@ -353,7 +354,7 @@ static int symlink_realpath(const char *name, char *resolved_path)
tmp_path = strdup(name);
if (!tmp_path) {
- fprintf(stderr, "symlink_realpath(%s) strdup() failed: %s\n",
+ myprintf("symlink_realpath(%s) strdup() failed: %s\n",
name, strerror(errno));
rc = -1;
goto out;
@@ -374,21 +375,24 @@ static int symlink_realpath(const char *name, char *resolved_path)
}
2011-02-01 22:40:11 +00:00
if (!p) {
- fprintf(stderr, "symlink_realpath(%s) realpath() failed: %s\n",
+ myprintf("symlink_realpath(%s) realpath() failed: %s\n",
name, strerror(errno));
rc = -1;
goto out;
}
len = strlen(p);
- if (len + strlen(last_component) + 1 > PATH_MAX) {
- fprintf(stderr, "symlink_realpath(%s) failed: Filename too long \n",
+ if (len + strlen(last_component) + 2 > PATH_MAX) {
+ myprintf("symlink_realpath(%s) failed: Filename too long \n",
name);
+ errno=ENAMETOOLONG;
rc = -1;
goto out;
}
2011-02-01 22:40:11 +00:00
resolved_path += len;
+ strcpy(resolved_path, "/");
+ resolved_path += 1;
strcpy(resolved_path, last_component);
out:
free(tmp_path);
diff --git a/libselinux/utils/matchpathcon.c b/libselinux/utils/matchpathcon.c
index 2fa21bc..5f0a4c2 100644
--- a/libselinux/utils/matchpathcon.c
+++ b/libselinux/utils/matchpathcon.c
@@ -45,7 +45,7 @@ int printmatchpathcon(char *path, int header, int mode)
int main(int argc, char **argv)
{
- int i, init = 0, rc = 0;
+ int i, init = 0;
int header = 1, opt;
int verify = 0;
int notrans = 0;