Frank Lahm [Mon, 31 Dec 2012 13:50:50 +0000 (14:50 +0100)]
Consolidate all Netatalk specific conversion in pull_charset_flags()
Netatalk specific conversion like '/' <-> ':' and CAP de-/encoding
was performed partially in pull_charset_flags() and push_charset_flags().
The resulting code was unmaintainable and as a result it failed to
to the proper conversion of ':' to '/' for an UTF8 -> UTF8-MAC
conversion.
Moving all Netatalk specific conversion to pull_charset_flags()
we can now easily do the necessary conversion in one place.
* ":xx" CAP sequences are decoded if CONV_UNESCAPEHEX is used
* ':' and '/' are CAP encoded if CONV_ESCAPEHEX is used
* ':' is converted to '/' only for a conversion whos target charset
is UTF8-MAC and whos source charset is NOT UTF8-MAC
* '/' is converted to ':' only for a conversion whos source charset
is UTF8-MAC and whos target charset is NOT UTF8-MAC
* a leading '.' is CAP encoded if CONV_ESCAPEDOTS is used
This consolidation obsoletes both CONV_ALLOW_COLON and CONV_ALLOW_SLASH
conversion options.
Frank Lahm [Wed, 14 Nov 2012 15:02:41 +0000 (16:02 +0100)]
Configurable symlink behaviour
Add a new volumes option 'follow symlinks'. The default setting is
false, symlinks are not followed on the server. This is the same
behaviour as OS X's AFP server.
Setting the option to true causes afpd to follow symlinks on the
server. symlinks may point outside of the AFP volume, currently
afpd doesn't do any checks for "wide symlinks".
In order to provide a somewhat consistent interface, add an API
of o* function wrappers for filesytem related functions.
These functions take an an additonal option arg (hence the o) which
tells the functions whether symlinks shall be followed or not.
Ralph Boehme [Mon, 10 Dec 2012 17:38:07 +0000 (18:38 +0100)]
Restructure opening and deleting the CNID dbs and CNID wraparound support
If opening the db fails, delete it and recreate a new empty one.
Add handling of CNID overflow, ie when the last used CNID reaches
its maximum (UINT32_MAX), wrap around to CNID_START. This then neccesites
a modification to get_id() where we used to just increment the last
used CNID counter and use that as next CNID.
Now we need to ensure that it isn't already used in the db and keep
searching for an used in case it is in a loop.
Move locking function back to main.c, as it's only used by cnid_dbd.
Modify dbd_add() such that it can add an entry with the CNID passed
in from the client, the CNID hint read from the adouble file.
Invalidate CNID hint in case lookup detected a problem
Ralph Boehme [Mon, 10 Dec 2012 13:55:41 +0000 (14:55 +0100)]
Ignore db stamp when reading CNID from adouble file
The db stamp (which is the ctime of the cnid2.db file stored in the
db at creation time) may change when running `dbd -f` or when deleting
the CNID db manually. But we don't want to reassing CNIDs in this case
(changed stamp) we really want to keep it.
Ralph Boehme [Fri, 7 Dec 2012 17:33:32 +0000 (18:33 +0100)]
Rewrite dbd to use CNID IPC instead of opening the db directly
In order to fix buf #447 (race condition between dbd and cnid_dbd)
dbd must be converted to work over the network IPC channel with
cnid_dbd instead of directly working on the BerkeleyDB CNID database.
Ralph Boehme [Tue, 11 Dec 2012 12:42:12 +0000 (13:42 +0100)]
Fix a possible crash when searching on large volumes
catsearch() used dirlookup() to lookup directories, but then it didn't
use movecwd() to cd into them, only lchdir(). This resulted in curdir
not being updated.
Then, while processing entries of directory and adding them to the
dircache, in case the dircache hit its maximum size limit, dircache
eviction would take place.
The dircache eviction will remove a fixed size number of directories
from the cache, but for every entry to be freed it will ensure that
it's nor curdir.
Unfortunately as catsearch didn't update that, the directory that
catsearch was working on was freed, which of course resulted in access
of invalid ressouces and possible crashes.
The fix is to just use movecwd() instead of lchdir()ing directly.
Ralph Boehme [Thu, 6 Dec 2012 08:55:53 +0000 (09:55 +0100)]
Fix an error where catalog search gave incomplete results
The bug was immediately solved when chaning the current implementation
of using the function dirlookup_bybath() with paths form the dirstack,
to dirlook() with dids stored in the dirstack.
Presumably something dirlookup_bybath() went wrong thus ceratain
folders weren't searched.
Ralph Boehme [Tue, 4 Dec 2012 15:08:27 +0000 (16:08 +0100)]
Dont copy our metadata EA in copyfile()
Apparently Apple is now relying more on the AFP copyfile function
for file copies where source and destination are on the same vol.
The copying is done by our copyfile() function. It calls into
our VFS stack where in the end _all_ extended attributes of the
file, including our metadata EA, will be copied from source to
dest.
This resulted in an incorrect metadata EA on the destination file,
eg the CNID was still the one of the source file.
Obviously the metadata EA of the destination file must be created
such that all relevant fields are properly assigned.
Ralph Boehme [Tue, 4 Dec 2012 14:58:51 +0000 (15:58 +0100)]
Fix adouble refcounting
Opening a file that doesn't have metadata with ADFLAGS_HF | AFFLAGS_NOHF
resulted in a successfull open (the error from the failed opening
of the nonexistent metadata is suppressed by AFFLAGS_NOHF), but
then the metadata refcount was increased becasue the error condition
was already reset to 0 at the place where we checked it.
Fixing this requires pushing the refcount increment deeper down the stack
into the individual functions where the error condition is still
available.
After fixing this, another bug became apparent in the mostyl empty
function ad_open_rf_v2().
Also fix an if check where what should be a comparison clobbered
a struct field.
Ralph Boehme [Wed, 28 Nov 2012 13:23:33 +0000 (14:23 +0100)]
Add option 'ad domain'
Add option 'ad domain' similar to 'nt domain'. Useful when
authenticating against Netatalk on Solaris in case the OS is bound
to Active Directory. Currently users have to type in their full AD
name user@domain. Adding an option 'ad domain' would allows users
to login giving just their usernames.
Ralph Boehme [Tue, 27 Nov 2012 17:04:29 +0000 (18:04 +0100)]
Don't convert AppleDouble v2 file of symlinks, delete it
Netatalk 2.x created AppleDouble files for symlinks. Netatalk's 3
autoconversion of AppleDouble files to AppleDouble metadata
extended attributes failed to do the conversion in ad_convert()
because some filesystem may not support EAs on symlinks.
The new behaviour is to ignore symlinks in ad_convert().
Frank Lahm [Tue, 20 Nov 2012 17:19:33 +0000 (18:19 +0100)]
Ensure pthread support compiler and linker flags are correct
On some platforms using AC_SEARCH_LIBS is not sufficient for
finding the linker flags for linking with a pthread library.
Add macro ax_pthread.m4 from GNU autoconf macro archive and
use the macro AX_PTHREAD.
Fix compiler and linker flags for afpd and libatalk.
Ralph Boehme [Thu, 22 Nov 2012 10:31:49 +0000 (11:31 +0100)]
Fix SIGHUP config reloading
Add SIGHUP handler to master 'netatalk' process and let it distribute
the signal to it's childs, eg afpd.
Add function afp_config_free() which releases ressources allocated
by afp_config_parse().
Additionally fix configinit()/configfree() which deal with ressources
only used in the afpd fileserver (eg sockets, zeroconf registration).
Fix an error in the mdns unregister code where pthread_kill() was
used but that somehow killed the whole process not just the mdns
thread. Use pthread_cancel() instead which seems to work.
Ralph Boehme [Mon, 26 Nov 2012 15:19:02 +0000 (16:19 +0100)]
Fix a ressource leak
Due to the ordering and multiplexing of data- and metadata handle
closing in ad_close(), a datafork lock handle was not released.
Releasing lock handles is now done when the logic fork counter
hits zero, not when the underlying filedescriptor referencing handle
count reaches zero.
Ralph Boehme [Fri, 23 Nov 2012 17:23:24 +0000 (18:23 +0100)]
Reloading volumes from config file was broken
load_volumes() is supposed to be a "reenetrant" function called from
various places in different programs (afpd, cnid_metad) to reload the
config for updating the volume list.
Fix the loop freeing volumes that are deleted.
Simplify the loop checking for paths and volume names in createvol().
This is also the loop which checks if a volume is already loaded
when config has been loaded before.
Ralph Boehme [Fri, 23 Nov 2012 09:23:27 +0000 (10:23 +0100)]
Remove lenght limitation of options like "valid users"
The options "valid users", "rolist" and others use the function
accessvol() for parsing the options string. accessfull uses
a static buffer limited to MAXPATHLEN which limits the maximum
length of these options.
Ralph Boehme [Fri, 23 Nov 2012 07:15:51 +0000 (08:15 +0100)]
"valid users" options and friends only use ',' as field delimiter
Netatalk 3 uses ',' and ' ' as field delimiter in the "valid users",
"invalid users", "rolist" and "rwlist" option for consistency with
other options that also allow the use of ' ' as field delimiter.
But as user and groupnames may contain spaces, we need to revert
to the Netatalk 2 behaviour where only ',' was used as delimiter.
Frank Lahm [Fri, 9 Nov 2012 11:48:53 +0000 (12:48 +0100)]
Fix pathname bug for FCE modified event
It's not guaranteed that cwd is the forks parent directory, thus
we can't use the fullpathname(forkname) wrapper.
Instead we use the DID stored in the ofork structure to dirlookup
the directory and use it's fullpath together with the fork's name.
Frank Lahm [Thu, 22 Nov 2012 08:58:02 +0000 (09:58 +0100)]
Use sigaction() instead of signal() for ignoring SIGPIPE
Move the code to ignore SIGPIPE from the DSI sesssion setup stage
to the main signal handling code in main() and avoid the use
of deprecated signal() function and use sigaction.
Frank Lahm [Sat, 17 Nov 2012 11:30:18 +0000 (12:30 +0100)]
Fix a bug where copying packages to a Netatalk share fails
The bug was caused by the 10.6 client trying to set the creation
date on a symlink in the package. This caused our setmetadata
routine to require a valid adouble handle for the symlink which is
not possible as symlink may not allow creating an EA, depending
on the filesystem. At least ZFS on Solaris doesnt.
The fix is to check whether the adouble handle creation failed
on a symlink and ignore the error.
Frank Lahm [Sat, 17 Nov 2012 13:14:17 +0000 (14:14 +0100)]
Always generate all initscripts
initscripts are now all created with variable substitution from
the templates, but they're not installed. Installation happens
only if the configure arg for the platform is used.
This should help packagers picking up an initscript for a package.
Frank Lahm [Fri, 9 Nov 2012 10:53:24 +0000 (11:53 +0100)]
FCE API change and cleanup
Change the FCE API by using a single function (fce_register()) as
a single point for callers to register events.
Remove all individual event functions.
Add types for events and file/directoy flag.
Use standard bool type instead of special defines FCE_TRUE/FALSE.