74 lines
2.8 KiB
Markdown
74 lines
2.8 KiB
Markdown
+++
|
|
title = 'Samba "ea support" Tips'
|
|
date = 2012-08-05T05:18:00Z
|
|
+++
|
|
|
|
At home, I use [Samba](http://www.samba.org/) as one of the methods for
|
|
exposing the data on my file server to the rest of my network (the others being
|
|
SFTP, FTPS, and NFS). In addition, I use [Folder
|
|
Redirection](http://technet.microsoft.com/en-us/library/cc732275.aspx) and
|
|
[Offline
|
|
Files](http://technet.microsoft.com/en-us/library/gg277982%28v=ws.10%29.aspx)
|
|
to keep my _Documents_, _Pictures_, and _Videos_ folders in sync on all of my
|
|
machines. In order to maintain the nifty appearance of those special folders,
|
|
the file attributes for the `desktop.ini` file in each one must be preserved.
|
|
Samba can do this in one of two ways:
|
|
|
|
* Mapping DOS file attributes to UNIX permissions
|
|
* Storing the DOS attributes in [extended file
|
|
attributes](http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#STOREDOSATTRIBUTES)
|
|
|
|
I prefer the latter method since I also access the files from Linux machines,
|
|
so changing the permissions of files is not appropriate.
|
|
|
|
To enable storing of DOS attributes in extended file attributes, the following
|
|
lines must be added to each share definition in `smb.conf`:
|
|
|
|
```ini
|
|
ea support = yes
|
|
map hidden = no
|
|
map system = no
|
|
map archive = no
|
|
map readonly = no
|
|
store dos attributes = yes
|
|
```
|
|
|
|
In order for it to work, though, the filesytem containing the files must
|
|
support extended attributes. My file server uses XFS, which needs no special
|
|
mount options. Ext3/4 need the `user_xattr` mount option set.
|
|
|
|
On occassion, I have noticed that sometimes, Samba seems to ignore the extended
|
|
attribute values. Setting file attributes from Windows does nothing (i.e. the
|
|
changes are not saved), and setting the `user.DOSATTRIB` extended attribute
|
|
manually with `setfattr` has no effect. In all cases that I have encountered,
|
|
this is because Samba encounters a file or directory from which it cannot read
|
|
the extended attributes. For me, this has been because I had mounted a
|
|
different filesystem that did not support extended attributes on a subdirectory
|
|
of a share. Apparently, once Samba encounters one file it cannot read, it stops
|
|
processing extended attributes altogether.
|
|
|
|
The `user.DOSATTRIB` extended attribute contains a bit field indicating the
|
|
state of each DOS attribute:
|
|
|
|
```
|
|
Read-Only = 0x1
|
|
Hidden = 0x2
|
|
System = 0x4
|
|
Archive = 0x20
|
|
```
|
|
|
|
Use the `getfattr` command to view the current attributes:
|
|
|
|
```
|
|
dustin@rigel ~/Documents $ getfattr -n user.DOSATTRIB desktop.ini
|
|
# file: desktop.ini
|
|
user.DOSATTRIB="0x6"
|
|
```
|
|
|
|
Use the `setfattr` command to manually set a file's attributes:
|
|
|
|
```
|
|
dustin@rigel ~/Documents $ setfattr -n user.DOSATTRIB -v '"0x6"' desktop.ini
|
|
```
|
|
|
|
(Note the escaping of the quotes in the value; this is needed to force the extended attribute to contain a string instead of an integer) |