Sharing your /home/username folder via Samba... Don't do what I did

So, on this page here: Making sure you're not a bot! (That’s supposed to be the “How to Create a Samba Share” page from the Fedora Docs website, but it keeps putting up that stupid 'Making sure you’re not a bot" bullsh!t, so I don’t know what to do to share the page properly.)

I’m stuck on this part:

  1. Check if the shared directory and sub-directories have the correct SELinux context.
ls -dZ /home/share

unconfined_u:object_r:samba_share_t:s0 /home/share

When I do that ls -dZ thingy it returns unconfined_us:object_4:user_home_dir_t:s0 /home/username So that’s definitely my problem – there’s no samba_share bit in there – but the instructions don’t tell me how to FIX this problem. I know it has something to do with SELinux, but I have no clue how to proceed from there.

Please keep in mind that what I’m sharing is my main /home/username folder, so I DO NOT want to do something that will screw up my regular read/write permissions.

Thanks.

Never mind. The solution was earlier on that page – since I didn’t create a new share (I shared my existing /home/username folder) I accidentally skipped right over it. Sorry.

Create a directory to be the share for jane, and set the correct SELinux context:

mkdir /home/jane/share
sudo semanage fcontext --add --type "samba_share_t" "/home/jane/share(/.*)?"
sudo restorecon -R ~/share

!!!EDIT!!!

DEAR GOD, DON’T DO WHAT I JUST DID!

The “solution” there is NOT the solution I was looking for! It works great – until you reboot. When you reboot, you cannot log in because you no longer have permission to access your /home/username folder!!!

Instead of all that rigamarole, after you’ve shared your /home/username folder in Samba, just do this one thing:

sudo setsebool -P samba_enable_home_dirs on

That’s it. None of the SELinux stuff or restorecon stuff is needed.

I literally wiped and re-installed Fedora 44 because I thought I’d somehow screwed up the encryption on my /home drive after attempting to get the TPM to auto-unlock it. Upon rebooting, I hit that /home/username Permission Denied error actually caused by my Samba “solution” above, but which I hadn’t come across yet because I hadn’t rebooted since sharing the folder and doing all that SELinux stuff… This time around, I did not do the auto-unlock thing, and finally realzed it must’ve been something not encryption-related. Had to be the SELinux permissions I changed when I shared my /home/username folder.

What a pain…

A side effect of efforts to prevent AI web scrapers making it impossible for real users to read the docs.

Like this: Press-Ctrl-K to insert a link