[CentOS] Samba HOWTO wiki bug: chcon samba_share_t

Fri May 4 22:11:57 UTC 2018
Louis Lagendijk <louis at fazant.net>

On Fri, 2018-05-04 at 14:55 -0700, Akemi Yagi wrote:
> On Fri, May 4, 2018 at 2:26 PM, Warren Young <warren at etr-usa.com>
> wrote:
> > On May 4, 2018, at 3:03 PM, Akemi Yagi <amyagi at gmail.com> wrote:
> > > 
> > > On Fri, May 4, 2018 at 12:03 PM, Warren Young <warren at etr-usa.com
> > > > wrote:
> > > > 
> > > >    $ sudo chcon -R -t samba_share_t /path/to/share
> > > 
> > > Updated the page as suggested. Thanks.
> > 
> > Thanks!
> > 
> > I now see another instance of this in section 3.  Instead of
> > copying the text verbatim, it should probably be:
> > 
> >     chcon -R -t samba_share_t /mnt/data
> > 
> > …in order to match the text above it.
> 
> Warren,
> 
> I was just informed that the chcon command your suggested was
> originally there, but it was replaced with the 2 line version
> sometime
> ago. The reason given was "Replace chcon by semanage/restorecon pair
> to survive filesystem relabel".

The comment is correct: chcon will not survive a relabel. You need to
update the database first (semanage fcontext) and then let a relabel
apply the new context.

Louis