Skip to contentSkip to conversation

resource-agents: Fix nfs mount contexts

PATCH New Lon Hohberger 3 participants 5 messages Apr 14, 2011 – Apr 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 resource-agents: Fix nfs mount contexts

Resolves: rhbz#635828

---
 rgmanager/src/resources/nfsserver.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
rgmanager/src/resources/nfsserver.sh +3 -0
index 17f472d..bb2632e 100644
@@ -222,6 +222,9 @@ create_tree()
 	[ -f "$fp/xtab" ] || touch "$fp/xtab"
 	[ -f "$fp/rmtab" ] || touch "$fp/rmtab"
 
+	chcon -R system_u:object_r:var_lib_nfs_t:s0 "$fp"
+	chcon -R system_u:object_r:var_lib_nfs_t:s0 "$fp/*"
+
         #
         # Generate a random state file.  If this ends up being what a client
         # already has in its list, that's bad, but the chances of this
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 resource-agents: Fix nfs mount contexts

Note - patch proposed for RHEL6 branch.

Signature · 1 line
Lon Hohberger - Red Hat, Inc.
#2 lore raw

PATCH 1/1 resource-agents: Fix nfs mount contexts

In reply to Lon Hohberger

ACK.

Quoted 24 lines · Lon Hohberger

Resolves: rhbz#635828

---
 rgmanager/src/resources/nfsserver.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
rgmanager/src/resources/nfsserver.sh +3 -0
index 17f472d..bb2632e 100644
@@ -222,6 +222,9 @@ create_tree()
 	[ -f "$fp/xtab" ] || touch "$fp/xtab"
 	[ -f "$fp/rmtab" ] || touch "$fp/rmtab"
 
+	chcon -R system_u:object_r:var_lib_nfs_t:s0 "$fp"
+	chcon -R system_u:object_r:var_lib_nfs_t:s0 "$fp/*"
+
         #
         # Generate a random state file.  If this ends up being what a client
         # already has in its list, that's bad, but the chances of this
Signature · 1 line
1.7.3.4
#3 lore raw

PATCH 1/1 resource-agents: Fix nfs mount contexts

In reply to Lon Hohberger

Hi Lon,

2 small bits here..

in nfsserver.sh, we also call restorecon.

IMHO execution of selinux tools should be conditional to selinux being enabled and tools available.

To make this a generic upstream patch, we can do (at the beginning of the agent):

selinuxon=""
[ -n "$(which selinuxenabled)" ] && selinuxenabled && selinuxon=1

this is mostly paranoia and to cache the result for later use. invoking selinuxenabled is cheap.

.....

[ -n "$selinuxon" ] && [ -n "$(which restorecon)" ] && restorecon...

.....

[ -n "$selinuxon" ] && [ -n "$(which chcon)" ] && chcon -R....

chcon -R works recursively, so one invocation should be sufficient.

The main motivator behind this approach is to guarantee that we don't need resource-agents to Requires those tools at packaging level and enforce them on a system.

Fabio

Quoted 22 lines · Lon Hohberger

Resolves: rhbz#635828

---
 rgmanager/src/resources/nfsserver.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
rgmanager/src/resources/nfsserver.sh +3 -0
index 17f472d..bb2632e 100644
@@ -222,6 +222,9 @@ create_tree()
 	[ -f "$fp/xtab" ] || touch "$fp/xtab"
 	[ -f "$fp/rmtab" ] || touch "$fp/rmtab"
 
+	chcon -R system_u:object_r:var_lib_nfs_t:s0 "$fp"
+	chcon -R system_u:object_r:var_lib_nfs_t:s0 "$fp/*"
+
         #
         # Generate a random state file.  If this ends up being what a client
         # already has in its list, that's bad, but the chances of this
#4 lore raw

PATCH 1/1 resource-agents: Fix nfs mount contexts

Quoted 11 lines · Fabio M. Di Nitto

Hi Lon,

2 small bits here..

in nfsserver.sh, we also call restorecon.

IMHO execution of selinux tools should be conditional to selinux being enabled and tools available.

To make this a generic upstream patch, we can do (at the beginning of the agent):

Yep, I'll revert the one I pushed. Sorry about that.

Quoted 8 lines

selinuxon=""
[ -n "$(which selinuxenabled)" ] && selinuxenabled && selinuxon=1

this is mostly paranoia and to cache the result for later use. invoking selinuxenabled is cheap.

.....

Quoted 7 lines

[ -n "$selinuxon" ] && [ -n "$(which restorecon)" ] && restorecon...

.....

[ -n "$selinuxon" ] && [ -n "$(which chcon)" ] && chcon -R....

chcon -R works recursively, so one invocation should be sufficient.

In my initial testing, it didn't work, but deleting the second line seemed to work fine now.

Quoted 3 lines

The main motivator behind this approach is to guarantee that we don't need resource-agents to Requires those tools at packaging level and enforce them on a system.

Understood.

Signature · 1 line
Lon Hohberger - Red Hat, Inc.