]> arthur.barton.de Git - netatalk.git/commitdiff
Merge master
authorFrank Lahm <franklahm@googlemail.com>
Tue, 3 Jan 2012 14:26:39 +0000 (15:26 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 3 Jan 2012 14:26:39 +0000 (15:26 +0100)
NEWS
distrib/initscripts/rc.atalk.suse-sysv.tmpl
etc/cnid_dbd/cmd_dbd.c
etc/cnid_dbd/cnid_metad.c
etc/cnid_dbd/main.c
libatalk/unicode/util_unistr.c

diff --git a/NEWS b/NEWS
index 8cdd6881acff2b71da4aa1b4357b3de3f6c2936f..1ef0583bb64686f89d820603fad23b5d154ba4d1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,8 +30,12 @@ Changes in 2.2.2
 * FIX: afpd: Fix dircache bug, NetAFP Bug ID #13
 * FIX: dbd: Better checking for duplicated or bogus CNIDs from AppleDouble
        files
+* FIX: dbd: Remove BerkeleyDB database environment after running `dbd`. This
+       is crucial for the automatic BerkeleyDB database upgrade feature which
+       is built into cnid_dbd and dbd.
 * FIX: Fix compilation error when AppleTalk support is disabled
 * FIX: Portability fixes
+* FIX: search of surrogate pair
 
 Changes in 2.2.1
 ================
index 68328e6d779f26b5d627d3c306054d2d2a395d2d..e06d0a06087b9aacf5a252cd2fab6ffc96d712ae 100755 (executable)
@@ -9,7 +9,7 @@
 # Provides:       netatalk
 # Required-Start: $local_fs
 # Required-Stop: $local_fs
-# Should-Start:  $network $named $remote_fs $syslog slpd
+# Should-Start:  $network $named $remote_fs $syslog slpd avahi-daemon
 # Should-Stop:   $remote_fs $network $syslog
 # Default-Start:  3 5
 # Default-Stop:
index e07741564136026d719db8505bb04df8f3101c0c..3b81b8b59df3fdeb428444ffb42837f9f817afdb 100644 (file)
@@ -170,7 +170,8 @@ static void set_signal(void)
 
 static void usage (void)
 {
-    printf("Usage: dbd [-e|-t|-v|-x] -d [-i] | -s [-c|-n]| -r [-c|-f] | -u <path to netatalk volume>\n"
+    printf("dbd (Netatalk %s)\n"
+           "Usage: dbd [-e|-t|-v|-x] -d [-i] | -s [-c|-n]| -r [-c|-f] | -u <path to netatalk volume>\n"
            "dbd can dump, scan, reindex and rebuild Netatalk dbd CNID databases.\n"
            "dbd must be run with appropiate permissions i.e. as root.\n\n"
            "Main commands are:\n"
@@ -186,7 +187,7 @@ static void usage (void)
            "      7. Check for orphaned CNIDs in database (requires -e)\n"
            "      8. Open and close adouble files\n"
            "      Options: -c Don't check .AppleDouble stuff, only ckeck orphaned.\n"
-           "               -n Don't open CNID database, skip CNID checks\n\n"
+           "               -n Don't open CNID database, skip CNID checks.\n\n"
            "   -r Rebuild volume:\n"
            "      1. Sync CNIDSs in database with volume\n"
            "      2. Make sure .AppleDouble dir exist, create if missing\n"
@@ -197,18 +198,21 @@ static void usage (void)
            "      7. Check for orphaned CNIDs in database (requires -e)\n"
            "      8. Open and close adouble files\n"
            "      Options: -c Don't create .AppleDouble stuff, only cleanup orphaned.\n"
-           "               -f wipe database and rebuild from IDs stored in AppleDouble files,\n"
-           "                  only available for volumes without 'nocnidcache' option. Implies -e.\n\n"
+           "               -f wipe database and rebuild from IDs stored in AppleDouble\n"
+           "                  files, only available for volumes without 'nocnidcache'\n"
+           "                  option. Implies -e.\n\n"
            "   -u Upgrade:\n"
-           "      Opens the database which triggers any necessary upgrades, then closes and exits.\n\n"
+           "      Opens the database which triggers any necessary upgrades,\n"
+           "      then closes and exits.\n\n"
            "General options:\n"
            "   -e only work on inactive volumes and lock them (exclusive)\n"
            "   -x rebuild indexes (just for completeness, mostly useless!)\n"
            "   -t show statistics while running\n"
            "   -v verbose\n\n"
            "WARNING:\n"
-           "For -r -f restore of the CNID database from the adouble files, the CNID must of course\n"
-           "be synched to them files first with a plain -r rebuild !\n"
+           "For -r -f restore of the CNID database from the adouble files,\n"
+           "the CNID must of course be synched to them files first with a plain -r rebuild!\n"
+           , VERSION
         );
 }
 
@@ -360,22 +364,22 @@ int main(int argc, char **argv)
 
     /* Get db lock */
     if ((db_locked = get_lock(LOCK_EXCL, dbpath)) == -1)
-        goto exit_failure;
+        goto exit_noenv;
     if (db_locked != LOCK_EXCL) {
         /* Couldn't get exclusive lock, try shared lock if -e wasn't requested */
         if (exclusive) {
             dbd_log(LOGSTD, "Database is in use and exlusive was requested");
-            goto exit_failure;
+            goto exit_noenv;
         }
         if ((db_locked = get_lock(LOCK_SHRD, NULL)) != LOCK_SHRD)
-            goto exit_failure;
+            goto exit_noenv;
     }
 
     /* Check if -f is requested and wipe db if yes */
     if ((flags & DBD_FLAGS_FORCE) && rebuild && (volinfo.v_flags & AFPVOL_CACHE)) {
         char cmd[8 + MAXPATHLEN];
         if ((db_locked = get_lock(LOCK_FREE, NULL)) != 0)
-            goto exit_failure;
+            goto exit_noenv;
 
         snprintf(cmd, 8 + MAXPATHLEN, "rm -rf \"%s\"", dbpath);
         dbd_log( LOGDEBUG, "Removing old database of volume: '%s'", volpath);
@@ -386,7 +390,7 @@ int main(int argc, char **argv)
         }
         dbd_log( LOGDEBUG, "Removed old database.");
         if ((db_locked = get_lock(LOCK_EXCL, dbpath)) == -1)
-            goto exit_failure;
+            goto exit_noenv;
     }
 
     /* 
@@ -394,13 +398,13 @@ int main(int argc, char **argv)
     */
     if ( ! nocniddb) {
         if ((dbd = dbif_init(dbpath, "cnid2.db")) == NULL)
-            goto exit_failure;
+            goto exit_noenv;
         
         if (dbif_env_open(dbd,
                           &db_param,
                           (db_locked == LOCK_EXCL) ? (DBOPTIONS | DB_RECOVER) : DBOPTIONS) < 0) {
             dbd_log( LOGSTD, "error opening database!");
-            goto exit_failure;
+            goto exit_noenv;
         }
 
         if (db_locked == LOCK_EXCL)
@@ -451,8 +455,13 @@ exit_success:
     ret = 0;
 
 exit_failure:
+    if (dbif_env_remove(dbpath) < 0) {
+        dbd_log( LOGSTD, "Error removing BerkeleyDB database environment");
+        ret++;
+    }
     get_lock(0, NULL);
-    
+
+exit_noenv:    
     if ((fchdir(cdir)) < 0)
         dbd_log(LOGSTD, "fchdir: %s", strerror(errno));
 
index 19087f19d5cc0ca31363bd79238717521daa9042..2a3bc6b9f32ce83e4ad0930dab5ab80bd8021e91 100644 (file)
@@ -451,8 +451,12 @@ int main(int argc, char *argv[])
 
     set_processname("cnid_metad");
 
-    while (( cc = getopt( argc, argv, "ds:p:h:u:g:l:f:")) != -1 ) {
+    while (( cc = getopt( argc, argv, "vVds:p:h:u:g:l:f:")) != -1 ) {
         switch (cc) {
+        case 'v':
+        case 'V':
+            printf("cnid_metad (Netatalk %s)\n", VERSION);
+            return -1;
         case 'd':
             debug = 1;
             break;
index 1219712e37dc67e8eabbb5b9fe502b98359aa8e1..55bbcddbb100c3b34fb34f5355d965c00bc6b3f0 100644 (file)
@@ -280,8 +280,12 @@ int main(int argc, char *argv[])
 
     set_processname("cnid_dbd");
 
-    while (( ret = getopt( argc, argv, "d")) != -1 ) {
+    while (( ret = getopt( argc, argv, "vVd")) != -1 ) {
         switch (ret) {
+        case 'v':
+        case 'V':
+            printf("cnid_dbd (Netatalk %s)\n", VERSION);
+            return -1;
         case 'd':
             delete_bdb = 1;
             break;
index 3c9a194b5dd6169813d68c40e9b94577fe1a13d2..e5ea4ba0fcea2cd8def574b835432305a0024c50 100644 (file)
@@ -179,8 +179,7 @@ wide & sp strcasechr()
 ucs2_t *strcasechr_w(const ucs2_t *s, ucs2_t c)
 {
        while (*s != 0) {
-/*             LOG(log_debug, logtype_default, "Comparing %X to %X (%X - %X)", c, *s, toupper_w(c), toupper_w(*s));*/
-               if (toupper_w(c) == toupper_w(*s)) return (ucs2_t *)s;
+               if (tolower_w(c) == tolower_w(*s)) return (ucs2_t *)s;
                s++;
        }
        if (c == *s) return (ucs2_t *)s;
@@ -192,7 +191,7 @@ ucs2_t *strcasechr_sp(const ucs2_t *s, uint32_t c_sp)
 {
        if (*s == 0) return NULL;
        while (s[1] != 0) {
-               if (toupper_sp(c_sp) == toupper_sp((uint32_t)*s << 16 | (uint32_t)s[1])) return (ucs2_t *)s;
+               if (tolower_sp(c_sp) == tolower_sp((uint32_t)*s << 16 | (uint32_t)s[1])) return (ucs2_t *)s;
                s++;
        }
 
@@ -249,7 +248,7 @@ ucs2_t *strstr_w(const ucs2_t *s, const ucs2_t *ins)
 /*******************************************************************
 wide strcasestr()
 ********************************************************************/
-/* */
+/* surrogate pair support */
 
 ucs2_t *strcasestr_w(const ucs2_t *s, const ucs2_t *ins)
 {
@@ -260,9 +259,22 @@ ucs2_t *strcasestr_w(const ucs2_t *s, const ucs2_t *ins)
        slen = strlen_w(s);
        inslen = strlen_w(ins);
        r = (ucs2_t *)s;
-       while ((r = strcasechr_w(r, *ins))) {
-               if (strncasecmp_w(r, ins, inslen) == 0) return r;
-               r++;
+
+       if ((0xD800 <= *ins) && (*ins < 0xDC00)) {
+               if ((0xDC00 <= ins[1]) && (ins[1] < 0xE000)) {
+                       u_int32_t ins_sp = (u_int32_t)*ins << 16 | (u_int32_t)ins[1];
+                       while ((r = strcasechr_sp(r, ins_sp))) {
+                               if (strncasecmp_w(r, ins, inslen) == 0) return r;
+                               r++;
+                       }
+               } else {
+                       return NULL; /* illegal sequence */
+               }
+       } else {
+               while ((r = strcasechr_w(r, *ins))) {
+                       if (strncasecmp_w(r, ins, inslen) == 0) return r;
+                       r++;
+               }
        }
        return NULL;
 }
@@ -358,6 +370,8 @@ ucs2_t *strdup_w(const ucs2_t *src)
 /*******************************************************************
 copy a string with max len
 ********************************************************************/
+/* This function is not used. */
+/* NOTE: not check isolation of surrogate pair */
 
 ucs2_t *strncpy_w(ucs2_t *dest, const ucs2_t *src, const size_t max)
 {
@@ -377,7 +391,9 @@ ucs2_t *strncpy_w(ucs2_t *dest, const ucs2_t *src, const size_t max)
 /*******************************************************************
 append a string of len bytes and add a terminator
 ********************************************************************/
+/* These functions are not used. */
 
+/* NOTE: not check isolation of surrogate pair */
 ucs2_t *strncat_w(ucs2_t *dest, const ucs2_t *src, const size_t max)
 {
        size_t start;
@@ -394,7 +410,7 @@ ucs2_t *strncat_w(ucs2_t *dest, const ucs2_t *src, const size_t max)
        return dest;
 }
 
-
+/* no problem of surrogate pair */
 ucs2_t *strcat_w(ucs2_t *dest, const ucs2_t *src)
 {
        size_t start;