From: Frank Lahm Date: Tue, 3 Jan 2012 14:26:39 +0000 (+0100) Subject: Merge master X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=7be2a68aa70fa5641e944ad0aed6f699736d3de9;hp=097ca98149a60e9b631cfe617064281eab68a450 Merge master --- diff --git a/NEWS b/NEWS index 8cdd6881..1ef0583b 100644 --- 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 ================ diff --git a/distrib/initscripts/rc.atalk.suse-sysv.tmpl b/distrib/initscripts/rc.atalk.suse-sysv.tmpl index 68328e6d..e06d0a06 100755 --- a/distrib/initscripts/rc.atalk.suse-sysv.tmpl +++ b/distrib/initscripts/rc.atalk.suse-sysv.tmpl @@ -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: diff --git a/etc/cnid_dbd/cmd_dbd.c b/etc/cnid_dbd/cmd_dbd.c index e0774156..3b81b8b5 100644 --- a/etc/cnid_dbd/cmd_dbd.c +++ b/etc/cnid_dbd/cmd_dbd.c @@ -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 \n" + printf("dbd (Netatalk %s)\n" + "Usage: dbd [-e|-t|-v|-x] -d [-i] | -s [-c|-n]| -r [-c|-f] | -u \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)); diff --git a/etc/cnid_dbd/cnid_metad.c b/etc/cnid_dbd/cnid_metad.c index 19087f19..2a3bc6b9 100644 --- a/etc/cnid_dbd/cnid_metad.c +++ b/etc/cnid_dbd/cnid_metad.c @@ -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; diff --git a/etc/cnid_dbd/main.c b/etc/cnid_dbd/main.c index 1219712e..55bbcddb 100644 --- a/etc/cnid_dbd/main.c +++ b/etc/cnid_dbd/main.c @@ -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; diff --git a/libatalk/unicode/util_unistr.c b/libatalk/unicode/util_unistr.c index 3c9a194b..e5ea4ba0 100644 --- a/libatalk/unicode/util_unistr.c +++ b/libatalk/unicode/util_unistr.c @@ -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;