Mounting a dvd/iso with different SELinux fcontext on RHEL9

Posted by useless_debian_user@reddit | linuxadmin | View on Reddit | 5 comments

I'm preparing for my rhce and on one test exam one block of tasks wants the RHEL iso mounted on /var/ftp/repo

When using default settings, the iso gets mounted as iso9660_t when I'd need it to mount as public_content_t

Obviously if I set selinux to permissive/disabled, it "works" but that's not the right way to go about things

the whole dance of adding fcontext with semanage and restorecon don't work either:

[qwe@controller exama]$ sudo semanage fcontext -a -t public_content_t "/var/ftp/repo(/.*)?"
[qwe@controller exama]$ sudo restorecon -Rv /var/ftp/repo
[qwe@controller exama]$ ls -Zd /var/ftp/repo
system_u:object_r:iso9660_t:s0 /var/ftp/repo

What I would obviously need to do is mount the iso somewhere else, and copy the contents to /var/ftp/repo, then run restorecon against it, I just don't understand why the test exam was written this way

I ran through man fstab and mount, and there's the {fs,}context='whatever:values' options to use with regular filesystems but that doesn't seem to work with iso files as mount gives err32(mount: /var/ftp/repo: wrong fs type, bad option, bad superblock on /dev/sr0, missing codepage or helper program, or other error.)

To me it feels like this test exam was not tested or was tested with selinux disabled