Projects
Kolab:3.4
cyrus-imapd
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 120
View file
working-diff.patch
Added
@@ -0,0 +1,520 @@ +diff --git a/lib/cyrusdb_skiplist.c b/lib/cyrusdb_skiplist.c +index 18d3ca3..fc540e0 100644 +--- a/lib/cyrusdb_skiplist.c ++++ b/lib/cyrusdb_skiplist.c +@@ -399,7 +399,7 @@ static unsigned RECSIZE_safe(struct dbengine *db, const char *ptr) + case ADD: + level = LEVEL_safe(db, ptr); + if (!level) { +- syslog(LOG_ERR, "IOERROR: skiplist RECSIZE not safe %s, offset %u", ++ syslog(LOG_ERR, "IOERROR: skiplist2 RECSIZE_safe not safe %s, offset %u", + db->fname, (unsigned)(ptr - db->map_base)); + return 0; + } +@@ -413,20 +413,50 @@ static unsigned RECSIZE_safe(struct dbengine *db, const char *ptr) + break; + + case DELETE: +- if (!is_safe(db, ptr+8)) { +- syslog(LOG_ERR, "IOERROR: skiplist RECSIZE not safe %s, offset %u", +- db->fname, (unsigned)(ptr - db->map_base)); +- return 0; +- } + ret += 8; + break; + + case COMMIT: +- if (!is_safe(db, ptr+4)) { +- syslog(LOG_ERR, "IOERROR: skiplist RECSIZE not safe %s, offset %u", +- db->fname, (unsigned)(ptr - db->map_base)); +- return 0; +- } ++ ret += 4; ++ break; ++ } ++ ++ return ret; ++} ++ ++/* how many levels does this record have? */ ++static unsigned LEVEL(const char *ptr) ++{ ++ const uint32_t *p, *q; ++ ++ assert(TYPE(ptr) == DUMMY || TYPE(ptr) == INORDER || TYPE(ptr) == ADD); ++ p = q = (uint32_t *) FIRSTPTR(ptr); ++ while (*p != (uint32_t)-1) p++; ++ return (p - q); ++} ++ ++/* how big is this record? */ ++static unsigned RECSIZE(const char *ptr) ++{ ++ int ret = 0; ++ switch (TYPE(ptr)) { ++ case DUMMY: ++ case INORDER: ++ case ADD: ++ ret += 4; /* tag */ ++ ret += 4; /* keylen */ ++ ret += ROUNDUP(KEYLEN(ptr)); /* key */ ++ ret += 4; /* datalen */ ++ ret += ROUNDUP(DATALEN(ptr)); /* data */ ++ ret += 4 * LEVEL(ptr); /* pointers */ ++ ret += 4; /* padding */ ++ break; ++ ++ case DELETE: ++ ret += 8; ++ break; ++ ++ case COMMIT: + ret += 4; + break; + } +@@ -494,12 +524,7 @@ static int newtxn(struct dbengine *db, struct txn **tidptr) + } + + +-static unsigned PADDING_safe(struct dbengine *db, const char *ptr) +-{ +- unsigned size = RECSIZE_safe(db, ptr); +- if (!size) return 0; +- return ntohl(*((uint32_t *)((ptr) + size - 4))); +-} ++#define PADDING(ptr) (ntohl(*((uint32_t *)((ptr) + RECSIZE(ptr) - 4)))) + + /* given an open, mapped db, read in the header information */ + static int read_header(struct dbengine *db) +@@ -570,9 +595,9 @@ static int read_header(struct dbengine *db) + db->fname); + r = CYRUSDB_IOERROR; + } +- if (!r && LEVEL_safe(db, dptr) != db->maxlevel) { ++ if (!r && LEVEL(dptr) != db->maxlevel) { + syslog(LOG_ERR, "DBERROR: %s: DUMMY level(%d) != db->maxlevel(%d)", +- db->fname, LEVEL_safe(db, dptr), db->maxlevel); ++ db->fname, LEVEL(dptr), db->maxlevel); + r = CYRUSDB_IOERROR; + } + +@@ -1281,7 +1306,7 @@ static int mystore(struct dbengine *db, + return CYRUSDB_EXISTS; + } else { + /* replace with an equal height node */ +- lvl = LEVEL_safe(db, ptr); ++ lvl = LEVEL(ptr); + + /* log a removal */ + WRITEV_ADD_TO_IOVEC(iov, num_iov, (char *) &delrectype, 4); +@@ -1575,8 +1600,8 @@ static int myabort(struct dbengine *db, struct txn *tid) + + /* find the last log entry */ + for (offset = tid->logstart, ptr = db->map_base + offset; +- offset + RECSIZE_safe(db, ptr) != (uint32_t) tid->logend; +- offset += RECSIZE_safe(db, ptr), ptr = db->map_base + offset) ; ++ offset + RECSIZE(ptr) != (uint32_t) tid->logend; ++ offset += RECSIZE(ptr), ptr = db->map_base + offset) ; + + offset = ptr - db->map_base; + +@@ -1613,7 +1638,7 @@ static int myabort(struct dbengine *db, struct txn *tid) + /* re-add this record. it can't exist right now. */ + netnewoffset = *((uint32_t *)(ptr + 4)); + q = db->map_base + ntohl(netnewoffset); +- lvl = LEVEL_safe(db, q); ++ lvl = LEVEL(q); + (void) find_node(db, KEY(q), KEYLEN(q), updateoffsets); + for (i = 0; i < lvl; i++) { + /* the current pointers FROM this node are correct, +@@ -1628,7 +1653,7 @@ static int myabort(struct dbengine *db, struct txn *tid) + } + + /* remove looking at this */ +- tid->logend -= RECSIZE_safe(db, ptr); ++ tid->logend -= RECSIZE(ptr); + } + + /* truncate the file to remove log entries */ +@@ -1742,13 +1767,13 @@ static int mycheckpoint(struct dbengine *db) + uint32_t netnewoffset; + + ptr = db->map_base + offset; +- lvl = LEVEL_safe(db, ptr); ++ lvl = LEVEL(ptr); + db->listsize++; + + num_iov = 0; + WRITEV_ADD_TO_IOVEC(iov, num_iov, (char *) &iorectype, 4); + /* copy all but the rectype from the record */ +- WRITEV_ADD_TO_IOVEC(iov, num_iov, (char *) ptr + 4, RECSIZE_safe(db, ptr) - 4); ++ WRITEV_ADD_TO_IOVEC(iov, num_iov, (char *) ptr + 4, RECSIZE(ptr) - 4); + + newoffset = lseek(db->fd, 0, SEEK_END); + netnewoffset = htonl(newoffset); +@@ -1915,9 +1940,9 @@ static int dump(struct dbengine *db, int detail __attribute__((unused))) + case INORDER: + case ADD: + printf("kl=%d dl=%d lvl=%d\n", +- KEYLEN(ptr), DATALEN(ptr), LEVEL_safe(db, ptr)); ++ KEYLEN(ptr), DATALEN(ptr), LEVEL(ptr)); + printf("\t"); +- for (i = 0; i < LEVEL_safe(db, ptr); i++) { ++ for (i = 0; i < LEVEL(ptr); i++) { + printf("%04X ", FORWARD(ptr, i)); + } + printf("\n"); +@@ -1932,7 +1957,7 @@ static int dump(struct dbengine *db, int detail __attribute__((unused))) + break; + } + +- ptr += RECSIZE_safe(db, ptr); ++ ptr += RECSIZE(ptr); + } + + unlock(db); +@@ -1961,7 +1986,7 @@ static int myconsistent(struct dbengine *db, struct txn *tid, int locked) + + ptr = db->map_base + offset; + +- for (i = 0; i < LEVEL_safe(db, ptr); i++) { ++ for (i = 0; i < LEVEL(ptr); i++) { + offset = FORWARD(ptr, i); + + if (offset > db->map_size) { +@@ -2005,11 +2030,9 @@ static int myconsistent(struct dbengine *db, struct txn *tid, int locked) + static int recovery(struct dbengine *db, int flags) + { + const char *ptr, *keyptr; +- unsigned filesize = db->map_size; + unsigned updateoffsets[SKIPLIST_MAXLEVEL+1]; + uint32_t offset, offsetnet, myoff = 0; +- int r = 0; +- int need_checkpoint = libcyrus_config_getswitch(CYRUSOPT_SKIPLIST_ALWAYS_CHECKPOINT); ++ int r = 0, need_checkpoint = 0; + time_t start = time(NULL); + unsigned i; + +@@ -2063,11 +2086,11 @@ static int recovery(struct dbengine *db, int flags) + }
View file
cyrus-imapd.cvt_cyrusdb_all
Changed
@@ -15,21 +15,42 @@ fi #if [ ! $(whoami) = "cyrus" ]; then -# exec $SWITCHUSER -s /bin/bash - cyrus -c "cd \$HOME < /dev/null ; INSTANCE=$0 $*" +# exec $SWITCHUSER -s /bin/bash - cyrus -c "cd \$HOME < /dev/null ; INSTANCE=$0 $*" +# exit 0 #fi +umask 166 + +alt_config="/etc/imapd.conf" +devel_mode=0 + +while [ $# -gt 0 ]; do + case $1 in + -C) + alt_config=$2 + shift; shift + ;; + + --devel) + devel_mode=1 + shift + ;; + + esac +done + declare -a dbs declare -a db_paths dbs[${#dbs[@]}]="annotation_db"; db_paths[${#db_paths[@]}]="annotations.db" dbs[${#dbs[@]}]="duplicate_db"; db_paths[${#db_paths[@]}]="deliver.db" -dbs[${#dbs[@]}]="mboxkey_db"; db_paths[${#db_paths[@]}]="" +# dbs[${#dbs[@]}]="mboxkey_db"; db_paths[${#db_paths[@]}]="" dbs[${#dbs[@]}]="mboxlist_db"; db_paths[${#db_paths[@]}]="mailboxes.db" -dbs[${#dbs[@]}]="ptscache_db"; db_paths[${#db_paths[@]}]="annotations.db" +dbs[${#dbs[@]}]="ptscache_db"; db_paths[${#db_paths[@]}]="ptclient/ptscache.db" dbs[${#dbs[@]}]="quota_db"; db_paths[${#db_paths[@]}]="quotas.db" -dbs[${#dbs[@]}]="seenstate_db"; db_paths[${#db_paths[@]}]="" +# dbs[${#dbs[@]}]="seenstate_db"; db_paths[${#db_paths[@]}]="" dbs[${#dbs[@]}]="statuscache_db"; db_paths[${#db_paths[@]}]="statuscache.db" -dbs[${#dbs[@]}]="subscription_db"; db_paths[${#db_paths[@]}]="" +# dbs[${#dbs[@]}]="subscription_db"; db_paths[${#db_paths[@]}]="" dbs[${#dbs[@]}]="tls_sessions_db"; db_paths[${#db_paths[@]}]="tls_sessions.db" dbs[${#dbs[@]}]="userdeny_db"; db_paths[${#db_paths[@]}]="user_deny.db" @@ -37,59 +58,152 @@ # Yes, consistent # 0 -function cvt_database() { - echo "would convert $1" +cvt_cyrusdb="/usr/lib/cyrus-imapd/cvt_cyrusdb" +cyr_dbtool="/usr/lib/cyrus-imapd/cyr_dbtool" +cyr_info="/usr/lib/cyrus-imapd/cyr_info" + +system_magic=$(file --version 2>&1 | awk '/magic file/ {print $4}') + +if [ ${devel_mode} -gt 0 ]; then + if [ -f "$(pwd)/imap/cvt_cyrusdb" ]; then + cvt_cyrusdb="$(pwd)/imap/cvt_cyrusdb" + fi + + if [ -f "$(pwd)/imap/.libs/cyr_dbtool" ]; then + cyr_dbtool="$(pwd)/imap/cyr_dbtool" + fi + + if [ -f "$(pwd)/imap/.libs/cyr_info" ]; then + cyr_info="$(pwd)/imap/cyr_info" + fi +fi + +function check_consistency() { + db_path=$1 + db_tech=$2 + + if [ ! -f "${db_path}" ]; then +# echo "No such file or directory '${db_path}'" + return 1 + fi + + retval=$(${cyr_dbtool} -C ${alt_config} ${db_path} ${db_tech} consistent >/dev/null 2>&1; echo $?) + + return ${retval} +} + +function convert_database() { +# echo "Converting $1 from $2 to $3 using $4" + retval=$(${cvt_cyrusdb} -C ${alt_config} "$1" "$2" "$3" "$4" >/dev/null 2>&1; echo $?) + chown cyrus:mail "$3" +} + +function expand_db_path() { + if [ "${1:0:1}" != "/" ]; then + config_directory=$(get_config "configdirectory") + value="${config_directory}/${1}" + fi + + echo "${value}" } function get_config() { - echo $(/usr/lib/cyrus-imapd/cyr_info conf | grep -E "^$1:\s+" | sed -r -e 's/[a-z0-9_-]+\:(.*)/\1/g') + echo $(${cyr_info} -C ${alt_config} conf | grep -E "^$1:\s+" | sed -r -e 's/[a-z0-9_-]+\:\s*(.*)/\1/g') } function get_config_default() { - echo $(/usr/lib/cyrus-imapd/cyr_info allconf | grep -E "^$1:\s+" | sed -r -e 's/[a-z0-9_-]+\:(.*)/\1/g') + echo $(${cyr_info} -C ${alt_config} conf-default | grep -E "^$1:\s+" | sed -r -e 's/[a-z0-9_-]+\:\s*(.*)/\1/g') } function get_current() { - value=$(/usr/lib/cyrus-imapd/cyr_info allconf | grep -E "^$1_path:\s+" | sed -r -e 's/[a-z0-9_-]+\:(.*)/\1/g') + default_path="$2" + value=$(${cyr_info} -C ${alt_config} conf-all | grep -E "^$1_path:\s+" | sed -r -e 's/[a-z0-9_-]+\:\s*(.*)/\1/g') if [ -z "${value}" ]; then - value="/var/lib/imap/annotations.db" + if [ ! -z "${default_path}" ]; then + value=$(expand_db_path "${default_path}") + fi fi -} -annotation_db=$(get_config "annotation_db") -annotation_db_current=$(get_current "annotation_db") -annotation_db_default=$(get_config_default "annotation_db") + if [ -z "${value}" ]; then +# echo "Cannot determine $1_path" + return 1 + fi -if [ ! -z "${annotation_db}" ]; then - echo "annotation_db format configured to be ${annotation_db}" + if [ ! -f "${value}" ]; then +# echo "No such file or directory '${value}'" + return 1 + fi - if [ ! -z "${annotation_db_default}" ]; then - echo "annotation_db default format is ${annotation_db_default}" + current=$(file -b -m /var/lib/imap/rpm/magic:${system_magic} "${value}") - if [ "${annotation_db}" != "${annotation_db_default}" ]; then - cvt_database annotation_db - echo "those two do not match" - else - echo "configured and default match" - fi + if echo "${current}" | grep -qi skiplist > /dev/null 2>&1; then + current="skiplist" + elif echo "${current}" | grep -qi twoskip > /dev/null 2>&1; then + current="twoskip" + elif echo "${current}" | grep -qi text > /dev/null 2>&1; then + current="flat" else - echo "default not known" + current="berkeley" fi -else - if [ ! -z "${annotation_db_default}" ]; then - echo "annotation_db default format is ${annotation_db_default}" - - if [ "${annotation_db}" != "${annotation_db_default}" ]; then - cvt_database annotation_db - echo "those two do not match" - else - echo "configured and default match" + + echo "${current}" +} + +config_directory=$(get_config "configdirectory") + +echo "Using configuration directory: '${config_directory}'" + +x=0 +while [ ${x} -lt ${#dbs[@]} ]; do + config=$(get_config "${dbs[${x}]}") + default=$(get_config_default "${dbs[${x}]}") + current=$(get_current "${dbs[${x}]}" "${db_paths[${x}]}") + + echo -n "${dbs[${x}]}: " + + if [ $? -ne 0 ]; then + echo "SKIPPED" + let x++ + continue + fi + + # If configuration doesn't hold anything, we have defaults + if [ -z "${config}" ]; then + config="${default}" + fi + + if [ "${config}" == "${default}" -a "${config}" == "${current}" ]; then + echo "SKIPPED (unchanged)" + let x++
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.