saltstack/salt — pull request #10219 by nshalman (2014-02-05 22:00:47+00:00)
Title: cherry-pick #10093 onto 0.17 branch

According to the SunOS man page on flock:
flock() applies or removes an advisory lock on the file associ-
ated with the file descriptor fd. The compatibility version of
flock() has been implemented on top of fcntl(2) locking. It does
not provide complete binary compatibility

This lack of binary compatibility results in some odd behavior when
running salt-master on a SunOS/SmartOS host. Specifically an IOError
[Errno 9] is thrown whenever the master calls the file_hash method.

Specifically it has to do with the fact that on SunOS/SmartOS the lock
is released when the file is closed, whereas in Linux the lock is kept
until it is released. An article discussing the problem in detail can be
found here:

http://infinitesque.net/articles/2010/on%20Python%20flock/index.html

To get this working I changed salt/fileserver/roots.py to check os.uname()
to make sure it's not a SunOS host when setting HAS_FCNTL. Comments indicate
Windows shouldn't have this set either.