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