Fix warnings all over citserver; handle function replies; remove unused code.
authorWilfried Goesgens <dothebart@citadel.org>
Wed, 7 Sep 2011 14:59:21 +0000 (14:59 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Wed, 7 Sep 2011 14:59:21 +0000 (14:59 +0000)
21 files changed:
citadel/config.c
citadel/context.c
citadel/file_ops.c
citadel/locate_host.c
citadel/modules/crypto/serv_crypto.c
citadel/modules/imap/imap_fetch.c
citadel/modules/imap/imap_list.c
citadel/modules/imap/imap_misc.c
citadel/modules/imap/serv_imap.c
citadel/modules/managesieve/serv_managesieve.c
citadel/modules/migrate/serv_migrate.c
citadel/modules/network/serv_network.c
citadel/modules/openid/serv_openid_rp.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/vcard/serv_vcard.c
citadel/modules/wiki/serv_wiki.c
citadel/modules/xmpp/xmpp_messages.c
citadel/msgbase.c
citadel/user_ops.c
citadel/user_ops.h
citadel/utillib/citadel_dirs.c

index 6817e27fe860c19621028152f5c7281ea5d08d5e..bc9a4128e9bd0b9c8cc5c0793797cee82d5a8bf1 100644 (file)
@@ -179,6 +179,9 @@ void put_config(void)
                perror(file_citadel_config);
        else {
                rv = fwrite((char *) &config, sizeof(struct config), 1, cfp);
+               if (rv == -1)
+                       syslog(LOG_EMERG, "Failed to write: %s [%s]\n", 
+                              file_citadel_config, strerror(errno));
                fclose(cfp);
        }
 }
index cf8309e01fb8e329b624f4a3ed534f030f31c484..0b433502e4fd4c9e234c4012eb643df2ea829d7f 100644 (file)
@@ -276,12 +276,10 @@ void terminate_idle_sessions(void)
 {
        CitContext *ccptr;
        time_t now;
-       int session_to_kill;
        int killed = 0;
        int longrunners = 0;
 
        now = time(NULL);
-       session_to_kill = 0;
        begin_critical_section(S_SESSION_TABLE);
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
                if (
index bb5e985a6c0e5c866f2207bb01db71dbd4475b9f..3bb6da1d8fc9962ec5048c94a334e0fd3d66c472 100644 (file)
@@ -373,6 +373,12 @@ void cmd_oimg(char *cmdbuf)
                return;
        }
        rv = fread(&MimeTestBuf[0], 1, 32, CC->download_fp);
+       if (rv == -1) {
+               cprintf("%d Cannot access %s: %s\n",
+                       ERROR + FILE_NOT_FOUND, pathname, strerror(errno));
+               return;
+       }
+
        rewind (CC->download_fp);
        OpenCmdResult(pathname, GuessMimeType(&MimeTestBuf[0], 32));
 }
@@ -706,6 +712,10 @@ void cmd_writ(char *cmdbuf)
        buf = malloc(bytes + 1);
        client_read(buf, bytes);
        rv = fwrite(buf, bytes, 1, CC->upload_fp);
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Couldn't write: %s\n",
+                      strerror(errno));
+       }
        free(buf);
 }
 
index c3a19636930996eeecebb11db922588bf248829f..2a7568b232e4ce1fbb05d6f05c7e88fe154ccf1c 100644 (file)
@@ -243,13 +243,11 @@ int rbl_check(char *message_to_spammer)
        int num_rbl;
        char rbl_domains[SIZ];
        char txt_answer[1024];
-       int ip_version = 4;
 
        strcpy(message_to_spammer, "ok");
 
        if ((strchr(CC->cs_addr, '.')) && (!strchr(CC->cs_addr, ':'))) {
                int a1, a2, a3, a4;
-               ip_version = 4;
 
                sscanf(CC->cs_addr, "%d.%d.%d.%d", &a1, &a2, &a3, &a4);
                snprintf(tbuf, sizeof tbuf, "%d.%d.%d.%d.", a4, a3, a2, a1);
@@ -261,8 +259,6 @@ int rbl_check(char *message_to_spammer)
                char workbuf[sizeof tbuf];
                char *ptr;
 
-               ip_version = 6;
-
                /* tedious code to expand and reverse an IPv6 address */
                safestrncpy(tbuf, CC->cs_addr, sizeof tbuf);
                num_colons = haschar(tbuf, ':');
index 6afeee84bc7c0b7a643ea51fce35093bff23932a..5fa965e5d25d7f0048acccf5db4e5de3e8664689 100644 (file)
@@ -79,7 +79,7 @@ void destruct_ssl(void)
 
 void init_ssl(void)
 {
-       SSL_METHOD *ssl_method;
+       const SSL_METHOD *ssl_method;
        DH *dh;
        RSA *rsa=NULL;
        X509_REQ *req = NULL;
@@ -471,11 +471,10 @@ int client_readline_sslbuffer(StrBuf *Line, StrBuf *IOBuf, const char **Pos, int
        CitContext *CCC = CC;
        const char *pos = NULL;
        const char *pLF;
-       int len, rlen, retlen;
+       int len, rlen;
        int nSuccessLess = 0;
        const char *pch = NULL;
        
-       retlen = 0;
        if ((Line == NULL) ||
            (Pos == NULL) ||
            (IOBuf == NULL))
index 862f587570c373212b07207fb00cab5a62d6dc98..5fedc283afde9e2a7670625bab768e63f8e1415b 100644 (file)
@@ -1258,7 +1258,6 @@ int imap_extract_data_items(citimap_command *Cmd)
        int nArgs;
        int nest = 0;
        const char *pch, *end;
-       long initial_len;
 
        /* Convert all whitespace to ordinary space characters. */
        pch = ChrPtr(Cmd->CmdBuf);
@@ -1293,7 +1292,6 @@ int imap_extract_data_items(citimap_command *Cmd)
         */
        nArgs = StrLength(Cmd->CmdBuf) / 10 + 10;
        nArgs = CmdAdjust(Cmd, nArgs, 0);
-       initial_len = StrLength(Cmd->CmdBuf);
        Cmd->num_parms = 0;
        Cmd->Params[Cmd->num_parms].Key = pch = ChrPtr(Cmd->CmdBuf);
        end = Cmd->Params[Cmd->num_parms].Key + StrLength(Cmd->CmdBuf);
index f66f121339f778cae5fcfbf3da642df731d6e188..6dbbe6ebb9d25f5936f8d72008b43ff8738b1607 100644 (file)
@@ -195,7 +195,6 @@ void imap_list(int num_parms, ConstStr *Params)
        int selection_left = (-1);
        int selection_right = (-1);
        int return_left = (-1);
-       int return_right = (-1);
        int root_pos = 2;
        int patterns_left = 3;
        int patterns_right = 3;
@@ -388,7 +387,6 @@ void imap_list(int num_parms, ConstStr *Params)
                        }
 
                        if (paren_nest == 0) {
-                               return_right = i;       /* found end of patterns */
                                i = num_parms + 1;      /* break out of the loop */
                        }
                }
index 3392c71bc113027136690b0de10c86a0ef2276fa..3ccd463671ac8b20d26d7a055ef60196301bdeb6 100644 (file)
@@ -281,7 +281,6 @@ void imap_do_append_flags(long new_msgnum, char *new_message_flags) {
  */
 void imap_append(int num_parms, ConstStr *Params) {
        long literal_length;
-       long bytes_transferred;
        struct CtdlMessage *msg = NULL;
        long new_msgnum = (-1L);
        int ret = 0;
@@ -340,7 +339,6 @@ void imap_append(int num_parms, ConstStr *Params) {
        
        IUnbuffer ();
 
-       bytes_transferred = 0;
        client_read_blob(Imap->TransmittedMessage, literal_length, config.c_sleeping);
 
        if ((ret < 0) || (StrLength(Imap->TransmittedMessage) < literal_length)) {
index e9f566375302109ffb6091f8032377e901a776bc..eab1e8571803cc11f754321e9a565d27781d8bd1 100644 (file)
@@ -821,8 +821,6 @@ void imap_select(int num_parms, ConstStr *Params)
        int ra = 0;
        struct ctdlroom QRscratch;
        int msgs, new;
-       int floornum;
-       int roomflags;
        int i;
 
        /* Convert the supplied folder name to a roomname */
@@ -832,8 +830,6 @@ void imap_select(int num_parms, ConstStr *Params)
                Imap->selected = 0;
                return;
        }
-       floornum = (i & 0x00ff);
-       roomflags = (i & 0xff00);
 
        /* First try a regular match */
        c = CtdlGetRoom(&QRscratch, towhere);
@@ -1385,7 +1381,7 @@ void imap_rename(int num_parms, ConstStr *Params)
 {
        char old_room[ROOMNAMELEN];
        char new_room[ROOMNAMELEN];
-       int oldr, newr;
+       int newr;
        int new_floor;
        int r;
        struct irl *irl = NULL; /* the list */
@@ -1398,7 +1394,7 @@ void imap_rename(int num_parms, ConstStr *Params)
                return;
        }
 
-       oldr = imap_roomname(old_room, sizeof old_room, Params[2].Key);
+       imap_roomname(old_room, sizeof old_room, Params[2].Key);
        newr = imap_roomname(new_room, sizeof new_room, Params[3].Key);
        new_floor = (newr & 0xFF);
 
@@ -1477,7 +1473,6 @@ void imap_command_loop(void)
 {
        struct timeval tv1, tv2;
        suseconds_t total_time = 0;
-       int untagged_ok = 1;
        citimap *Imap;
        const char *pchs, *pche;
        const imap_handler_hook *h;
@@ -1554,10 +1549,6 @@ void imap_command_loop(void)
         * If the command just submitted does not contain a literal, we
         * might think about delivering some untagged stuff...
         */
-       if (*(ChrPtr(Imap->Cmd.CmdBuf) + StrLength(Imap->Cmd.CmdBuf) - 1)
-           == '}') {
-               untagged_ok = 0;
-       }
 
        /* Grab the tag, command, and parameters. */
        imap_parameterize(&Imap->Cmd);
index b0e5f7de9ba48b50c7db4b7b7ccfe600eb495dde..289bc5784ecafe8817a736a81e545881bb9f4e22 100644 (file)
@@ -279,7 +279,6 @@ void cmd_mgsve_auth(int num_parms, char **parms, struct sdm_userdata *u)
                /* todo, check length*/
        {
                char auth[SIZ];
-               int retval;
                char *message;
                char *username;
 
@@ -289,10 +288,10 @@ void cmd_mgsve_auth(int num_parms, char **parms, struct sdm_userdata *u)
                        message = ReadString(GetSizeToken(parms[2]), parms[0]);
                
                if (message != NULL) {/**< do we have tokenized login? */
-                       retval = CtdlDecodeBase64(auth, MGSVE->transmitted_message, SIZ);
+                       CtdlDecodeBase64(auth, MGSVE->transmitted_message, SIZ);
                }
                else 
-                       retval = CtdlDecodeBase64(auth, parms[2], SIZ);
+                       CtdlDecodeBase64(auth, parms[2], SIZ);
                username = auth;
                if ((*username == '\0') && (*(username + 1) != '\0'))
                        username ++;
index 5c0a2e27d9ae3d0c0139a176139a04dd33c83a0c..d1d6d04b95795d4adfc2bf51a6ebdb55104e3df5 100644 (file)
@@ -394,8 +394,6 @@ void migr_export_messages(void) {
 
 
 void migr_do_export(void) {
-       struct config *buf;
-       buf = &config;
        CitContext *Ctx;
 
        Ctx = CC;
index 7506a1abf372267158b71c6f6a918247353bed8a..7955f5a2eb935ebe4b16336c2f0d51a9653a9a36 100644 (file)
@@ -494,7 +494,6 @@ void network_deliver_digest(SpoolControl *sc) {
        long msglen;
        char *recps = NULL;
        size_t recps_len = SIZ;
-       size_t siz;
        struct recptypes *valid;
        namelist *nptr;
        char bounce_to[256];
@@ -541,7 +540,7 @@ void network_deliver_digest(SpoolControl *sc) {
 
        msg->cm_fields['M'] = malloc(msglen + 1);
        fseek(sc->digestfp, 0L, SEEK_SET);
-       siz = fread(msg->cm_fields['M'], (size_t)msglen, 1, sc->digestfp);
+       fread(msg->cm_fields['M'], (size_t)msglen, 1, sc->digestfp);
        msg->cm_fields['M'][msglen] = '\0';
 
        fclose(sc->digestfp);
@@ -653,7 +652,6 @@ void network_spool_msg(long msgnum, void *userdata) {
        SpoolControl *sc;
        int i;
        char *newpath = NULL;
-       size_t instr_len = SIZ;
        struct CtdlMessage *msg = NULL;
        namelist *nptr;
        maplist *mptr;
@@ -672,7 +670,6 @@ void network_spool_msg(long msgnum, void *userdata) {
        /*
         * Process mailing list recipients
         */
-       instr_len = SIZ;
        if (sc->listrecps != NULL) {
                /* Fetch the message.  We're going to need to modify it
                 * in order to insert the [list name] in it, etc.
@@ -810,7 +807,6 @@ void network_spool_msg(long msgnum, void *userdata) {
        /*
         * Process client-side list participations for this room
         */
-       instr_len = SIZ;
        if (sc->participates != NULL) {
                msg = CtdlFetchMessage(msgnum, 1);
                if (msg != NULL) {
index 080916282bd17ceb628cb8620150c485ce174394..c82a6c286a0a5175fe3a2f1a646f4ddf2873ff11 100644 (file)
@@ -485,7 +485,7 @@ int login_via_openid(StrBuf *claimed_id)
  */
 void extract_link(StrBuf *target_buf, const char *rel, long repllen, StrBuf *source_buf)
 {
-       int len, i;
+       int i;
        const char *ptr;
        const char *href_start = NULL;
        const char *href_end = NULL;
@@ -508,8 +508,6 @@ void extract_link(StrBuf *target_buf, const char *rel, long repllen, StrBuf *sou
                if (link_tag_end == NULL)
                        break;
                for (i=0; i < 1; i++ ){
-                       len = link_tag_end - link_tag_start;
-
                        rel_start = cbmstrcasestr(link_tag_start, "rel=");
                        if ((rel_start == NULL) ||
                            (rel_start > link_tag_end)) 
@@ -744,7 +742,7 @@ void cmd_oidf(char *argbuf) {
                if (len < 0)
                        len = sizeof(thiskey) - 1;
                extract_token(thisdata, buf, 1, '|', sizeof thisdata);
-               syslog(LOG_DEBUG, "%s: [%d] %s\n", thiskey, strlen(thisdata), thisdata);
+               syslog(LOG_DEBUG, "%s: ["SIZE_T_FMT"] %s\n", thiskey, strlen(thisdata), thisdata);
                Put(keys, thiskey, len, strdup(thisdata), NULL);
        }
 
index 9e1366bc910d0f09de3574459efb0df72ee4c571..b28ca2ef39a3ad434c582bf52aba193d1d4c2bc7 100644 (file)
@@ -181,10 +181,8 @@ void smtp_msa_greeting(void) {
  * LMTP is like SMTP but with some extra bonus footage added.
  */
 void lmtp_greeting(void) {
-       citsmtp *sSMTP;
 
        smtp_greeting(0);
-       sSMTP = SMTP;
        SMTP->is_lmtp = 1;
 }
 
index cc0ad99fb3fedea418562ac58621765d2fe22285..8efae6578f5748da50c9d6fe8e4e1b45fe05c17b 100644 (file)
@@ -1315,7 +1315,6 @@ void strip_addresses_already_have(long msgnum, void *userdata) {
  */
 void store_this_ha(struct addresses_to_be_filed *aptr) {
        struct CtdlMessage *vmsg = NULL;
-       long vmsgnum = (-1L);
        char *ser = NULL;
        struct vCard *v = NULL;
        char recipient[256];
@@ -1352,7 +1351,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) {
                        vcard_free(v);
 
                        syslog(LOG_DEBUG, "Adding contact: %s\n", recipient);
-                       vmsgnum = CtdlSubmitMsg(vmsg, NULL, aptr->roomname, QP_EADDR);
+                       CtdlSubmitMsg(vmsg, NULL, aptr->roomname, QP_EADDR);
                        CtdlFreeMessage(vmsg);
                }
        }
@@ -1459,6 +1458,9 @@ CTDL_MODULE_INIT(vcard)
                        fp = fopen(filename, "a");
                        if (fp != NULL) fclose(fp);
                        rv = chown(filename, CTDLUID, (-1));
+                       if (rv == -1)
+                               syslog(LOG_EMERG, "Failed to adjust ownership of: %s [%s]\n", 
+                                      filename, strerror(errno));
                }
 
                /* for postfix tcpdict */
index f2b54c892d4c95402ad8dfa143a54b874babaffc..f18bb4a4a30c84ad45b8b52085960b59105d3813 100644 (file)
@@ -193,7 +193,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                fclose(fp);
        }
 
-       syslog(LOG_DEBUG, "diff length is %d bytes", diffbuf_len);
+       syslog(LOG_DEBUG, "diff length is "SIZE_T_FMT" bytes", diffbuf_len);
 
        unlink(diff_old_filename);
        unlink(diff_new_filename);
index 0deb0199a6f880ff542074619e58f2c331285759..5265fc1886d526f4887584d0aa30b0f61afaff8e 100644 (file)
@@ -94,7 +94,6 @@ void xmpp_output_incoming_messages(void) {
  */
 void xmpp_send_message(char *message_to, char *message_body) {
        char *recp = NULL;
-       int message_sent = 0;
        struct CitContext *cptr;
 
        if (message_body == NULL) return;
@@ -112,7 +111,7 @@ void xmpp_send_message(char *message_to, char *message_body) {
        }
 
        if (recp) {
-               message_sent = PerformXmsgHooks(CC->user.fullname, CC->cs_inet_email, recp, message_body);
+               PerformXmsgHooks(CC->user.fullname, CC->cs_inet_email, recp, message_body);
        }
 
        free(XMPP->message_body);
index a02f7cd242beb94422e36f3019ec9f452c98f8c9..7eb321905315c9b2313e81cf0639729cb8891ebe 100644 (file)
@@ -1106,6 +1106,10 @@ void mime_download(char *name, char *filename, char *partnum, char *disp,
                        return;
        
                rv = fwrite(content, length, 1, CC->download_fp);
+               if (rv == -1) {
+                       syslog(LOG_EMERG, "mime_download(): Couldn't write: %s\n",
+                              strerror(errno));
+               }
                fflush(CC->download_fp);
                rewind(CC->download_fp);
        
@@ -2068,7 +2072,6 @@ void Dump_RFC822HeadersBody(
        int outlen = 0;
        int nllen = strlen(nl);
        char *mptr;
-       int rc;
 
        mptr = TheMessage->cm_fields['M'];
 
@@ -2128,7 +2131,7 @@ void Dump_RFC822HeadersBody(
                }
        }
        if (outlen > 0) {
-               rc = client_write(outbuf, outlen);
+               client_write(outbuf, outlen);
                outlen = 0;
        }
 }
@@ -2934,7 +2937,6 @@ void serialize_message(struct ser_ret *ret,               /* return values */
 void dump_message(struct CtdlMessage *msg,     /* unserialized msg */
                  long Siz)                     /* how many chars ? */
 {
-       size_t wlen;
        int i;
        static char *forder = FORDER;
        char *buf;
@@ -2949,8 +2951,6 @@ void dump_message(struct CtdlMessage *msg,        /* unserialized msg */
 
        buf = (char*) malloc (Siz + 1);
 
-       wlen = 3;
-       
        for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) {
                        snprintf (buf, Siz, " msg[%c] = %s ...\n", (char) forder[i], 
                                   msg->cm_fields[(int)forder[i]]);
@@ -3308,6 +3308,10 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,      /* message to save */
                        network_fp = fopen(submit_filename, "wb+");
                        if (network_fp != NULL) {
                                rv = fwrite(smr.ser, smr.len, 1, network_fp);
+                               if (rv == -1) {
+                                       syslog(LOG_EMERG, "CtdlSubmitMsg(): Couldn't write network spool file: %s\n",
+                                              strerror(errno));
+                               }
                                fclose(network_fp);
                        }
                        free(smr.ser);
@@ -4968,6 +4972,11 @@ void AdjRefCount(long msgnum, int incr)
        new_arcq.arcq_msgnum = msgnum;
        new_arcq.arcq_delta = incr;
        rv = fwrite(&new_arcq, sizeof(struct arcq), 1, arcfp);
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Couldn't write Refcount Queue File %s: %s\n",
+                      file_arcq,
+                      strerror(errno));
+       }
        fflush(arcfp);
 
        return;
index d7f88ad4dc79e1fa94d39d00a69044925db64bd2..17aa4e7710254adb8581558623971ec992be3f99 100644 (file)
@@ -856,8 +856,23 @@ static int validpw(uid_t uid, const char *pass)
 
        begin_critical_section(S_CHKPWD);
        rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+               end_critical_section(S_CHKPWD);
+               return 0;
+       }
        rv = write(chkpwd_write_pipe[1], pass, 256);
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+               end_critical_section(S_CHKPWD);
+               return 0;
+       }
        rv = read(chkpwd_read_pipe[0], buf, 4);
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+               end_critical_section(S_CHKPWD);
+               return 0;
+       }
        end_critical_section(S_CHKPWD);
 
        if (!strncmp(buf, "PASS", 4)) {
@@ -1335,8 +1350,6 @@ void CtdlSetPassword(char *new_pw)
  */
 void cmd_setp(char *new_pw)
 {
-       int generate_random_password = 0;
-
        if (CtdlAccessCheck(ac_logged_in)) {
                return;
        }
@@ -1352,7 +1365,6 @@ void cmd_setp(char *new_pw)
 
        if (!strcasecmp(new_pw, "GENERATE_RANDOM_PASSWORD")) {
                char random_password[17];
-               generate_random_password = 1;
                snprintf(random_password, sizeof random_password, "%08lx%08lx", random(), random());
                CtdlSetPassword(random_password);
                cprintf("%d %s\n", CIT_OK, random_password);
@@ -1390,6 +1402,15 @@ void cmd_creu(char *cmdbuf)
        //password[31] = 0;
        strproc(username);
        strproc(password);
+       len = strlen(username);
+       if (len >= USERNAME_SIZE)
+       {
+               syslog(LOG_EMERG, "Username to long: %s", username);
+               cit_backtrace ();
+               len = USERNAME_SIZE - 1; 
+               username[63]='\0';
+       }
+
        len = cutuserkey(username);
 
        if (IsEmptyStr(username)) {
index b057947c6d0a72828e991e465877341b304ed0ed..7bd7c6b7f2cc21d7db7048ff0cc12154c0caafc6 100644 (file)
@@ -70,7 +70,7 @@ static INLINE long cutuserkey(char *username) {
                syslog(LOG_EMERG, "Username to long: %s", username);
                cit_backtrace ();
                len = USERNAME_SIZE - 1; 
-               ((char*)username)[USERNAME_SIZE - 1]='\0';
+               username[63]='\0';
        }
        return len;
 }
index f4cc31071b972889c844dab1af6b9c8d75ed3d4f..8037b6d128aa6bae2c74e47db7d09f828fd5a396 100644 (file)
@@ -390,24 +390,39 @@ int create_dir(char *which, long ACCESS, long UID, long GID)
 {
        int rv;
        rv = mkdir(which, ACCESS);
+       if ((rv == -1) && (errno == EEXIST))
+               return rv;
        rv = chmod(which, ACCESS);
+       if (rv == -1)
+               return rv;
        rv = chown(which, UID, GID);
        return rv;
 }
 
-void create_run_directories(long UID, long GID)
+int create_run_directories(long UID, long GID)
 {
        int rv;
 
        rv = create_dir(ctdl_info_dir    , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_bio_dir     , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_usrpic_dir  , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_hlp_dir     , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_image_dir   , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_bb_dir      , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_file_dir    , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_netcfg_dir  , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_key_dir     , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
-       rv = create_dir(ctdl_run_dir     , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID);
+       if (rv != -1)
+               rv = create_dir(ctdl_bio_dir     , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_usrpic_dir  , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_hlp_dir     , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_image_dir   , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_bb_dir      , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_file_dir    , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_netcfg_dir  , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_key_dir     , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+       if (rv != -1)
+               rv = create_dir(ctdl_run_dir     , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID);
+       return rv;
 }