]> arthur.barton.de Git - netatalk.git/commitdiff
Merge branch 'v3-cleanup' into tmp/v3.0.4-alex tmp/v3.0.4-alex
authorAlexander Barton <alex@barton.de>
Sat, 20 Jul 2013 10:12:21 +0000 (12:12 +0200)
committerAlexander Barton <alex@barton.de>
Sat, 20 Jul 2013 10:12:21 +0000 (12:12 +0200)
* v3-cleanup:
  autoconf: Indentation fixes
  Spelling fixes
  Whitespace and exclamation mark fixes

Conflicts:
etc/afpd/main.c

1  2 
NEWS
etc/afpd/auth.c
etc/afpd/status.c
etc/afpd/volume.c
libatalk/cnid/cdb/cnid_cdb_close.c
libatalk/cnid/cnid.c
libatalk/cnid/dbd/cnid_dbd.c
macros/netatalk.m4
macros/quota-check.m4

diff --combined NEWS
index 8eac3474d523b14d5345e3cc0a1a3835759330a9,866ac8871b478afb263850cbd13976e718f39c30..cb54cd87bc2fefa96ac9f1b15804e25dff9528fa
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
 +Changes in 3.0.4
 +================
 +* FIX: Opening files without metadata EA may result in an invalid
 +       metadata EA. Check for malformed metadata EAs and delete them.
 +       Fixes bug #510.
 +* FIX: Fix an issue with filenames containing non-ASCII characters that
 +       lead to a failure setting the size of a files ressource fork.
 +       This affected application like Adobe Photoshop where saving
 +       files may fail. Fixes bug #511.
 +* UPD: Enhance ACL mapping, change global ACL option 'map acl' to take
 +       the following options: "none", "rights" (default), "mode".
 +       none   = no mapping, this resembles the previous false/no setting
 +       rights = map ACLs to Finder UARights, this resembles the previous
 +                true/yes setting. This is the default.
 +       mode   = map ACLs to Finder UARights and UNIX mode
 +       From FR #73.
 +* FIX: Fix a possible crash in cname() where cname_mtouname calls
 +       dirlookup() where the curdir is freed because the dircache
 +       detected a dev/inode cache difference and evicted the object
 +       from the cache. Fixes bug #498.
 +* FIX: Add missing include, fixes bug #512.
 +* FIX: Change default FinderInfo for directories to be all 0, fixes
 +       bug 514.
 +* NEW: New option "afp interfaces" which allows specifying where
 +       Netatalk listens for AFP connections by interface names.
 +       From FR #79.
 +
 +Changes in 3.0.3
 +================
 +* UPD: afpd: Increase default DSI server quantum to 1 MB
 +* UPD: bundled libevent2 is now static
 +* NEW: --with-lockfile=PATH configure option for specifying an
 +       alternative path for the netatalk lockfile.
 +* UPD: systemd service file use PIDFile and ExecReload.
 +       From FR #70.
 +* UPD: RedHat sysvinit: rm graceful, reimplement reload, add condrestart
 +* FIX: Couldn't create folders on FreeBSD 9.1 ZFS fileystems.
 +       Fixed bug #491.
 +* FIX: Fix an issue with user homes when user home directory has not the
 +       same name as the username.
 +       Fixes bug #497.
 +* UPD: Fix PAM config install, new default installation dir is
 +       $sysconfdir/pam.d/. Add configure option --with-pam-confdir
 +       to specify alternative path.
 +* NEW: AFP stats about active session via dbus IPC. Client side python
 +       program `afpstats`. Requires dbus, dbus-glib any python-dbus.
 +       configure option --dbus-sysconf-dir for specifying dbus
 +       system security configuration files.
 +       New option 'afpstats' (default: no) which determines whether
 +       to enable the feature or not.
 +* NEW: configure option --with-init-dir
 +* NEW: dtrace probes, cf include/atalk/afp_dtrace.d for available
 +       probes.
 +* UPD: Reload groups when reloading volumes. FR #71.
 +* FIX: Attempt to read read-only ._ rfork results in disconnect.
 +       Fixes bug #502.
 +* FIX: File's ressource fork can't be read if metadata EA is missing.
 +       Fixes bug #501.
 +* FIX: Conversion from adouble v2 to ea for directories.
 +       Fixes bug #500.
 +* FIX: Error messages when mounting read-only filesystems.
 +       Fixes bug #504.
 +* FIX: Permissions of ._ AppleDouble ressource fork after conversion
 +       from v2 to ea.
 +       Fixes bug #505.
 +* UPD: Use FreeBSD sendfile() capability to send protocol header.
 +       From FR #75.
 +* UPD: Increase IO size when sendfile() is not used.
 +       From FR #76.
 +* FIX: Can't set Finder label on symlinked folder with "follow symlinks = yes".
 +       Fixes bug #508.
 +* FIX: Setting POSIX ACLs on Linux
 +       Fixes bug #506.
 +* FIX: "ad ls" segfault if requested object is not in an AFP volume.
 +       Fixes bug #496.
 +
 +Changes in 3.0.2
 +================
 +* NEW: afpd: Put file extension type/creator mapping back in which had
 +       been removed in 3.0.
 +* NEW: afpd: new option 'ad domain'. From FR #66.
 +* FIX: volumes and home share with symlinks in the path
 +* FIX: Copying packages to a Netatalk share could fail, bug #469
 +* FIX: Reloading volumes from config file was broken.  Fixes bug #474.
 +* FIX: Fix _device-info service type registered with dns-sd API
 +* FIX: Fix pathname bug for FCE modified event.
 +* FIX: Remove length limitation of options like "valid users".
 +       Fixes bug #473.
 +* FIX: Dont copy our metadata EA in copyfile(). Fixes bug #452.
 +* FIX: Fix an error where catalog search gave incomplete results.
 +       Fixes bug #479.
 +* REM: Remove TimeMachine volume used size FCE event.
 +* UPD: Add quoting support to '[in]valid users' option. Fixes bug #472.
 +* FIX: Install working PAM config on Solaris 11. Fixes bug #481.
 +* FIX: Fix a race condition between dbd and the cnid_dbd daemon
 +       which could result in users being disconnected from volumes
 +       when dbd was scanning their volumes. Fixes bug #477.
 +* FIX: Netatalk didn't start when the last line of the config file
 +       afp.conf wasn't terminated by a newline. Fixes bug #476.
 +* NEW: 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".
 +* FIX: Automatic AppleDouble conversion to EAs failing for directories.
 +       Fixes bug #486.
 +* FIX: dbd failed to convert appledouble files of symlinks.
 +       Fixes bug #490.
 +
  Changes in 3.0.1
  ================
  * NEW: afpd: Optional "ldap uuid encoding = string | ms-guid" parameter to
@@@ -298,7 -188,7 +298,7 @@@ Changes in 2.2.
  Changes in 2.2.1
  ================
  
- * NEW: afpd: disable continous service feature by default, new option
+ * NEW: afpd: disable continuous service feature by default, new option
         -keepsessions to enable it
  * NEW: configure option "--enable-redhat-systemd" for Fedora15 and later.
         "--enable-redhat" is renamed "--enable-redhat-sysv".
diff --combined etc/afpd/auth.c
index bec624dc6cd32efc72b9838381a5b8f12ad6593b,ce1556b6930ee26b9569ad746dc726c3a722a821..80cd5339f51494b5dd13d0fd240123c53ddf6b49
@@@ -39,7 -39,6 +39,7 @@@ extern void afp_get_cmdline( int *ac, c
  #include <atalk/server_ipc.h>
  #include <atalk/uuid.h>
  #include <atalk/globals.h>
 +#include <atalk/unix.h>
  
  #include "auth.h"
  #include "uam_auth.h"
@@@ -211,6 -210,23 +211,6 @@@ static int set_auth_switch(const AFPOb
      return AFP_OK;
  }
  
 -#define GROUPSTR_BUFSIZE 1024
 -static const char *print_groups(int ngroups, gid_t *groups)
 -{
 -    static char groupsstr[GROUPSTR_BUFSIZE];
 -    int i;
 -    char *s = groupsstr;
 -
 -    if (ngroups == 0)
 -        return "-";
 -
 -    for (i = 0; (i < ngroups) && (s < &groupsstr[GROUPSTR_BUFSIZE]); i++) {
 -        s += snprintf(s, &groupsstr[GROUPSTR_BUFSIZE] - s, " %u", groups[i]);
 -    }
 -
 -    return groupsstr;
 -}
 -
  static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expired)
  {
  #ifdef ADMIN_GRP
      LOG(log_note, logtype_afpd, "%s Login by %s",
          afp_versions[afp_version_index].av_name, pwd->pw_name);
  
 -    if (initgroups( pwd->pw_name, pwd->pw_gid ) < 0) {
 -#ifdef RUN_AS_USER
 -        LOG(log_info, logtype_afpd, "running with uid %d", geteuid());
 -#else /* RUN_AS_USER */
 -        LOG(log_error, logtype_afpd, "login: %s", strerror(errno));
 -        return AFPERR_BADUAM;
 -#endif /* RUN_AS_USER */
 -
 -    }
 -
 -    /* Basically if the user is in the admin group, we stay root */
 -
 -    if ((obj->ngroups = getgroups( 0, NULL )) < 0 ) {
 -        LOG(log_error, logtype_afpd, "login: %s getgroups: %s", pwd->pw_name, strerror(errno) );
 -        return AFPERR_BADUAM;
 -    }
 -
 -    if ( NULL == (obj->groups = calloc(obj->ngroups, sizeof(gid_t))) ) {
 -        LOG(log_error, logtype_afpd, "login: %s calloc: %d", obj->ngroups);
 +    if (set_groups(obj, pwd) != 0)
          return AFPERR_BADUAM;
 -    }
 -
 -    if (( obj->ngroups = getgroups(obj->ngroups, obj->groups )) < 0 ) {
 -        LOG(log_error, logtype_afpd, "login: %s getgroups: %s", pwd->pw_name, strerror(errno) );
 -        return AFPERR_BADUAM;
 -    }
  
  #ifdef ADMIN_GRP
      LOG(log_debug, logtype_afpd, "obj->options.admingid == %d", obj->options.admingid);
@@@ -335,7 -375,6 +335,7 @@@ int afp_zzz(AFPObj *obj, char *ibuf, si
          if (dsi->flags & DSI_EXTSLEEP) {
              LOG(log_note, logtype_afpd, "afp_zzz: waking up from extended sleep");
              dsi->flags &= ~(DSI_SLEEPING | DSI_EXTSLEEP);
 +            ipc_child_state(obj, DSI_RUNNING);
          }
      } else {
          /* sleep request */
          if (data & AFPZZZ_EXT_SLEEP) {
              LOG(log_note, logtype_afpd, "afp_zzz: entering extended sleep");
              dsi->flags |= DSI_EXTSLEEP;
 +            ipc_child_state(obj, DSI_EXTSLEEP);
          } else {
              LOG(log_note, logtype_afpd, "afp_zzz: entering normal sleep");
 +            ipc_child_state(obj, DSI_SLEEPING);
          }
      }
  
@@@ -875,7 -912,7 +875,7 @@@ int afp_changepw(AFPObj *obj, char *ibu
          if ( ibuf[0] != '\0' || ibuf[1] != '\0')
              return AFPERR_PARAM;
          ibuf += 2;
 -        len = MIN(sizeof(username), strlen(obj->username));
 +        len = MIN(sizeof(username) - 1, strlen(obj->username));
          memcpy(username, obj->username, len);
          username[ len ] = '\0';
      }
@@@ -960,7 -997,7 +960,7 @@@ int afp_getuserinfo(AFPObj *obj _U_, ch
              atalk_uuid_t uuid;
              ret = getuuidfromname( obj->username, UUID_USER, uuid);
              if (ret != 0) {
-                 LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID !");
+                 LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID!");
                  return AFPERR_NOITEM;
              }
              LOG(log_debug, logtype_afpd, "afp_getuserinfo: got UUID: %s", uuid_bin2string(uuid));
diff --combined etc/afpd/status.c
index 35e088499db21c56483139df30e3c7b3d5c7f9de,eb5b99b30b970a95f96547e6e87260be38282c9a..ec1025dda3922106a2325290fd9ff59fb7d13ce2
@@@ -95,7 -95,7 +95,7 @@@ static void status_flags(char *data
  static int status_server(char *data, const char *server, const struct afp_options *options)
  {
      char                *start = data;
 -    char                *Obj, *Type, *Zone;
 +    char                *Obj;
      char              buf[32];
      uint16_t           status;
      size_t            len;
@@@ -364,6 -364,7 +364,6 @@@ static size_t status_directorynames(cha
      data += offset;
  
      char *DirectoryNamesCount = data++;
 -    char *DirectoryNames = data;
      size_t size = sizeof(uint8_t);
      *DirectoryNamesCount = 0;
  
      }
  
      krb5_unparse_name(context, entry.principal, &principal);
 +#ifdef HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS
 +    krb5_free_keytab_entry_contents(context, &entry);
 +#elif defined(HAVE_KRB5_KT_FREE_ENTRY)
      krb5_kt_free_entry(context, &entry);
 -
 +#endif
      append_directoryname(&data,
                           offset,
                           &size,
@@@ -503,7 -501,7 +503,7 @@@ static size_t status_utf8servername(cha
      uint16_t namelen;
      size_t len;
      char *begin = data;
 -    uint16_t offset, status;
 +    uint16_t offset;
  
      memcpy(&offset, data + *nameoffset, sizeof(offset));
      offset = ntohs(offset);
@@@ -647,7 -645,7 +647,7 @@@ void set_signature(struct afp_options *
      char *servername_conf;
      int header = 0;
      char buf[1024], *p;
 -    FILE *fp = NULL, *randomp;
 +    FILE *fp = NULL;
      size_t len;
      char *server_tmp;
      
      if (len == 0) {
          goto server_signature_auto;   /* default */
      } else if (len < 3) {
-         LOG(log_warning, logtype_afpd, "WARNING: signature string %s is very short !", options->signatureopt);
+         LOG(log_warning, logtype_afpd, "WARNING: signature string %s is very short!", options->signatureopt);
          goto server_signature_user;
      } else if (len > 16) {
-         LOG(log_warning, logtype_afpd, "WARNING: signature string %s is very long !", options->signatureopt);
+         LOG(log_warning, logtype_afpd, "WARNING: signature string %s is very long!", options->signatureopt);
          len = 16;
          goto server_signature_user;
      } else {
diff --combined etc/afpd/volume.c
index f51223730c32a5047eedd749d935315613e24ff9,da57a30a822491746f603ba6112516b3ac325dac..205383bb0ee7d939da4d24ba59d7980ba27be109
@@@ -39,7 -39,6 +39,7 @@@
  #include <atalk/iniparser.h>
  #include <atalk/unix.h>
  #include <atalk/netatalk_conf.h>
 +#include <atalk/server_ipc.h>
  
  #ifdef CNID_DB
  #include <atalk/cnid.h>
@@@ -153,6 -152,7 +153,6 @@@ static int get_tm_used(struct vol * res
      DIR *dir = NULL;
      const struct dirent *entry;
      const char *p;
 -    struct stat st;
      long int links;
      time_t now = time(NULL);
  
  
              EC_NULL_LOG( infoplist = bformat("%s/%s/%s", vol->v_path, entry->d_name, "Info.plist") );
              
 -            if ((bandsize = get_tm_bandsize(cfrombstr(infoplist))) == -1)
 +            if ((bandsize = get_tm_bandsize(cfrombstr(infoplist))) == -1) {
 +                bdestroy(infoplist);
                  continue;
 +            }
  
              EC_NULL_LOG( bandsdir = bformat("%s/%s/%s/", vol->v_path, entry->d_name, "bands") );
  
 -            if ((links = get_tm_bands(cfrombstr(bandsdir))) == -1)
 +            if ((links = get_tm_bands(cfrombstr(bandsdir))) == -1) {
 +                bdestroy(infoplist);
 +                bdestroy(bandsdir);
                  continue;
 +            }
  
              used += (links - 1) * bandsize;
              LOG(log_debug, logtype_afpd, "getused(\"%s\"): bands: %" PRIu64 " bytes",
@@@ -217,6 -212,7 +217,6 @@@ static int getvolspace(const AFPObj *ob
  {
      int         spaceflag, rc;
      uint32_t   maxsize;
 -    VolSpace    used;
  #ifndef NO_QUOTA_SUPPORT
      VolSpace    qfree, qtotal;
  #endif
@@@ -268,6 -264,22 +268,6 @@@ getvolspace_done
      return( AFP_OK );
  }
  
 -#define FCE_TM_DELTA 10  /* send notification every 10 seconds */
 -void vol_fce_tm_event(void)
 -{
 -    static time_t last;
 -    time_t now = time(NULL);
 -    struct vol  *vol = getvolumes();
 -
 -    if ((last + FCE_TM_DELTA) < now) {
 -        last = now;
 -        for ( ; vol; vol = vol->v_next ) {
 -            if (vol->v_flags & AFPVOL_TM)
 -                (void)fce_register_tm_size(vol->v_path, vol->v_tm_used + vol->v_appended);
 -        }
 -    }
 -}
 -
  /* -----------------------
   * set volume creation date
   * avoid duplicate, well at least it tries
@@@ -531,7 -543,7 +531,7 @@@ int afp_getsrvrparms(AFPObj *obj, char 
      int         vcnt;
      size_t      len;
  
 -    load_volumes(obj, closevol);
 +    load_volumes(obj);
  
      data = rbuf + 5;
      for ( vcnt = 0, volume = getvolumes(); volume; volume = volume->v_next ) {
@@@ -601,7 -613,7 +601,7 @@@ static int volume_codepage(AFPObj *obj
      }
  
      if ( NULL == (charset = find_charset_functions(volume->v_volcodepage)) || charset->flags & CHARSET_ICONV ) {
-         LOG (log_warning, logtype_afpd, "WARNING: volume encoding %s is *not* supported by netatalk, expect problems !!!!", volume->v_volcodepage);
+         LOG (log_warning, logtype_afpd, "WARNING: volume encoding %s is *not* supported by netatalk, expect problems!", volume->v_volcodepage);
      }
  
      if (!volume->v_maccodepage)
@@@ -660,31 -672,6 +660,31 @@@ static int volume_openDB(const AFPObj *
      return (!volume->v_cdb)?-1:0;
  }
  
 +/*
 + * Send list of open volumes to afpd master via IPC
 + */
 +static void server_ipc_volumes(AFPObj *obj)
 +{
 +    struct vol *volume, *vols;
 +    volume = vols = getvolumes();
 +    bstring openvolnames = bfromcstr("");
 +    bool firstvol = true;
 +
 +    while (volume) {
 +        if (volume->v_flags & AFPVOL_OPEN) {
 +            if (!firstvol)
 +                bcatcstr(openvolnames, ", ");
 +            else
 +                firstvol = false;
 +            bcatcstr(openvolnames, volume->v_localname);
 +        }
 +        volume = volume->v_next;
 +    }
 +
 +    ipc_child_write(obj->ipc_fd, IPC_VOLUMES, blength(openvolnames), bdata(openvolnames));
 +    bdestroy(openvolnames);
 +}
 +
  /* -------------------------
   * we are the user here
   */
@@@ -692,14 -679,16 +692,14 @@@ int afp_openvol(AFPObj *obj, char *ibuf
  {
      struct stat st;
      char    *volname;
 -    char        *p;
  
      struct vol  *volume;
      struct dir  *dir;
      int     len, ret;
      size_t  namelen;
      uint16_t   bitmap;
 -    char        path[ MAXPATHLEN + 1];
      char        *vol_uname;
 -    char        *vol_mname;
 +    char        *vol_mname = NULL;
      char        *volname_tmp;
  
      ibuf += 2;
      if ((len + 1) & 1) /* pad to an even boundary */
          ibuf++;
  
 -    load_volumes(obj, closevol);
 +    load_volumes(obj);
  
      for ( volume = getvolumes(); volume; volume = volume->v_next ) {
          if ( strcasecmp_w( (ucs2_t*) volname, volume->v_name ) == 0 ) {
          return AFPERR_PARAM;
      }
  
 -    if ( NULL == getcwd(path, MAXPATHLEN)) {
 -        /* shouldn't be fatal but it will fail later */
 -        LOG(log_error, logtype_afpd, "afp_openvol(%s): volume pathlen too long", volume->v_path);
 -        return AFPERR_MISC;
 -    }
 -
 -    /* Normalize volume path */
 -#ifdef REALPATH_TAKES_NULL
 -    if ((volume->v_path = realpath(path, NULL)) == NULL)
 -        return AFPERR_MISC;
 -#else
 -    if ((volume->v_path = malloc(MAXPATHLEN+1)) == NULL)
 -        return AFPERR_MISC;
 -    if (realpath(path, volume->v_path) == NULL) {
 -        free(volume->v_path);
 -        return AFPERR_MISC;
 -    }
 -    /* Safe some memory */
 -    char *tmp;
 -    if ((tmp = strdup(volume->v_path)) == NULL) {
 -        free(volume->v_path);
 -        return AFPERR_MISC;
 -    }
 -    free(volume->v_path);
 -    volume->v_path = tmp;
 -#endif
 -
      if (volume_codepage(obj, volume) < 0) {
          ret = AFPERR_MISC;
          goto openvol_err;
          goto openvol_err;
      }
  
 -    if ((vol_uname = strrchr(path, '/')) == NULL)
 -        vol_uname = path;
 -    else if (*(vol_uname + 1) != '\0')
 +    if ((vol_uname = strrchr(volume->v_path, '/')) == NULL)
 +        vol_uname = volume->v_path;
 +    else if (vol_uname[1] != '\0')
          vol_uname++;
  
      if ((dir = dir_new(vol_mname,
          ret = AFPERR_MISC;
          goto openvol_err;
      }
 -    free(vol_mname);
      volume->v_root = dir;
      curdir = dir;
  
          if ((msg = iniparser_getstring(obj->iniconfig, volume->v_configname, "login message",  NULL)) != NULL)
              setmessage(msg);
  
 +        free(vol_mname);
 +        server_ipc_volumes(obj);
          return( AFP_OK );
      }
  
@@@ -875,7 -890,6 +875,7 @@@ openvol_err
          cnid_close(volume->v_cdb);
          volume->v_cdb = NULL;
      }
 +    free(vol_mname);
      *rbuflen = 0;
      return ret;
  }
@@@ -933,7 -947,6 +933,7 @@@ int afp_closevol(AFPObj *obj, char *ibu
      (void)chdir("/");
      curdir = NULL;
      closevol(obj, vol);
 +    server_ipc_volumes(obj);
  
      return( AFP_OK );
  }
index d34a418b7e3cef4b623912d2008a4f54cec5a04e,fcc01df2eb6ded40fc339f039389e548f6ab97e7..2e11ea81c23a4466288f17b34216d81ecaf67c0d
@@@ -1,4 -1,5 +1,4 @@@
  /*
 - * $Id: cnid_cdb_close.c,v 1.2 2005-04-28 20:49:59 bfernhomberg Exp $
   */
  
  #ifdef HAVE_CONFIG_H
@@@ -12,7 -13,7 +12,7 @@@ void cnid_cdb_close(struct _cnid_db *cd
      CNID_private *db;
  
      if (!cdb) {
-           LOG(log_error, logtype_afpd, "cnid_close called with NULL argument !");
+           LOG(log_error, logtype_afpd, "cnid_close called with NULL argument!");
            return;
      }
  
diff --combined libatalk/cnid/cnid.c
index 7cf3af1618d19a6de2e0cecada09936aeab90508,f0b8903d6ccf95782bbb7dcd4809d01239733402..021cecfbfa35ac6425ef9afbde9b61273458fe6f
@@@ -47,7 -47,7 +47,7 @@@ void cnid_register(struct _cnid_module 
      /* Check if our module is already registered. */
      list_for_each(ptr, &modules)
          if (0 == strcmp(list_entry(ptr, cnid_module, db_list)->name, module->name)) {
-         LOG(log_error, logtype_afpd, "Module with name [%s] is already registered !", module->name);
+         LOG(log_error, logtype_afpd, "Module with name [%s] is already registered!", module->name);
          return;
      }
  
@@@ -203,7 -203,7 +203,7 @@@ void cnid_close(struct _cnid_db *db
      uint32_t flags;
  
      if (NULL == db) {
-         LOG(log_error, logtype_afpd, "Error: cnid_close called with NULL argument !");
+         LOG(log_error, logtype_afpd, "Error: cnid_close called with NULL argument!");
          return;
      }
      /* cnid_close free db */
@@@ -338,15 -338,3 +338,15 @@@ cnid_t ret
      unblock_signal(cdb->flags);
      return ret;
  }
 +
 +/* --------------- */
 +int cnid_wipe(struct _cnid_db *cdb)
 +{
 +    int ret = 0;
 +
 +    block_signal(cdb->flags);
 +    if (cdb->cnid_wipe)
 +        ret = cdb->cnid_wipe(cdb);
 +    unblock_signal(cdb->flags);
 +    return ret;
 +}
index 3f0278ae46aa9678e320e232580c52e53ea38535,c96a22596163659fc87be4a6b3a60f3eafc6e321..ccf01343c13639a963f6423e57a19420179c6a51
@@@ -356,18 -356,47 +356,18 @@@ static int transmit(CNID_private *db, s
      time_t orig, t;
      int clean = 1; /* no errors so far - to prevent sleep on first try */
  
 -    if (db->changed) {
 -        /* volume and db don't have the same timestamp
 -         */
 -        return -1;
 -    }
      while (1) {
          if (db->fd == -1) {
 -            struct cnid_dbd_rqst rqst_stamp;
 -            struct cnid_dbd_rply rply_stamp;
 -            char  stamp[ADEDLEN_PRIVSYN];
 -
              LOG(log_maxdebug, logtype_cnid, "transmit: connecting to cnid_dbd ...");
              if ((db->fd = init_tsock(db)) < 0) {
                  goto transmit_fail;
              }
 -            dbd_initstamp(&rqst_stamp);
 -            memset(stamp, 0, ADEDLEN_PRIVSYN);
 -            rply_stamp.name = stamp;
 -            rply_stamp.namelen = ADEDLEN_PRIVSYN;
 -
 -            if (dbd_rpc(db, &rqst_stamp, &rply_stamp) < 0)
 -                goto transmit_fail;
 -            if (dbd_reply_stamp(&rply_stamp ) < 0)
 -                goto transmit_fail;
 -
              if (db->notfirst) {
 -                LOG(log_debug7, logtype_cnid, "transmit: reconnected to cnid_dbd, comparing database stamps...");
 -                if (memcmp(stamp, db->stamp, ADEDLEN_PRIVSYN)) {
 -                    LOG(log_error, logtype_cnid, "transmit: ... not the same db!");
 -                    db->changed = 1;
 -                    return -1;
 -                }
 -                LOG(log_debug7, logtype_cnid, "transmit: ... OK.");
 +                LOG(log_debug7, logtype_cnid, "transmit: reconnected to cnid_dbd");
              } else { /* db->notfirst == 0 */
                  db->notfirst = 1;
 -                if (db->client_stamp)
 -                    memcpy(db->client_stamp, stamp, ADEDLEN_PRIVSYN);
 -                memcpy(db->stamp, stamp, ADEDLEN_PRIVSYN);
              }
 -            LOG(log_debug, logtype_cnid, "transmit: attached to '%s', stamp: '%08lx'.",
 -                db->db_dir, *(uint64_t *)stamp);
 +            LOG(log_debug, logtype_cnid, "transmit: attached to '%s'", db->db_dir);
          }
          if (!dbd_rpc(db, rqst, rply)) {
              LOG(log_maxdebug, logtype_cnid, "transmit: {done}");
@@@ -427,7 -456,7 +427,7 @@@ static struct _cnid_db *cnid_dbd_new(co
      cdb->cnid_update = cnid_dbd_update;
      cdb->cnid_rebuild_add = cnid_dbd_rebuild_add;
      cdb->cnid_close = cnid_dbd_close;
 -
 +    cdb->cnid_wipe = cnid_dbd_wipe;
      return cdb;
  }
  
@@@ -484,7 -513,7 +484,7 @@@ void cnid_dbd_close(struct _cnid_db *cd
      CNID_private *db;
  
      if (!cdb) {
-         LOG(log_error, logtype_cnid, "cnid_close called with NULL argument !");
+         LOG(log_error, logtype_cnid, "cnid_close called with NULL argument!");
          return;
      }
  
      return;
  }
  
 +/**
 + * Get the db stamp
 + **/
 +static int cnid_dbd_stamp(CNID_private *db)
 +{
 +    struct cnid_dbd_rqst rqst_stamp;
 +    struct cnid_dbd_rply rply_stamp;
 +    char  stamp[ADEDLEN_PRIVSYN];
 +
 +    dbd_initstamp(&rqst_stamp);
 +    memset(stamp, 0, ADEDLEN_PRIVSYN);
 +    rply_stamp.name = stamp;
 +    rply_stamp.namelen = ADEDLEN_PRIVSYN;
 +
 +    if (transmit(db, &rqst_stamp, &rply_stamp) < 0)
 +        return -1;
 +    if (dbd_reply_stamp(&rply_stamp ) < 0)
 +        return -1;
 +
 +    if (db->client_stamp)
 +        memcpy(db->client_stamp, stamp, ADEDLEN_PRIVSYN);
 +    memcpy(db->stamp, stamp, ADEDLEN_PRIVSYN);
 +
 +    return 0;
 +}
 +
  /* ---------------------- */
  cnid_t cnid_dbd_add(struct _cnid_db *cdb, const struct stat *st,
                      cnid_t did, const char *name, size_t len, cnid_t hint)
      rqst.name = name;
      rqst.namelen = len;
  
 -    LOG(log_debug, logtype_cnid, "cnid_dbd_add: CNID: %u, name: '%s', inode: 0x%llx, type: %d (0=file, 1=dir)",
 -        ntohl(did), name, (long long)st->st_ino, rqst.type);
 +    LOG(log_debug, logtype_cnid, "cnid_dbd_add: CNID: %u, name: '%s', dev: 0x%llx, inode: 0x%llx, type: %s",
 +        ntohl(did), name, (long long)rqst.dev, (long long)st->st_ino, rqst.type ? "dir" : "file");
  
      rply.namelen = 0;
      if (transmit(db, &rqst, &rply) < 0) {
@@@ -703,9 -706,7 +703,9 @@@ char *cnid_dbd_resolve(struct _cnid_db 
      return name;
  }
  
 -/* ---------------------- */
 +/**
 + * Caller passes buffer where we will store the db stamp
 + **/
  int cnid_dbd_getstamp(struct _cnid_db *cdb, void *buffer, const size_t len)
  {
      CNID_private *db;
      }
      db->client_stamp = buffer;
      db->stamp_size = len;
 -    memset(buffer,0, len);
 -    return 0;
 +
 +    return cnid_dbd_stamp(db);
  }
  
  /* ---------------------- */
@@@ -993,39 -994,6 +993,39 @@@ int cnid_dbd_delete(struct _cnid_db *cd
      }
  }
  
 +int cnid_dbd_wipe(struct _cnid_db *cdb)
 +{
 +    CNID_private *db;
 +    struct cnid_dbd_rqst rqst;
 +    struct cnid_dbd_rply rply;
 +
 +    if (!cdb || !(db = cdb->_private)) {
 +        LOG(log_error, logtype_cnid, "cnid_wipe: Parameter error");
 +        errno = CNID_ERR_PARAM;
 +        return -1;
 +    }
 +
 +    LOG(log_debug, logtype_cnid, "cnid_dbd_wipe");
 +
 +    RQST_RESET(&rqst);
 +    rqst.op = CNID_DBD_OP_WIPE;
 +    rqst.cnid = 0;
 +
 +    rply.namelen = 0;
 +    if (transmit(db, &rqst, &rply) < 0) {
 +        errno = CNID_ERR_DB;
 +        return -1;
 +    }
 +
 +    if (rply.result != CNID_DBD_RES_OK) {
 +        errno = CNID_ERR_DB;
 +        return -1;
 +    }
 +    LOG(log_debug, logtype_cnid, "cnid_dbd_wipe: ok");
 +
 +    return cnid_dbd_stamp(db);
 +}
 +
  
  struct _cnid_module cnid_dbd_module = {
      "dbd",
diff --combined macros/netatalk.m4
index 1a55276471d8e7c2066fd5db2b12006d0e22c189,34dfc08cc6c31128da4503e6e857a4ab6fc1038d..cb0fc717fe11daf8e074490de3e6292f0c7dc97f
  dnl Kitchen sink for configuration macros
  
 +dnl Check for docbook
 +AC_DEFUN(AX_CHECK_DOCBOOK, [
 +  # It's just rude to go over the net to build
 +  XSLTPROC_FLAGS=--nonet
 +  DOCBOOK_ROOT=
 +  XSLTPROC_WORKS=no
 +
 +  AC_ARG_WITH(docbook,
 +    AS_HELP_STRING(
 +      [--with-docbook],
 +      [Path to Docbook XSL directory]
 +    ),
 +    [DOCBOOK_ROOT=$withval]
 +  )
 +
 +  if test -n "$DOCBOOK_ROOT" ; then
 +    AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,)
 +    if test -n "$XSLTPROC"; then
 +      AC_MSG_CHECKING([whether xsltproc works])
 +      DB_FILE="$DOCBOOK_ROOT/html/docbook.xsl"
 +      $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END
 +<?xml version="1.0" encoding='ISO-8859-1'?>
 +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
 +<book id="test">
 +</book>
 +END
 +      if test "$?" = 0; then
 +        XSLTPROC_WORKS=yes
 +      fi
 +      AC_MSG_RESULT($XSLTPROC_WORKS)
 +    fi
 +  fi
 +
 +  AC_MSG_CHECKING([whether to build Docbook documentation])
 +  AC_MSG_RESULT($XSLTPROC_WORKS)
 +
 +  AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC_WORKS" = x"yes")
 +  AC_SUBST(XSLTPROC_FLAGS)
 +  AC_SUBST(DOCBOOK_ROOT)
 +  AC_SUBST(XSLTPROC)
 +])
 +
 +dnl Check for dtrace
 +AC_DEFUN([AC_NETATALK_DTRACE], [
 +  AC_ARG_WITH(dtrace,
 +    AS_HELP_STRING(
 +      [--with-dtrace],
 +      [Enable dtrace probes (default: enabled if dtrace found)]
 +    ),
 +    [WDTRACE=$withval],
 +    [WDTRACE=auto]
 +  )
 +  if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
 +    AC_CHECK_PROG([atalk_cv_have_dtrace], [dtrace], [yes], [no])
 +    if test "x$atalk_cv_have_dtrace" = "xno" ; then
 +      if test "x$WDTRACE" = "xyes" ; then
 +        AC_MSG_FAILURE([dtrace requested but not found])
 +      fi
 +      WDTRACE="no"
 +    else
 +      WDTRACE="yes"
 +    fi
 +  fi
 +
 +  if test x"$WDTRACE" = x"yes" ; then
 +    AC_DEFINE([WITH_DTRACE], [1], [dtrace probes])
 +    DTRACE_LIBS=""
 +    if test x"$this_os" = x"freebsd" ; then
 +      DTRACE_LIBS="-lelf"
 +    fi
 +    AC_SUBST(DTRACE_LIBS)
 +  fi
 +  AM_CONDITIONAL(WITH_DTRACE, test "x$WDTRACE" = "xyes")
 +])
 +
 +dnl Check for dbus-glib, for AFP stats
 +AC_DEFUN([AC_NETATALK_DBUS_GLIB], [
 +    atalk_cv_with_dbus=no
 +    PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1, have_dbus=yes, have_dbus=no)
 +    PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1, have_dbus_glib=yes, have_dbus_glib=no)
 +    PKG_CHECK_MODULES(DBUS_GTHREAD, gthread-2.0, have_dbus_gthread=yes, have_dbus_gthread=no)
 +    AC_SUBST(DBUS_CFLAGS)
 +    AC_SUBST(DBUS_LIBS)
 +    AC_SUBST(DBUS_GLIB_CFLAGS)
 +    AC_SUBST(DBUS_GLIB_LIBS)
 +    AC_SUBST(DBUS_GTHREAD_CFLAGS)
 +    AC_SUBST(DBUS_GTHREAD_LIBS)
 +    if test x$have_dbus_glib = xyes -a x$have_dbus = xyes -a x$have_dbus_gthread = xyes ; then
 +        saved_CFLAGS=$CFLAGS
 +        saved_LIBS=$LIBS
 +        CFLAGS="$CFLAGS $DBUS_GLIB_CFLAGS"
 +        LIBS="$LIBS $DBUS_GLIB_LIBS"
 +        AC_CHECK_FUNC([dbus_g_bus_get_private], [atalk_cv_with_dbus=yes], [atalk_cv_with_dbus=no])
 +        CFLAGS="$saved_CFLAGS"
 +        LIBS="$saved_LIBS"
 +    fi
 +    AM_CONDITIONAL(HAVE_DBUS_GLIB, test x$atalk_cv_with_dbus = xyes)
 +
 +    AC_ARG_WITH(
 +        dbus-sysconf-dir,
 +        [AS_HELP_STRING([--with-dbus-sysconf-dir=PATH],[Path to dbus system bus security configuration directory (default: ${sysconfdir}/dbus-1/system.d/)])],
 +        ac_cv_dbus_sysdir=$withval,
 +        ac_cv_dbus_sysdir='${sysconfdir}/dbus-1/system.d'
 +    )
 +
 +    if test x$atalk_cv_with_dbus = xyes ; then
 +        AC_DEFINE(HAVE_DBUS_GLIB, 1, [Define if support for dbus-glib was found])
 +        DBUS_SYS_DIR="$ac_cv_dbus_sysdir"
 +        AC_SUBST(DBUS_SYS_DIR)
 +    fi
 +])
 +
  dnl Whether to enable developer build
  AC_DEFUN([AC_DEVELOPER], [
      AC_MSG_CHECKING([whether to enable developer build])
  
  dnl Whether to disable bundled libevent
  AC_DEFUN([AC_NETATALK_LIBEVENT], [
 -    use_bundled_libevent=no
 -    AC_MSG_CHECKING([whether to use bundled or installed libevent])
 +    AC_MSG_CHECKING([whether to use bundled libevent])
 +    AC_ARG_WITH(
 +        libevent,
 +        [AS_HELP_STRING([--with-libevent],[whether to use the bundled libevent (default: yes)])],
 +        use_bundled_libevent=$withval,
 +        use_bundled_libevent=yes
 +    )
      AC_ARG_WITH(
          libevent-header,
          [AS_HELP_STRING([--with-libevent-header],[path to libevent header files])],
 -        LIBEVENT_CFLAGS=-I$withval,
 -        use_bundled_libevent=yes
 +        [use_bundled_libevent=no; LIBEVENT_CFLAGS=-I$withval]
      )
      AC_ARG_WITH(
          libevent-lib,
 -        [AS_HELP_STRING([--with-libevent-lib],[path to libevent header library])],
 -        LIBEVENT_LDFLAGS=-L$withval,
 -        use_bundled_libevent=yes
 +        [AS_HELP_STRING([--with-libevent-lib],[path to libevent library])],
 +        [use_bundled_libevent=no; LIBEVENT_LDFLAGS=-L$withval]
      )
 +    if test x"$LIBEVENT_CFLAGS" = x"-Iyes" -o x"$LIBEVENT_LDFLAGS" = x"-Lyes" ; then
 +        AC_MSG_ERROR([--with-libevent requires a path])
 +    fi
      AC_MSG_RESULT([$use_bundled_libevent])
      if test x"$use_bundled_libevent" = x"yes" ; then
          AC_CONFIG_SUBDIRS([libevent])
@@@ -174,47 -56,13 +174,47 @@@ AC_ARG_ENABLE(fhs
                use_pam_so=yes
                AC_DEFINE(FHS_COMPATIBILITY, 1, [Define if you want compatibily with the FHS])
                AC_MSG_RESULT([yes])
 +        atalk_cv_fhs_compat=yes
        else
                AC_MSG_RESULT([no])
 +        atalk_cv_fhs_compat=no
        fi
        ],[
                AC_MSG_RESULT([no])
 -      ]
 -)])
 +        atalk_cv_fhs_compat=no
 +])])
 +
 +dnl netatalk lockfile path
 +AC_DEFUN([AC_NETATALK_LOCKFILE], [
 +    AC_MSG_CHECKING([netatalk lockfile path])
 +    AC_ARG_WITH(
 +        lockfile,
 +        [AS_HELP_STRING([--with-lockfile=PATH],[Path of netatalk lockfile])],
 +        ac_cv_netatalk_lock=$withval,
 +        ac_cv_netatalk_lock=""
 +    )
 +    if test -z "$ac_cv_netatalk_lock" ; then
 +        ac_cv_netatalk_lock=/var/spool/locks/netatalk
 +        if test x"$atalk_cv_fhs_compat" = x"yes" ; then
 +            ac_cv_netatalk_lock=/var/run/netatalk.pid
 +        else
 +            case "$host_os" in
 +            *freebsd*)
 +                ac_cv_netatalk_lock=/var/spool/lock/netatalk
 +                ;;
 +            *netbsd*|*openbsd*)
 +                ac_cv_netatalk_lock=/var/run/netatalk.pid
 +                ;;
 +            *linux*)
 +                ac_cv_netatalk_lock=/var/lock/netatalk
 +                ;;
 +            esac
 +        fi
 +    fi
 +    AC_DEFINE_UNQUOTED(PATH_NETATALK_LOCK, ["$ac_cv_netatalk_lock"], [netatalk lockfile path])
 +    AC_SUBST(PATH_NETATALK_LOCK, ["$ac_cv_netatalk_lock"])
 +    AC_MSG_RESULT([$ac_cv_netatalk_lock])
 +])
  
  dnl 64bit platform check
  AC_DEFUN([AC_NETATALK_64BIT_LIBS], [
@@@ -397,7 -245,7 +397,7 @@@ AC_ARG_ENABLE(shell-check
  )
  ])
  
 -dnl Check for optional sysv initscript install
 +dnl Check for optional initscript install
  AC_DEFUN([AC_NETATALK_INIT_STYLE], [
      AC_ARG_WITH(init-style,
                  [  --with-init-style       use OS specific init config [[redhat-sysv|redhat-systemd|suse-sysv|suse-systemd|gentoo|netbsd|debian|solaris|systemd]]],
          ;;
      "redhat-sysv")
            AC_MSG_RESULT([enabling redhat-style sysv initscript support])
 +          ac_cv_init_dir="/etc/rc.d/init.d"
            ;;
      "redhat-systemd")
            AC_MSG_RESULT([enabling redhat-style systemd support])
 +          ac_cv_init_dir="/lib/systemd/system"
            ;;
      "suse")
            AC_MSG_ERROR([--with-init-style=suse is obsoleted. Use suse-sysv or suse-systemd.])
          ;;
      "suse-sysv")
            AC_MSG_RESULT([enabling suse-style sysv initscript support])
 +          ac_cv_init_dir="/etc/init.d"
            ;;
      "suse-systemd")
            AC_MSG_RESULT([enabling suse-style systemd support (>=openSUSE12.1)])
 +          ac_cv_init_dir="/lib/systemd/system"
            ;;
      "gentoo")
            AC_MSG_RESULT([enabling gentoo-style initscript support])
 +          ac_cv_init_dir="/etc/init.d"
          ;;
      "netbsd")
            AC_MSG_RESULT([enabling netbsd-style initscript support])
 +          ac_cv_init_dir="/etc/rc.d"
          ;;
      "debian")
            AC_MSG_RESULT([enabling debian-style initscript support])
 +          ac_cv_init_dir="/etc/init.d"
          ;;
      "solaris")
            AC_MSG_RESULT([enabling solaris-style SMF support])
 +          ac_cv_init_dir="/lib/svc/manifest/network/"
          ;;
      "systemd")
            AC_MSG_RESULT([enabling general systemd support])
 +          ac_cv_init_dir="/lib/systemd/system"
          ;;
      "none")
            AC_MSG_RESULT([disabling init-style support])
 +          ac_cv_init_dir="none"
          ;;
      *)
            AC_MSG_ERROR([illegal init-style])
      AM_CONDITIONAL(USE_SYSTEMD, test x$init_style = xsystemd || test x$init_style = xredhat-systemd || test x$init_style = xsuse-systemd)
      AM_CONDITIONAL(USE_UNDEF, test x$init_style = xnone)
  
 +    AC_ARG_WITH(init-dir,
 +                [  --with-init-dir=PATH    path to OS specific init directory],
 +                ac_cv_init_dir="$withval", ac_cv_init_dir="$ac_cv_init_dir"
 +    )
 +    INIT_DIR="$ac_cv_init_dir"
 +    AC_SUBST(INIT_DIR, ["$ac_cv_init_dir"])
  ])
  
  dnl OS specific configuration
@@@ -523,7 -355,7 +523,7 @@@ f
  dnl ----- Linux specific -----
  if test x"$this_os" = "xlinux"; then 
        AC_MSG_RESULT([ * Linux specific configuration])
 -      
 +    AC_DEFINE(LINUX, 1, [OS is Linux])        
        dnl ----- check if we need the quotactl wrapper
      AC_CHECK_HEADERS(linux/dqblk_xfs.h,,
                [AC_CHECK_HEADERS(linux/xqm.h linux/xfs_fs.h)
@@@ -749,7 -581,7 +749,7 @@@ save_CFLAGS="$CFLAGS
  save_LIBS="$LIBS"
  CFLAGS="$KRB5_CFLAGS"
  LIBS="$KRB5_LIBS"
 -AC_CHECK_FUNCS([krb5_free_unparsed_name krb5_free_error_message])
 +AC_CHECK_FUNCS([krb5_free_unparsed_name krb5_free_error_message krb5_free_keytab_entry_contents krb5_kt_free_entry])
  CFLAGS="$save_CFLAGS"
  LIBS="$save_LIBS"
  ])
@@@ -817,7 -649,7 +817,7 @@@ AC_SUBST(LDAP_CFLAGS
  AC_SUBST(LDAP_LDFLAGS)
  AC_SUBST(LDAP_LIBS)
  CFLAGS="$save_CFLAGS"
 -LDLFLAGS="$save_LDLFLAGS"
 +LDFLAGS="$save_LDFLAGS"
  LIBS="$save_LIBS"
  ])
  
@@@ -1107,7 -939,7 +1107,7 @@@ dnl ------ Check for sendfile() -------
  AC_DEFUN([AC_NETATALK_SENDFILE], [
  netatalk_cv_search_sendfile=yes
  AC_ARG_ENABLE(sendfile,
-     [  --disable-sendfile       disable sendfile syscall],
+     [  --disable-sendfile      disable sendfile syscall],
      [if test x"$enableval" = x"no"; then
              netatalk_cv_search_sendfile=no
          fi]
diff --combined macros/quota-check.m4
index 703c3568d34d38b36029a2c2e342abb8713af5a3,ad135080e91f0facd1610c26190561020741f54a..e2e145e616ed15da19fec87d1729c7ed211f9666
@@@ -1,9 -1,10 +1,9 @@@
 -dnl $Id: quota-check.m4,v 1.6 2005-07-20 23:58:21 didg Exp $
  dnl Autoconf macro to check for quota support
  dnl FIXME: This is in now way complete.
  
  AC_DEFUN([AC_NETATALK_CHECK_QUOTA], [
        AC_ARG_ENABLE(quota,
-       [  --enable-quota           Turn on quota support (default=auto)])
+       [  --enable-quota          Turn on quota support (default=auto)])
  
        if test x$enable_quota != xno; then
        QUOTA_LIBS=""