SELinux and Apparmor Flashcards

1
Q

Conf file where policies are defined (SELINUX mode and SELINUXTYPE)

A

/etc/selinux/config

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

View current SELinux mode

A

getenforce

se status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Set SELinux mode

A

setenforce enforcing= setenforce 1

setenforce permissive= setenforce 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Relable files on a system with SELinux labeling

A

touch /.autorelabel

and reboot the PC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Labels, SELinux context

A

ls -Z
netstat -lZ
ps -auxZ

user _u
role _r
type _t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Change SELinux context

A
  1. chcon -t httpd_sys_content_t /var/www/html/index.html
    Note, chcon will not survive a relabeling process
  2. If we are not sure what type should be, we can reference to a good known file and copy its context:
    chcon –reference /var/www/html /var/www/html/index.html
  3. semanage fcontext -a -t httpd_sys_content_t /var/www/html/index.html
    +
    restorecon -v httpd_sys_content_t /var/www/html/index.html
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Restore context to default type

A

restorecon -vR /var/www/html
R-recursive
v-verbose

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List all SE booleans

List booleans with descriptions

A

getsebool -a
semanage boolean -l

getsebool -a | grep httpd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Enable/Disable SE booleans

A

setsebool -P

-P-Persistent
setsebool -P ftpd_anon_write on
setsebool -P ftpd_anon_write off

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Generate a report with SELinux issues

Troubleshooting SE with journalctl

A
  1. sealert -a /var/log/audit/audit.log
  2. journalctl -xe
    - x-add explanation text
    - e- jump to the end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

View mapping of Linux to SELinux users

A

semanage login -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Map existing Linux user to SELinux user

A

semanage login -a -s [SELinux user] [Linux User]
-a- add
-m -modify
semanage login -a -s “staff_u” cloud_user

semanage login -m -S targeted -s “user_u” -r s) __default__

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Identify Linux user mapped to SELinux user

A

id -Z

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Delete SELinux user

A

semanage login -d [SELinux user]
-d -delete
semanage login -d cloud_user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Check SE users configured

A

semanage user -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Location of apparmor conf files

A

/etc/apparmore.d

17
Q

Check apparmor status

A

aa-status

apparmor_status

18
Q

Modes of apparmor

A

Complain

Enforce

19
Q

Switch profile to complain/enforce mode

A

aa-complain /usr/bin/man

aa-enforce /sbin/dhclient

20
Q

Switch apparmor between modes

A

aa-complain

aa-enforce

21
Q

Create a new AppArmor profile for Xtightvnc

A

aa-genprof Xtightvnc