Skip to content

Instantly share code, notes, and snippets.

@Infiniti151
Last active September 1, 2026 12:08
Show Gist options
  • Select an option

  • Save Infiniti151/b84f235efda2a815c806ed4088aec066 to your computer and use it in GitHub Desktop.

Select an option

Save Infiniti151/b84f235efda2a815c806ed4088aec066 to your computer and use it in GitHub Desktop.
Share systemd User Config Over Samba in Fedora 44

Share systemd User Config Over Samba in Fedora 44

Systemd user config (~/.config/systemd/user/*) typically cannot be shared over Samba due to different SELinux context (unconfined_u:object_r:systemd_unit_file_t:s0) than home files (unconfined_u:object_r:user_home_t:s0), even if home directory sharing is turned on (sudo setsebool -P samba_enable_home_dirs on). In order to share them, we need to add a custom SELinux policy module.

1. Generate the type enforcement (.te) file

Try to connect to the systemd user folder with your phone.

Check the denial with:

sudo ausearch -m AVC -c smbd --start recent

It should show as:

----
time->Sat Jun 27 15:25:48 2026
type=AVC msg=audit(1782554148.035:485): avc:  denied  { read } for  pid=26265 comm="smbd[192.168.0." name="user" dev="dm-1" ino=3687733 scontext=system_u:system_r:smbd_t:s0 tcontext=unconfined_u:object_r:systemd_unit_file_t:s0 tclass=dir permissive=0

Generate a .te file with read permission:

sudo ausearch -m AVC -c smbd --start recent | audit2allow -M my_samba_systemd

2. Generate the module file (.mod) from the type enforcement file (.te)

sudo checkmodule -M -m -o my_samba_systemd.mod my_samba_systemd.te

3. Generate the policy package (.pp) from the module file (.mod)

sudo semodule_package -o my_samba_systemd.pp -m my_samba_systemd.mod

4. Install the policy package

sudo semodule -i my_samba_systemd.pp

The command automatically compiles and immediately loads the new policy rules straight into the running kernel. It takes effect instantly.

5. Verify the module

sudo semodule -l | grep my_samba_systemd

6. Restart Samba service

sudo systemctl restart smb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment