# -m and -M options are broken in 2.3: dependancy on external cdb database # which maps username to Unix UID on our systems. Use mailbox uniqueid instead. # diff -uNrd cyrus-imapd-2.3.8/imap/make_md5.c cyrus-imapd/imap/make_md5.c --- cyrus-imapd-2.3.8/imap/make_md5.c 2006-11-30 17:11:19.000000000 +0000 +++ cyrus-imapd/imap/make_md5.c 2007-03-26 17:35:51.000000000 +0100 @@ -28,7 +28,6 @@ #include "map.h" #include "md5global.h" #include "md5.h" -/*#include "cdb.h"*/ /* global state */ const int config_need_data = 0; @@ -596,30 +595,25 @@ * but given tranche of users. That tranche gets regenerated from scratch */ static int -use_existing_data(char *user, int uid_set, int uid_modulo, int uid_fd) +use_existing_data(char *s, int uid_set, int uid_modulo) { - char buf[64]; - unsigned long len; - int uid; - - if ((uid_modulo == 0) || (uid_fd < 0)) - return(1); -#if 0 /* XXX make sure we're not the replica */ - if (cdb_seek(uid_fd, (unsigned char *)user, strlen(user), &len) != 1) - return(1); -#endif - if ((len >= sizeof(buf)) || (read(uid_fd, buf, len) != len)) - return(1); + unsigned long total; - if ((uid = atoi(buf)) == 0) + if (uid_modulo == 0) return(1); - return ((uid_set == (uid % uid_modulo)) ? 0 : 1); + total = 0; + while (*s) { + total += (unsigned long)*s; + s++; + } + + return ((uid_set == (total % uid_modulo)) ? 0 : 1); } static int do_user(const char *md5_dir, char *user, struct namespace *namespacep, - int uid_set, int uid_modulo, int uid_fd) + int uid_set, int uid_modulo) { char buf[MAX_MAILBOX_PATH+1]; char buf2[MAX_MAILBOX_PATH+1]; @@ -630,7 +624,7 @@ imapd_userid = user; imapd_authstate = auth_newstate(imapd_userid); - if (use_existing_data(user, uid_set, uid_modulo, uid_fd)) { + if (use_existing_data(user, uid_set, uid_modulo)) { snprintf(buf, sizeof(buf)-1, "%s/%c/%s", md5_dir, user[0], user); r = md5_mailbox_list_read(md5_mailbox_list, buf); @@ -735,7 +729,6 @@ char *input_file = NULL; const char *md5_dir = NULL; const char *uid_file = NULL; - int uid_fd = (-1); int uid_set = 0; int uid_modulo = 0; int r = 0; @@ -819,12 +812,6 @@ if (!md5_dir) md5_dir = xstrdup("/var/imap/md5"); - if (((uid_file = config_getstring(IMAPOPT_MD5_USER_MAP)) != NULL) && - ((uid_fd=open(uid_file, O_RDONLY)) < 0)) { - syslog(LOG_NOTICE, "Failed to open uid file %s: %m\n", uid_file); - shut_down(1); - } - if (max_children == 0) { /* Simple case */ @@ -842,7 +829,7 @@ continue; if (do_user(md5_dir, buf, &md5_namespace, - uid_set, uid_modulo, uid_fd)) { + uid_set, uid_modulo)) { syslog(LOG_NOTICE, "Error make_md5 %s: %m", buf); shut_down(1); } @@ -850,7 +837,7 @@ fclose(file); } else for (i = optind; i < argc; i++) { if (do_user(md5_dir, argv[i], &md5_namespace, - uid_set, uid_modulo, uid_fd)) { + uid_set, uid_modulo)) { syslog(LOG_NOTICE, "Error make_md5 %s: %m", argv[i]); shut_down(1); } @@ -890,7 +877,7 @@ if (pid == 0) { /* Child process */ do_user(md5_dir, buf, &md5_namespace, - uid_set, uid_modulo, uid_fd); + uid_set, uid_modulo); _exit(0); } md5_children++; /* Parent process */ @@ -907,7 +894,7 @@ if (pid == 0) { /* Child process */ do_user(md5_dir, argv[i], &md5_namespace, - uid_set, uid_modulo, uid_fd); + uid_set, uid_modulo); _exit(0); } md5_children++; /* Parent process */