Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem with SELinux while being attached through lxd-agent
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
doskanoness
n00b
n00b


Joined: 06 Oct 2021
Posts: 45

PostPosted: Tue Nov 23, 2021 12:29 pm    Post subject: Problem with SELinux while being attached through lxd-agent Reply with quote

Hey, I'm going to prepare a hardened SELinux virtual machine for the LXD with Gentoo. I have a problem with the message
Code:
!!! Failed to set new SELinux execution context. Is your current SELinux context allowed to run Portage?

when I emerge whatever package:
Code:
gentoo-hardened-selinux-nomultilib ~ # emerge -NuDav @world

 * IMPORTANT: 14 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.


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

Calculating dependencies... done!
[ebuild   R    ] sys-libs/pam-1.5.1_p20210622-r1::gentoo  USE="(audit) filecaps* (selinux) (split-usr) -berkdb -debug -nis" 826 KiB
[ebuild   R    ] dev-libs/openssl-1.1.1l:0/1.1::gentoo  USE="asm -bindist* -rfc3779 -sctp -sslv3 -static-libs -test -tls-compression -tls-heartbeat -vanilla" CPU_FLAGS_X86="(sse2)" 9604 KiB
[ebuild   R    ] dev-libs/libpcre2-10.37-r2:0/3::gentoo  USE="bzip2 pcre16 readline recursion-limit (split-usr) unicode zlib -jit* -libedit -pcre32 -static-libs" 1691 KiB
[ebuild   R    ] net-misc/openssh-8.6_p1-r2::gentoo  USE="(audit) pam (pie) scp (selinux) ssl -X -X509 -bindist* (-debug) -hpn -kerberos -ldns -libedit -livecd -sctp -security-key -static -test -xmss" 1745 KiB
[ebuild   R    ] net-misc/iputils-20210722-r1::gentoo  USE="arping (caps) filecaps* ipv6 nls ssl -clockdiff -doc -gcrypt -idn -nettle -rarpd -rdisc -static -test -tftpd -tracepath -traceroute6" 538 KiB

Total: 5 packages (5 reinstalls), Size of downloads: 14401 KiB

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

>>> Verifying ebuild manifests

>>> Running pre-merge checks for net-misc/openssh-8.6_p1-r2

>>> Emerging (1 of 5) sys-libs/pam-1.5.1_p20210622-r1::gentoo
 * Fetching files in the background.
 * To view fetch progress, run in another terminal:
 * tail -f /var/log/emerge-fetch.log
 * pam-1.5.1_p20210622.tar.gz BLAKE2B SHA512 size ;-) ...                             [ ok ]
 * pam-doc-1.5.1_p20210610.tar.xz BLAKE2B SHA512 size ;-) ...                         [ ok ]
!!! Failed to set new SELinux execution context. Is your current SELinux context allowed to run Portage?
>>> Unpacking source...
>>> Unpacking pam-1.5.1_p20210622.tar.gz to /var/tmp/portage/sys-libs/pam-1.5.1_p20210622-r1/work
>>> Unpacking pam-doc-1.5.1_p20210610.tar.xz to /var/tmp/portage/sys-libs/pam-1.5.1_p20210622-r1/work
>>> Source unpacked in /var/tmp/portage/sys-libs/pam-1.5.1_p20210622-r1/work
!!! Failed to set new SELinux execution context. Is your current SELinux context allowed to run Portage?
>>> Preparing source in /var/tmp/portage/sys-libs/pam-1.5.1_p20210622-r1/work/linux-pam-fe1307512fb8892b5ceb3d884c793af8dbd4c16a ...
 * Running eautoreconf in '/var/tmp/portage/sys-libs/pam-1.5.1_p20210622-r1/work/linux-pam-fe1307512fb8892b5ceb3d884c793af8dbd4c16a' ...
 * Running 'autopoint --force' ...
^C

Exiting on signal 2

This error doesn't occur when I emerge package while being logged in through SSH instead of lxd-agnet.
Code:
gentoo-hardened-selinux-nomultilib ~ # emerge --info
Portage 3.0.28 (python 3.9.8-final-0, default/linux/amd64/17.1/no-multilib/hardened/selinux, gcc-11.2.0, glibc-2.33-r7, 5.10.78-gentoo-dist x86_64)
=================================================================
System uname: Linux-5.10.78-gentoo-dist-x86_64-Intel-R-_Core-TM-_i7-8750H_CPU_@_2.20GHz-with-glibc2.33
KiB Mem:    15253280 total,  14867232 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Tue, 23 Nov 2021 08:30:01 +0000
Head commit of repository gentoo: 6f4b1c555fca194d9f81eb6b30d9039acb25a717
sh bash 5.1_p8
ld GNU ld (Gentoo 2.37_p1 p0) 2.37
app-shells/bash:          5.1_p8::gentoo
dev-lang/perl:            5.34.0-r3::gentoo
dev-lang/python:          3.9.8::gentoo
sys-apps/baselayout:      2.7-r3::gentoo
sys-apps/openrc:          0.44.8::gentoo
sys-apps/sandbox:         2.25::gentoo
sys-devel/autoconf:       2.71-r1::gentoo
sys-devel/automake:       1.16.4::gentoo
sys-devel/binutils:       2.37_p1::gentoo
sys-devel/gcc:            11.2.0::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts:

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch preserve-libs protect-owned qa-unresolved-soname-deps sandbox selinux sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j12"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 audit bzip2 caps crypt hardened iconv ipv6 libglvnd libtirpc ncurses nls nptl openmp pam pcre pie readline seccomp selinux split-usr ssl ssp unicode xattr xtpax zlib" ABI_X86="64" ADA_TARGET="gnat_2019" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26 ruby27" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS

id -Z output while being logged through SSH:
Code:
gentoo-hardened-selinux-nomultilib ~ # id -Z
root:sysadm_r:sysadm_t

id -Z output while being attached through lxd-agent:
Code:
gentoo-hardened-selinux-nomultilib ~ # id -Z
system_u:system_r:kernel_t
gentoo-hardened-selinux-nomultilib ~ # newrole -r sysadm_r
system_u:sysadm_r:sysadm_t is not a valid context

I tried to execute commands from the section "Supporting service administration" on https://wiki.gentoo.org/wiki/SELinux/Installation#Installing_policies_and_utilities.2C_part_one without satisfying results.
Any ideas how to get rid of the message "!!! Failed to set new SELinux execution context. Is your current SELinux context allowed to run Portage?" while being attached through lxd-agent?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3875

PostPosted: Tue Nov 23, 2021 12:46 pm    Post subject: Reply with quote

Hi maybe login with
Code:

lxc exec <container-name> -- sudo --login --user root


Then if needed change role
Code:

newrole -r sysadm_r

If not just use ssh.
_________________
:)
Back to top
View user's profile Send private message
doskanoness
n00b
n00b


Joined: 06 Oct 2021
Posts: 45

PostPosted: Tue Nov 23, 2021 2:48 pm    Post subject: Reply with quote

It doesn't solve the problem

Code:
┌─[doskanoness@gentoo] - [~/Operating systems/Gentoo] - [2021-11-23 03:47:07]
└─[1] <> lxc exec gentoo-hardened-selinux-nomultilib -- sudo --login --user root                                                                                              ⚡[▶▶▶▶▶▶▶▶▶▷]
gentoo-hardened-selinux-nomultilib ~ # id -Z
system_u:system_r:kernel_t


Is there any way to get root:sysadm_r:sysadm_t while attaching with lxd exec/shell?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum