metarestore: Fix memory leak

Fix memory leak (it was found by valgrind when running
test_metadata_recovery) by refactoring merger's interface
to use std::string instead of c-style strings.

Change-Id: I5bb85a4ca99b69a39a8eb8158a5d57334cda3b39
mount: Fix getting xattrs for special inodes

.masterinfo file has to be readable by unpriviledged users in order to be
able to use mfstools. There was a bug in mfs_getxattr handler which caused
EPERM to be returned when kernel asked for ACLs for this inode. This commit
fixes this issue by making mount return empty xattrs for all special inodes.

Change-Id: Iad57757ac43b60d0a58c1c0892379a89a129b654
tests: Add assert_awk_finds[_no] assertions

These assertions help users to verify contents of long strings
in various tests. Eg.

  x=$(come-command-which-prints-a-lot-of-lines)
  # Assert that there is a line which has '5' as the second field
  assert_awk_finds '$2 == 5' "$x"
  # Assert that there is a line which begins with 'entry'
  # and has '5' as the second field
  assert_awk_finds '/^entry/ && $2 == 5'

Change-Id: I46004a553a77b38d2a626078bb73d77e5bcd7e01
tests: Add tests of manipulating permissions and ACLs

Add tests which verify correctness of operations which manipulate permissions
when ACLs are used on LizardFS.

The first test (test_acl_group_class) is very simple and verifies if setfacl
and getfacl work properly with LizardFS, ie:
* if getfacl returns what it should return
* if modifying permissions using chmod influences output of getfacl
* if modifying permissions using setfacl influences file's access mask
'default:' entries are not covered by this test.

The test_acl_behavior is a little more complicated: it tries to do the same
things in two directory trees: one on LizardFS and the other one on
a filesystem which natively supports ACLs (the one in in $TEMP_DIR). After
each step (setting some permissions using chmod or setfacl, copying files,
etc.) it verifies if access masks and results of getfacl are the same.

Change-Id: I991a3dae64679400b20c82bc03a3f08150be4d86
tests: Remove races from test_metadata_dump

The test suffered from a set of races when waiting for metadata to be dumped,
eg. some entries were added to changelog.0.mfs after reading version number
of the last entry. This commit modifies the test to wait for the dump to be
finished in a way that should always work and removes the race. Also some
refactoring has been made to avoid code duplication in the test.

Change-Id: I5dc2d9d62a8776c0eb6ff21a14f71285d9720195
common: hashfn: Fix redefinition of default template argument

Default values of template parameters should be specified at the first
declaration of this template.

Remove excess default argument specification from hashCombine definition.

Change-Id: I99ed40519ae412adfa9e441e82ad4c0a40c63715
common: Add classes for storing access control lists

Add classes which will be used in the future for storing ACLs
in different LizardFS modules and in network messages.

Change-Id: I103b1d6a61814631b7e54f9e8356358acc26a8b1
master: Define metadata filenames in filesystem.cc

Some time ago there were introduced definitions of filenames
"metadata.mfs.back" and "metadata.mfs.back.tmp" (which aren't all types of
"metadata.mfs" appearing in this source file) but weren't used in every place
in this source file. This commit adds remaining definitions and makes a use of
them.

Change-Id: Ie9d25b4f14464586741a7435ab7eec2d3a603ee1
master: Handle deserialization exceptions

Catch all deserialization exception in message handling code, respond
with disconnection from the client.

Change-Id: I92b3fc9a8d5cd2adade33a6e3268e16c05261eb6
common: Add serialization of AccessControlList

This will make it possible to transfer AccessControlList objects
over the network and serizalize them in metadata files.

Change-Id: Ic9dff8fa394f02da09acd8538d28b3e1916d4863
mount: Add option that enables ACL support

This commit adds a configuration option for enabling ACL support. It's
mostly needed by clients that don't have an OS that implements ACL
support within FUSE module.

Change-Id: I6413284cd054f0884034c5d631997626f651f1a9
common: Add network messages for ACL

Add description of the ACL protocol in MFSCommunication.h and functions for
serializing and deserializing these network messages. It will be used to
support Access Control Lists in LizardFS.

Change-Id: I850dcdc05d553df68b241ff87d793a3c1b72d04f
master: Remove copy-pasted code for storing metadata

There were three occurrences of procedure storing metadata
into disk file provided the files's descriptor to write to.
The procedure writes header and then the metadata body.

Change-Id: I5a8d4d556c41e2a3e3cd895b325cd52f739f0574
master: Add stubs for ACL requests

Add stubs so that it's possible to start implementing support for ACLs
in mount. The master server side will be finished in one of the next commits.

Change-Id: I0956d012bfe6245f08165fab01b52b8877c18d35
common: Fix compilation errors in acl_type.h

This header was missing some essential #include directives which
made other code not compile. This commit fixes the header file.

Change-Id: Ie2716f40467c79eb7350962601e8c5aaec5199fb
common: Fix uid/gid type in ExtendedAcl

User/group identifiers are 32-bit uint values but in ExtendedAcl they have been
stored as 16-bit ones. This commit fixes this.

Change-Id: I12fff9d5e24a1edafef372812909a5ab52997576
mount: Fix deadlock in mastercomm

The receiving thread acquires rec->mutex with fdMutex already held,
while worker threads tried to lock fdMutex with corresponding rec->mutex
already held.

Make worker threads release their rec->mutex before attempting to lock
fdMutex.

Change-Id: I26f913f8e6929f58f5e515734c39765f04f66580
master: Fix handling ACL packets

There was an error in the packet handling code -- only tools were able
to send ACL packets. This commit moves the code to the section designed
for mount <-> master communication.

Change-Id: If5e597303edc83a67d69dae03b7d1aa216464a55
master: Add support for access ACLs

This commit adds very basic support for access ACLs in the master server.
Some optimizations may be added in the future, eg. deduplication of
ExtendedAcl structures. The master server does not use these ACLs for
permission checks, so to use the mechanism one has to set nomasterpermcheck
session flag.

Change-Id: I24dab4f2093149b17c006817b4d237714612b9cc
common: Add ACL xattr <-> AccessControlList converter

ACL on Linux is stored as serialized struct of kernel in extended attributes,
so it's very inconvenient to use them directly. To allow an easy manipulation
on these data, this commit introduces a class which converts them to an
AccessControlList object (and vice versa). A definition of kernel structs have
been extracted from its sources and adapted to this use in this case.

Change-Id: I7e218ad349db410d0ae1ca42fa7b91bc95fd11f1