LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-17-2016, 04:32 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
SELinux semanage is missing context of unconfied_u


I'm trying to troubleshoot some 3rd party software that is having issues with SELinux on RHEL5.

On one RHEL6 server it is working and the other server, RHEL5 it is. I'm guessing because the context is off.

RHEL6
Code:
rwsr-x---. root varonis unconfined_u:object_r:usr_t:s0   vrns_watchdog

RHEL5
Code:
rwsr-x---. root varonis user_u:object_r:usr_t:s0   vrns_watchdog
If I run

Code:
[root@server varonis]# semanage user -l

                Labeling   MLS/       MLS/
SELinux User    Prefix     MCS Level  MCS Range                      SELinux Roles

root            user       s0         SystemLow-SystemHigh           system_r sysadm_r user_r
system_u        user       s0         SystemLow-SystemHigh           system_r
user_u          user       s0         SystemLow-SystemHigh           system_r sysadm_r user_r
[root@server varonis]#
Its missing the context for the user that i need, which is unconfined_u.

Is there a way to add unconfined_u?

thanks
 
Old 02-17-2016, 08:16 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
have you ran "audit2allow " on the error log?

and have you contacted RH support
 
Old 02-17-2016, 08:29 PM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by John VV View Post
have you ran "audit2allow " on the error log?

and have you contacted RH support
No, I forgot to run audit2allow, however I did look at /var/log/audit.

I try to troubleshoot the best I can before contacting RH.

I'm just wondering if anyone else has seen this?
 
Old 02-17-2016, 08:46 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Not that particular one. I have seen similar differences between releases though.

But after every upgrade you really need to check/relable the system (touch ./autorelable, and reboot would do).

It is also possible to do after the fact using "restorecon -R <pathname>" which will recursively check/set everything in <pathname>. The only issue here is that running processes may get cut off. For some busy systems, that can end up in a reboot anyway.

The best explaination I have seen was that the labels in the filesystem are binary numbers, and between releases the security definitions may change due to new ones added/unused ones removed. This in turn changes the numbers assigned... and thus needing a pass over filesystems to update the definitions.

Last edited by jpollard; 02-17-2016 at 08:49 PM.
 
Old 02-17-2016, 09:21 PM   #5
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by jpollard View Post
But after every upgrade you really need to check/relable the system (touch ./autorelable, and reboot would do).
Recently updated the kernel, which upgraded the the release.

I wasn't aware that if doing this, need to run touch ./autorelabel in order to fix issues. I will make a note of this.


Quote:
Originally Posted by jpollard View Post
It is also possible to do after the fact using "restorecon -R <pathname>" which will recursively check/set everything in <pathname>. The only issue here is that running processes may get cut off. For some busy systems, that can end up in a reboot anyway.
I didn't attempt restorecon because in my experience say I moved a file that I touched or created in a different directory, typically will keep its SELinux context. I can try that first before doing the touch ./autorelabel, which can take some time once its kicked off.

thanks
 
Old 02-18-2016, 05:23 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by JockVSJock View Post
Recently updated the kernel, which upgraded the the release.

I wasn't aware that if doing this, need to run touch ./autorelabel in order to fix issues. I will make a note of this.
It is usually done by upgrade process - but that doesn't mean all file systems are seen as they may have been removed. In my case, I usually remove the home and media filesystems to avoid the possibility of an accidental erasure. Other situations that can require it is in multi-boot situations. A newer system is planned, installed for testing, but without all of the filesystems mounted. When testing finished switch to the new system - and again, the filesystems need to have their security labels updated.
Quote:


I didn't attempt restorecon because in my experience say I moved a file that I touched or created in a different directory, typically will keep its SELinux context. I can try that first before doing the touch ./autorelabel, which can take some time once its kicked off.

thanks
If a file is in a directory tree with the wrong security label, it needs to be relabeled as it no longer has a valid context for where it is located.

If the new location is deemed to valid context, then the database needs to be updated, and that will preserve the desired context the next time the labels get updated. The usual case for that would be web content being put in /var/www. These SHOULD be httpd_sys_script_exec_t, httpd_sys_content_t , webalizer_rw_content_t. But moving user files into should be made httpd_sys_content_t so that they cannot be altered by actions of the web server (or the user again). It happens, but the files no longer are protected... If apache is to write on them the label needs to be httpd_sys_rw_content_t.

But that is just being consistent with the compartmented design.
 
Old 02-18-2016, 09:09 PM   #7
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by John VV View Post
have you ran "audit2allow " on the error log?
SELinux audit2allow generates policies to allow what is denied. I don't think that is a great place to start. I started to look at /var/log/audit first and look for exceptions there.

Right now I'm trying to figure out if its even an SELinux issues.

Today I changed the user context to root and the software still wouldn't run. Matter of fact while troubleshooting /var/log/messages, it just stopped working...maybe its the software...

I also create .autorelabel and rebooted and this didn't change the users found under semanage...maybe its the software...
 
Old 02-23-2016, 07:19 PM   #8
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
From troubleshooting this more, this is an application issue. It abruptly stops running on two of my servers, so I don't know why they would think it would be an SELinux issue.
 
  


Reply

Tags
selinux, semanage


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] SELinux context change shfyang Linux - Security 1 09-27-2014 12:32 AM
SELinux change context to my own name kingkashif Programming 1 03-16-2013 07:44 AM
[SOLVED] SELinux - Best Context to Use dcarrington Linux - Server 7 07-11-2012 04:25 PM
SElinux context problem Bit-Devil Linux - Security 0 12-04-2009 06:58 PM
invalid context in SELinux lothario Linux - Security 1 06-17-2005 04:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration