Jira (PUP-11603) Puppet Wont Write SELinux Labels on ZFS

14 views
Skip to first unread message

Daniel Milnes (Jira)

unread,
Aug 5, 2022, 7:35:03 AM8/5/22
to puppe...@googlegroups.com
Daniel Milnes created an issue
 
Puppet / Bug PUP-11603
Puppet Wont Write SELinux Labels on ZFS
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2022/08/05 4:34 AM
Priority: Normal Normal
Reporter: Daniel Milnes

Puppet Version: 7.16.0
Puppet Server Version:
OS Name/Version: Rocky Linux 8.6

Puppet believes that ZFS does not support SELinux labels, so ZFS mountpoints are not automatically relabeled. However since OpenZFS 0.6.3 this is not the case (Commit). This means that currently you have to do something like the following to not break anything that lives inside a ZFS mount on a SELinux enforcing system. Just having a `File` for the mountpoint is not enough.

zfs { 'tstpool/tstfs':
  ensure     => present,
  mountpoint => '/var/log/forwarded',
  notify     => Exec['/sbin/restorecon /var/log/forwarded'],
}
 
exec { '/sbin/restorecon -Rv /var/log/forwarded':
  refreshonly => true,
}

You can reproduce this with the following steps:

  1. Define a ZFS filesystem

    zfs { 'zpool1/testing':
            ensure     => present,
            mountpoint => '/var/log/test',
    }
     
    file { '/var/log/test':
            ensure  => directory,
            require => Zfs['zpool1/testing'],
    }
    

  2. Run Puppet with the manifest you create. Below is the relevant section of the trace output. Note that the use of `require` here is to prevent subdirectories being created before the the mountpoint is set.

    Info: Applying configuration version '1659697804'
    Debug: /Stage[main]/Main/File[/mnt/testing]/require: require to Zfs[zpool1/testing]
    Debug: Executing: '/sbin/zfs list zpool1/testing'
    Debug: Executing: '/sbin/zfs create -o mountpoint=/var/log/test zpool1/testing'
    Notice: /Stage[main]/Main/Zfs[zpool1/testing]/ensure: created
    Debug: /Stage[main]/Main/Zfs[zpool1/testing]: The container Class[Main] will propagate my refresh eventDebug: /File[/var/log/test]/seluser: SELinux not available for this filesystem. Ignoring parameter.
    Debug: /File[/var/log/test]/selrole: SELinux not available for this filesystem. Ignoring parameter.
    Debug: /File[/var/log/test]/seltype: SELinux not available for this filesystem. Ignoring parameter.
    Debug: /File[/var/log/test]/selrange: SELinux not available for this filesystem. Ignoring parameter.
    Debug: /File[/var/log/test/test.txt]/seluser: SELinux not available for this filesystem. Ignoring parameter.
    Debug: /File[/var/log/test/test.txt]/selrole: SELinux not available for this filesystem. Ignoring parameter.
    Debug: /File[/var/log/test/test.txt]/seltype: SELinux not available for this filesystem. Ignoring parameter.
    Debug: /File[/var/log/test/test.txt]/selrange: SELinux not available for this filesystem. Ignoring parameter.Debug: Class[Main]: The container Stage[main] will propagate my refresh event
    Debug: Finishing transaction 12520
    Debug: Storing state
    Debug: Pruned old state cache entries in 0.00 seconds
    Debug: Stored state in 0.06 seconds
    Notice: Applied catalog in 0.28 seconds
    

  3. Check the SELinux label on the directory

    $ ls -Zd /var/log/testsystem_u:object_r:unlabeled_t:s0 /var/log/test 

  4. Run `restorecon` to see what label should have been applied

    $ restorecon -Rv /var/log/test
    Relabeled /var/log/test from system_u:object_r:mnt_t:s0 to system_u:object_r:var_log_t:s0
    Relabeled /var/log/test/test.txt from unconfined_u:object_r:unlabeled_t:s0 to unconfined_u:object_r:var_log_t:s0

The same works if you define a file inside the mount.

file { '/var/log/test/test.txt':
        content => 'test',
}

Desired Behavior:

Puppet should use matchpathcon like it does with other filesystems to fix the label of both the mountpoint and files within.

Actual Behavior:

Puppet does not relabel the mountpoint or the files within because it believes it cannot.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Daniel Milnes (Jira)

unread,
Aug 5, 2022, 7:52:02 AM8/5/22
to puppe...@googlegroups.com

Morgan Rhodes (Jira)

unread,
Aug 9, 2022, 4:10:01 PM8/9/22
to puppe...@googlegroups.com

Morgan Rhodes (Jira)

unread,
Aug 9, 2022, 4:10:02 PM8/9/22
to puppe...@googlegroups.com
Morgan Rhodes updated an issue
Change By: Morgan Rhodes
Sprint: Phoenix 2022-08-31

Morgan Rhodes (Jira)

unread,
Aug 17, 2022, 12:37:01 PM8/17/22
to puppe...@googlegroups.com

Michael Hashizume (Jira)

unread,
Sep 7, 2022, 4:55:03 PM9/7/22
to puppe...@googlegroups.com
Michael Hashizume updated an issue
Change By: Michael Hashizume
Release Notes: Enhancement
Release Notes Summary: Marks ZFS as an SELinux-Capable Filesystem

Parker Leach (Jira)

unread,
Sep 12, 2022, 12:28:03 PM9/12/22
to puppe...@googlegroups.com
Parker Leach updated an issue
Change By: Parker Leach
Labels: docs_reviewed
Reply all
Reply to author
Forward
0 new messages