#=====================================
# Enable Selinux permissive
#-------------------------------------
/usr/bin/sed -i -e "s/SELINUX=[^\n]*/SELINUX=permissive/g" /etc/selinux/config
and I have these SELinux packages in config.kiwi:
<package name="selinux-policy-targeted"/><package name="policycoreutils"/>
<type image="oem" boot="oemboot/rhel-07.0" filesystem="ext3" installiso="true" installpxe="true" bootloader="grub2"
kernelcmdline="selinux=1 console=ttyS0,115200 console=tty0" firmware="efi" hybrid="true">
After boot, context is completely off.
[root@localhost ~]# ps -efZ |grep tomcat system_u:system_r:kernel_t:s0 tomcat 11969 1 48 17:22 ? 00:03:48 /usr/bin/java -Dlog4j.configurationFile=file:/etc/opt/xxx/xxx/log4j2_tomcat.xml -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat -Dcatalina.home=/usr/share/tomcat -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat/temp -Djava.util.logging.config.file=/usr/share/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start [root@localhost efivar]# ps -efZ |grep http system_u:system_r:kernel_t:s0 root 11911 1 0 17:22 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND system_u:system_r:kernel_t:s0 apache 12072 11911 0 17:22 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND system_u:system_r:kernel_t:s0 apache 12073 11911 0 17:22 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND system_u:system_r:kernel_t:s0 apache 12074 11911 0 17:22 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
#version=RHEL7 # System authorization information auth --enableshadow --passalgo=sha512 # Use network installation url --url="http://buildlogs.centos.org/centos/7/os/x86_64-20140614/" # Use text mode install text # Keyboard layouts keyboard --vckeymap=us --xlayouts='us' # System language lang en_US.UTF-8 # Network information network --bootproto=dhcp --device=eth0 --ipv6=auto --activate network --hostname=centos7previewkickstarttest # Root password rootpw some-password # Do not configure the X Window System skipx # System timezone timezone Europe/Amsterdam --isUtc #user --groups=wheel --name=useraccount --password=some-password --gecos="User" # Skip EULA eula --agreed # Disable firewall firewall --disabled # Don't run the Setup Agent on first boot firstboot --disabled # Selinux (ENFORCING|permissive|disabled) selinux --enforcing <-------------------------------------------------
}
Is something similar required for kiwi?
Virt-builder does not know how to give new files a label, so there are two possible strategies it can use to ensure correct labelling:
This runs fixfiles(8) just before finalizing the guest, which sets SELinux labels correctly in the disk image.
Sometimes fixfiles is not possible during installation, in which case this option falls back on:
[ INFO ]: 10:01:11 | Syncing system to image[ INFO ]: 10:01:11 | --> Syncing EFI boot data to EFI partition[ ERROR ]: 10:01:11 | KiwiCommandError: rsync: stderr: rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/."","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/BOOT"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/BOOT/.bootx64.efi.5fZ4YB"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/BOOT/.earlyboot.cfg.XA8kZT"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/centos"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/centos/.gcdx64.efi.1FUBZb"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/centos/.grubx64.efi.dKon1t"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/centos/fonts"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/tmp/kiwi_filesystem.awnry426/EFI/centos/fonts/.unicode.pf2.5BUJ5L"","security.selinux") failed: Operation not supported (95)rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1165) [sender=3.1.1], stdout: (no output on stdout)[ INFO ]: 10:01:11 | Cleaning up InstallImageBuilder instance[ INFO ]: 10:01:11 | Cleaning up FileSystemFat16 instance[ INFO ]: 10:01:11 | Cleaning up BootImageKiwi instance[ INFO ]: 10:01:12 | Cleaning up Disk instance[ INFO ]: 10:01:12 | Cleaning up LoopDevice instanceI compared the steps between kiwi 7 and kiwi 8.kiwi 7 did cp -a whereas kiwi 8 is doing rsync -a.I am also referring to the doc mentioned at https://ibboard.co.uk/Linux/httpd-from-vfat-with-selinux.html which states that "but FAT file systems cannot store context data"It seems cp as well as rsync cannot copy extended attributes to fat16 as fat16 doesn't support them but return code of cp is 0 where as rsync fails with error.
To test it further,I created a 200MB partition and created FAT16NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 32G 0 disk|-sda1 8:1 0 2M 0 part|-sda2 8:2 0 200M 0 part /boot/efi`-sda3 8:3 0 31.8G 0 part /sdb 8:16 0 200M 0 disk /mnt/dosfs <--------sr0 11:0 1 1024M 0 rom
/dev/sdb on /mnt/dosfs type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
and in rsync, I got the same error:[root@localhost ~]# rsync -a -v -H -X -A --one-file-system /boot/efi /mnt/dosfs/sending incremental file listefi/efi/EFI/efi/EFI/BOOT/efi/EFI/BOOT/bootx64.efiefi/EFI/BOOT/grub.cfgrsync: rsync_xal_set: lsetxattr(""/mnt/dosfs/efi"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/mnt/dosfs/efi/EFI"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/mnt/dosfs/efi/EFI/BOOT"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/mnt/dosfs/efi/EFI/BOOT/.bootx64.efi.nd5jjU"","security.selinux") failed: Operation not supported (95)rsync: rsync_xal_set: lsetxattr(""/mnt/dosfs/efi/EFI/BOOT/.grub.cfg.dqdM91"","security.selinux") failed: Operation not supported (95)
sent 737170 bytes received 67 bytes 1474474.00 bytes/sectotal size is 736809 speedup is 1.00rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]
getfattr -n security.selinux EFI/ <---------------------getfattr errors EFI/: security.selinux: Operation not supported
[root@localhost ~]# cp -ar /boot/efi /mnt/dosfs/ <------no error but getfattr throws error[root@localhost ~]#getfattr -n security.selinux EFI/EFI/: security.selinux: Operation not supported.