2008-06-02 11:12:20 +00:00
|
|
|
From a089634c855312a28f2ff3c2e7c08df5d030e2f5 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jim Meyering <meyering <at> redhat.com>
|
|
|
|
Date: Tue, 20 May 2008 17:58:42 +0200
|
|
|
|
Subject: [PATCH] install: avoid a leak in currently-ifdef'd-out code
|
|
|
|
|
|
|
|
* src/install.c (setdefaultfilecon)
|
|
|
|
[ENABLE_WHEN_MATCHPATHCON_IS_MORE_EFFICIENT]:
|
|
|
|
Call matchpathcon_init_prefix only once.
|
|
|
|
Suggestion from Stephen Smalley. Reported by Ben Webb in
|
|
|
|
<http://bugzilla.redhat.com/447410>.
|
|
|
|
---
|
|
|
|
src/install.c | 5 ++++-
|
|
|
|
1 files changed, 4 insertions(+), 1 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/install.c b/src/install.c
|
|
|
|
index 964ab36..b531f45 100644
|
|
|
|
--- a/src/install.c
|
|
|
|
+++ b/src/install.c
|
|
|
|
@@ -208,6 +208,8 @@ setdefaultfilecon (char const *file)
|
2008-05-20 15:07:43 +00:00
|
|
|
{
|
|
|
|
struct stat st;
|
2008-06-02 11:12:20 +00:00
|
|
|
security_context_t scontext = NULL;
|
|
|
|
+ static bool first_call = true;
|
|
|
|
+
|
2008-05-20 15:07:43 +00:00
|
|
|
if (selinux_enabled != 1)
|
|
|
|
{
|
|
|
|
/* Indicate no context found. */
|
2008-06-02 11:12:20 +00:00
|
|
|
@@ -216,7 +218,7 @@ setdefaultfilecon (char const *file)
|
2008-05-20 15:07:43 +00:00
|
|
|
if (lstat (file, &st) != 0)
|
|
|
|
return;
|
2008-06-02 11:12:20 +00:00
|
|
|
|
|
|
|
- if (IS_ABSOLUTE_FILE_NAME (file))
|
|
|
|
+ if (first_call && IS_ABSOLUTE_FILE_NAME (file))
|
2008-05-20 15:07:43 +00:00
|
|
|
{
|
2008-06-02 11:12:20 +00:00
|
|
|
/* Calling matchpathcon_init_prefix (NULL, "/first_component/")
|
2008-05-20 15:07:43 +00:00
|
|
|
is an optimization to minimize the expense of the following
|
2008-06-02 11:12:20 +00:00
|
|
|
@@ -247,6 +249,7 @@ setdefaultfilecon (char const *file)
|
|
|
|
}
|
2008-05-20 15:07:43 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-02 11:12:20 +00:00
|
|
|
+ first_call = false;
|
|
|
|
|
2008-05-20 15:07:43 +00:00
|
|
|
/* If there's an error determining the context, or it has none,
|
|
|
|
return to allow default context */
|
2008-06-02 11:12:20 +00:00
|
|
|
--
|
|
|
|
1.5.5.1.249.g68ef3
|