# selinux installation problem

## GNUtoo

emerge -av selinux-base-policy

These are the packages that would be merged, in order:

Calculating dependencies... done!

INCOMPLETE MERGE: /var/db/pkg/sec-policy/-MERGING-selinux-base-policy-20061015

[ebuild  N    ] sec-policy/selinux-base-policy-20061015  0 kB

Total size of downloads: 0 kB

Would you like to merge these packages? [Yes/No] y

>>> Emerging (1 of 1) sec-policy/selinux-base-policy-20061015 to /

 * refpolicy-20061015.tar.bz2 MD5  :Wink:  ...                                 [ ok ]

 * refpolicy-20061015.tar.bz2 RMD160  :Wink:  ...                              [ ok ]

 * refpolicy-20061015.tar.bz2 SHA1  :Wink:  ...                                [ ok ]

 * refpolicy-20061015.tar.bz2 SHA256  :Wink:  ...                              [ ok ]

 * refpolicy-20061015.tar.bz2 size  :Wink:  ...                                [ ok ]

 * checking ebuild checksums  :Wink:  ...                                      [ ok ]

 * checking auxfile checksums  :Wink:  ...                                     [ ok ]

 * checking miscfile checksums  :Wink:  ...                                    [ ok ]

 * checking refpolicy-20061015.tar.bz2  :Wink:  ...                            [ ok ]

!!! SELinux module not found. Please verify that it was installed.

>>> Unpacking source...

>>> Unpacking refpolicy-20061015.tar.bz2 to /var/tmp/portage/selinux-base-policy-20061015/work

>>> Source unpacked.

>>> Compiling source in /var/tmp/portage/selinux-base-policy-20061015/work/ ...

Creating policy.xml

Creating strict base module base.conf

Compiling strict base module

/usr/bin/checkmodule:  loading policy configuration from /var/tmp/portage/selinux-base-policy-20061015/work//strict/base.conf

/usr/bin/checkmodule:  policy configuration loaded

/usr/bin/checkmodule:  writing binary representation (version 6) to /var/tmp/portage/selinux-base-policy-20061015/work//strict/tmp/base.mod

Creating strict base module file contexts.

Creating netfilter network labeling rules

Creating strict base module package

Creating targeted base module base.conf

Compiling targeted base module

/usr/bin/checkmodule:  loading policy configuration from /var/tmp/portage/selinux-base-policy-20061015/work//targeted/base.conf

/usr/bin/checkmodule:  policy configuration loaded

/usr/bin/checkmodule:  writing binary representation (version 6) to /var/tmp/portage/selinux-base-policy-20061015/work//targeted/tmp/base.mod

Creating targeted base module file contexts.

Creating netfilter network labeling rules

Creating targeted base module package

>>> Source compiled.

>>> Test phase [not enabled]: sec-policy/selinux-base-policy-20061015

>>> Install selinux-base-policy-20061015 into /var/tmp/portage/selinux-base-policy-20061015/image/ category sec-policy

Installing strict base.pp policy package.

Installing strict policy headers.

Installing targeted base.pp policy package.

Installing targeted policy headers.

>>> Completed installing selinux-base-policy-20061015 into /var/tmp/portage/selinux-base-policy-20061015/image/

man:

>>> Merging sec-policy/selinux-base-policy-20061015 to /

>>> Setting SELinux security labels

/etc/selinux/targeted/contexts/files/file_contexts: No such file or directory

!!! ERROR: sec-policy/selinux-base-policy-20061015 failed.

Call stack:

  misc-functions.sh, line 417:   Called preinst_selinux_labels

  misc-functions.sh, line 342:   Called die

!!! Failed to set SELinux security labels.

!!! If you need support, post the topmost build error, and the call stack if relevant.

!!! post preinst failed; exiting.

!!! FAILED preinst: 1

----------

## xathin

I am also getting this error.  I looked, and the directory /etc/selinux/targeted/ does not exist, and I followed the instructions on http://www.gentoo.org/proj/en/hardened/selinux/selinux-handbook.xml?part=2 for an existing linux install, but can't get past installing selinux-base-policy.

I am attempting to install selinux-base-policy-20061114.

----------

## GNUtoo

you must use a 2005.1 stage3 then upgrade to the 2006.1 profile and recompile evrything

----------

## xathin

 *GNUtoo wrote:*   

> you must use a 2005.1 stage3 then upgrade to the 2006.1 profile and recompile evrything

 

So, does that mean you can't install SELinux from an already installed system?  Or can you just use the 2005.1 profile and build from that?

----------

## GNUtoo

 *xathin wrote:*   

>  *GNUtoo wrote:*   you must use a 2005.1 stage3 then upgrade to the 2006.1 profile and recompile evrything 
> 
> So, does that mean you can't install SELinux from an already installed system?  Or can you just use the 2005.1 profile and build from that?

 

yes that is a problem

----------

## momofuku

I managed to solve this problem by simply creating the dirs and the file:

```

mkdir /etc/selinux/targeted/contexts

mkdir /etc/selinux/targeted/contexts/files

touch /etc/selinux/targeted/contexts/files/file_contexts

```

and then re-emerging selinux-base-policy.

After that the emerge succeds and the file /etc/selinux/targeted/contexts/files/file_contexts is recreated.

----------

## JohnerH

I know this my sound a bit dumb but, is there actually a gentoo guide for SELinux installation from scratch? As in, u have a new box you and you want to install SELinux from the very beggning?

Thank you in advance for the help,

Joao

----------

