Justin Maggard [Mon, 10 Nov 2014 23:28:17 +0000 (15:28 -0800)]
cnid_metad: fix tsockfd_create() return value on error
We ran into a case where the netatalk log grew at an extremely rapid
pace. There was one message that kept repeating:
cnid_metad[2528] {usockfd.c:169} (E:CNID): error in accept: Socket
operation on non-socket
An strace showed pselect() getting called on stdin, rather than an
actual socket. Looking at the code, I see that tsockfd_create() will
return 0 instead of -1 if the call to getaddrinfo() fails, which is
obviously wrong.
Ross Lagerwall [Sun, 31 Aug 2014 07:14:24 +0000 (08:14 +0100)]
afpd: Return the correct error for non-existent volume
Return kFPObjectNotFound rather than kFPParamErr when openvol() is
called with a non-existent volume. This follows the specification and
Apple's implementation.
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com> Reviewed-by: Ralph Boehme <rb@sernet.de>
Ralph Boehme [Sat, 9 Aug 2014 06:26:15 +0000 (08:26 +0200)]
Spotlight: when to call tracker_sparql_cursor_next_async()
No need to call tracker_sparql_cursor_next_async() if the queue is in
SLQ_STATE_RESULTS state, as then the cursor callback will already have
called it in order to request more results.
HAT [Wed, 6 Aug 2014 13:23:08 +0000 (22:23 +0900)]
new option "case sensitive = yes|no", FR #62.
In spite of being case sensitive as a matter of fact, netatalk
3.1.3 and earlier did not notify kCaseSensitive flag to the client.
Now, it is notified correctly by default.
Ralph Boehme [Wed, 25 Jun 2014 09:46:03 +0000 (11:46 +0200)]
Writing metadata xattr on directories with sticky bit set, FR#94
Even though we may have write access to a directory, if the sticky bit
is set only the owner is allowed to write xattrs.
Add an option that enables behaviour to set the xattr as root, using
the fact that we can distinguish between a failing xattr set request
due to insufficient permissions (EACCES) or the sticky bit (EPERM):
force xattr with sticky bit = yes|no (default: no)
Ralph Boehme [Sat, 5 Jul 2014 06:14:41 +0000 (08:14 +0200)]
Hangs in Netatalk which causes it to stop responding to connections
Hangs in Netatalk which causes it to stop responding to
connections. The master afpd process gets stuck in a poll loop, being
repeatedly notified that there are connections on its socket, but
never actually doesn anything with them.
Analysis with gdb revealed that the dat astructure dealing with the
main AFP socket and the IPC client sockets was smashed. This could
happen because the function fdset_add_fd() doesn't do bound checking
itself but relied on other parts of the code that enforce a connection
limit. Unfortunately, for low-level AFP connections that don't result
in a full AFP login these checks come too late resulting in a buffer
overflow.
Add a bound check. While we're at it, rewrite the fdset code to use a
full blown data structure 'struct asev' encapsultating the
implementation details.
* ignore = UNIX chmod() requests are completely ignored
* preserve = preserve ZFS ACEs for named users and groups or POSIX ACL
group mask
* simple = just to a chmod() as requested without any extra steps
Ralph Boehme [Sun, 15 Jun 2014 04:07:10 +0000 (06:07 +0200)]
Resource fork conversion from AppleDouble v2 broken, bug #568
Converting from AppleDouble v2 to ea may corrupt the resource fork. In
some circumstances an offset calculation is wrong resulting in corrupt
resource forks after the conversion.
Ensure the resource fork AppleDouble entry offset is always set up and
we don't rely on the manual offset calculation.
Skip ADEID_RFORK in ad_copy_header() and allow copying of AppleDouble
entry that have an initial zero size in the destination adouble.
Ralph Boehme [Wed, 18 Jun 2014 14:54:24 +0000 (16:54 +0200)]
Fix a crash when accessing ._ files, bug #564
At least FreeBSD is picky in that it requires PROT_READ if we're going
to read a mmap()ed memory region mapped, only specifying PROT_WRITE
doesn't imply PROT_READ. Other OSen seem to handle this differently.
Also add a missing pointer reinitialisation to the buf pointer.
Reported-by: Sean Eric Fagan Signed-off-by: Ralph Boehme <rb@sernet.de>
Ralph Boehme [Tue, 17 Jun 2014 15:02:20 +0000 (17:02 +0200)]
Unarchiving certain ZIP archives fails, bug #569
The current code that checks whether the client is allowed to use
pathnames starting with ._ checks whether the file is an AppleDouble
file, and if it is and the filler does not contain the magic string
"Mac OS X", access to the file is denied. This results in the
following sequence of steps:
* client created empty file "._NAME"
* client wants to stat the newly created file "._NAME"
* server checks whether access to the file is allowed
* check fails
Modify check in ad_valid_header_osx() to allow access to all .-
AppleDouble files where the filler string is not "Netatalk", which is
the magic string Netatalk puts there.
Ralph Boehme [Wed, 4 Jun 2014 20:42:37 +0000 (22:42 +0200)]
Spotlight: "spotlight expr = false" broke the default Spotlight query
The default Spotlight query a Mac uses is
*=="test*"cwd || kMDItemTextContent=="test*"cwd
which is of course using a logic expression. The parser has an extra
rule for catching this (MATCH or MATCH) for the purpose of munging
both expression into a single fts:match SPARQL query. Which means
we shouldn't check whether logic expressions are enabled or not.
Ralph Boehme [Wed, 21 May 2014 14:42:58 +0000 (16:42 +0200)]
getvolbypath returns incorrect volume, bug #563
getvolbypath() would match a given path "/foo/barbaz" with an existing
volume path of "/foo/bar" because the strings where compared with
strnlen() where n is the length of "/foo/bar", ie we did a substring
match.
I faintly remember there was a reason for this, but I couldn't come up
with any sensible configuration of usage of dbd that would not also
work by simply using strcmp() instead of strmcmp().
Of course, in order for dbd to work with paths that included a
trailing slash, there's a need to adding some slash stripping code,
because our code (somehow) ensures (hopefully!) that in struct
vol.v_path is always stored with trailinsh slashes stripped.
Ralph Boehme [Wed, 19 Feb 2014 15:19:42 +0000 (16:19 +0100)]
Support for using $u username variable in AFP volume definitions
* Prepare CNID backend dbd for user variable expansion
* Store a struct vol pointer in the CNID db handles.
* Pass three arguments to the CNID daemon:
- the afp.conf volume section name
- the volume path
- an optional username
* Rename several struct elements by prefixing them with a struct tag,
helps catching bad or missing assignments.
* Disable uniconv, doesn't use laod_volumes() and thus wont work with
the new CNID dbd backend.