LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-05-2019, 04:55 PM   #1
buckcosmos
LQ Newbie
 
Registered: Aug 2019
Posts: 2

Rep: Reputation: Disabled
Strange file permissions trying to disable selinux


I have a Linux VM that I inherited and I'm running into some strange permission issues around selinux that I'm hoping someone can help me out with. I started with the simple things:

# setenforce 0
setenforce: setenforce() failed

My id is:
# id
uid=0(root) gid=0(root) grupos=0(root) context=root:sysadm_r:sysadm_t:s0-s15:c0.c1023

If I try to edit /etc/selinux/config I get a warning about it being a read only file

Running sestatus results in the following:
# /usr/sbin/sestatus
-bash: /usr/sbin/sestatus: Permission denied

# ls -la /usr/sbin | grep sestatus
-?????????? ? ? ? ? ? sestatus

A couple of other things that I have checked:
# getsebool -a | grep secure
secure_mode --> off
secure_mode_insmod --> off
secure_mode_policyload --> off

I'm not sure where else to check or what to look for. If anyone has any ideas they are certainly welcomed.
 
Old 08-05-2019, 11:17 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by buckcosmos View Post
# setenforce 0
setenforce: setenforce() failed
Anything in the kernel message buffer? Run dmesg to check.

Quote:
If I try to edit /etc/selinux/config I get a warning about it being a read only file
That's normal if the file is read-only. As root, you can write to it anyway.
Quote:
Running sestatus results in the following:
# /usr/sbin/sestatus
-bash: /usr/sbin/sestatus: Permission denied

# ls -la /usr/sbin | grep sestatus
-?????????? ? ? ? ? ? sestatus
Does the directory /usr/sbin have correct permissions?

I would also check whatever log file contains SELinux messages (/var/log/auth/auth.log on Centos, I think), and run a filesystem check.
 
Old 08-06-2019, 01:53 AM   #3
dac.override
LQ Newbie
 
Registered: Oct 2016
Posts: 24

Rep: Reputation: Disabled
You are logged in as systems administrator, sysadm is not allowed to do security administration in MLS systems. You need to login as security administrator (secadm) instead if you want to touch SELinux.
 
Old 08-06-2019, 06:08 AM   #4
dac.override
LQ Newbie
 
Registered: Oct 2016
Posts: 24

Rep: Reputation: Disabled
I will expand on the above answer a little bit.

You noted that `id` returns:
uid=0(root) gid=0(root) grupos=0(root) context=root:sysadm_r:sysadm_t:s0-s15:c0.c1023

The "s0-s15:c0.c1023" part of the "context=" indicates to me that this system enforces confidentiality using what is called "Multi-level security". Enforcement of confidentiality is a very niche use-case. Usually government of DoD type parties.

https://en.wikipedia.org/wiki/Bell%E...LaPadula_model

In these environments there are verious roles like sysadm_r for systems administration, secadm_r for security administration, auditadm_r for audit administrators.

So depending on your task you assume the appropriate role. There are various way's to configure this. At login time with "pam_selinux" and at runtime with "newrole".
 
1 members found this post helpful.
Old 08-06-2019, 06:25 AM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by dac.override View Post
You are logged in as systems administrator, sysadm is not allowed to do security administration in MLS systems. You need to login as security administrator (secadm) instead if you want to touch SELinux.
SELinux with the targeted policy is enabled and enforced on all Red Hat and Centos system out of the box, without secadm user. It's likely that this is the case here as well.
 
Old 08-06-2019, 06:27 AM   #6
dac.override
LQ Newbie
 
Registered: Oct 2016
Posts: 24

Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
SELinux with the targeted policy is enabled and enforced on all Red Hat and Centos system out of the box, without secadm user. It's likely that this is the case here as well.
This system does not enforce targeted policy. It enforces MLS policy.
 
Old 08-06-2019, 10:06 AM   #7
buckcosmos
LQ Newbie
 
Registered: Aug 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for the help everyone, this is all very interesting to me since I haven't really worked with anything like this before. I've been working on this a little more and originally tried just running a newrole command but got the output of

Error: you are not allowed to change levels on a non secure terminal

I checked /etc/securetty and ran the command chvt to change to tty2 which matched up with what was listed in /etc/securetty

Now I can create a new role, but I've never created anything like this before. Would it be easier to create a new user and assign them a role that would give them proper access, or would it be better to just re-assign the role of the root user?

Thanks again for all of the help!
 
Old 08-06-2019, 10:17 AM   #8
dac.override
LQ Newbie
 
Registered: Oct 2016
Posts: 24

Rep: Reputation: Disabled
No because you need root regardless of whether you use sysadm_r, secadm_r, or auditadm_r.

Newrole is cumbersome but you can make it a little less painful. For example you can add the "pam_rootok" pam module to newroles' pam stack so that you dont have to type root's password each time you run newrole.

You can also look into appending the "select_context" option to the "pam_selinux open" call in logins' pam stack. This will then make login ask you for a role and optionally a security level. You might then be able to just log in with one of the three administrator roles depending on what task you want to perform.

Unless you are familiar with the concept of confidentiality and "no read up/no write down" you probably should not try to manipulate the policy, as you might create holes in the model.
 
Old 08-06-2019, 10:42 AM   #9
dac.override
LQ Newbie
 
Registered: Oct 2016
Posts: 24

Rep: Reputation: Disabled
I am a bit rusty with MLS but if I recall correctly:

The staff_u SELinux identity *should* be authorized to the sysadm_r, auditadm_r, and secadm_r roles I believe.

So you could create a new user and associate that user with the existing staff_u identity. Something like: `useradd -Z staff_u joe`

Then you should be able to use `su` to switch to root and to use `newrole` to transition to any of the three privileged roles.

In theory I suppose you could create three seperate "staff_u" like identities and authorize each to a specific privileged role.

for example:
"joe_u { staff_r auditadm_r } s0-s15:c0.c1023"
"jane_u { staff_r sysadm_r } s0-s15:c0.c1023"
"foo_u { staff_r secadm_r } s0-s15:c0.c1023"

But they still need newrole to transition from staff_r to any of the privileged roles, the also need the root password to get root access with su. The auditadm_r, secadm_r, and sysadm_r roles are privileged roles that are meant to be associated with root afterall

And besides. if the root SELinux identity is authorized to all three privileged roles then any of the users with root password and physical access can access any of the three privileged roles anyway I suppose.
 
Old 08-06-2019, 10:47 AM   #10
dac.override
LQ Newbie
 
Registered: Oct 2016
Posts: 24

Rep: Reputation: Disabled
If I is important for you to be able to properly operate MLS systems then I suggest you install some virtualized systems, configure MLS and play with that a little in your spare time. It is not the easiest environment to operate in.
 
  


Reply



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
postfix and selinux [selinux updates broke postfix?] rjcroasdale Linux - Server 59 12-03-2019 11:17 PM
Implementing SeLinux on Debian 5 (Lenny) -- can't install "selinux-basics" bashFUL Linux - Security 3 10-17-2011 01:16 AM
SELinux errors, SELinux and wine ziphem Linux - Security 10 01-27-2011 04:15 PM
Selinux-how do i find out what domains have permissions on what type?(selinux policy) vishyc88 Linux - Security 2 11-22-2010 04:27 AM
"../system.h :selinux/selinux.h:no such file or directory" ashmita04 Linux From Scratch 4 02-05-2009 03:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:40 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