Browse Source

make some maildir (error) messages more helpful

include the affected path.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
04e225c7ce
  1. 25
      src/drv_maildir.c

25
src/drv_maildir.c

@ -607,20 +607,20 @@ maildir_validate( const char *box, int create, maildir_store_t *ctx )
bl = nfsnprintf( buf, sizeof(buf) - 4, "%s/", box ); bl = nfsnprintf( buf, sizeof(buf) - 4, "%s/", box );
if (stat( buf, &st )) { if (stat( buf, &st )) {
if (errno != ENOENT) { if (errno != ENOENT) {
sys_error( "Maildir error: cannot access mailbox '%s'", box ); sys_error( "Maildir error: cannot access mailbox '%s'", buf );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
if (!create) if (!create)
return DRV_BOX_BAD; return DRV_BOX_BAD;
if (make_box_dir( buf, bl )) { if (make_box_dir( buf, bl )) {
sys_error( "Maildir error: cannot create mailbox '%s'", box ); sys_error( "Maildir error: cannot create mailbox '%s'", buf );
ctx->conf->failed = FAIL_FINAL; ctx->conf->failed = FAIL_FINAL;
maildir_invoke_bad_callback( ctx ); maildir_invoke_bad_callback( ctx );
return DRV_CANCELED; return DRV_CANCELED;
} }
} else if (!S_ISDIR(st.st_mode)) { } else if (!S_ISDIR(st.st_mode)) {
notdir: notdir:
error( "Maildir error: '%s' is no valid mailbox\n", box ); error( "Maildir error: '%s' is no valid mailbox\n", buf );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@ -691,7 +691,7 @@ maildir_store_uidval( maildir_store_t *ctx )
n = sprintf( buf, "%u\n%u\n", ctx->uidvalidity, ctx->nuid ); n = sprintf( buf, "%u\n%u\n", ctx->uidvalidity, ctx->nuid );
lseek( ctx->uvfd, 0, SEEK_SET ); lseek( ctx->uvfd, 0, SEEK_SET );
if (write( ctx->uvfd, buf, (uint)n ) != n || ftruncate( ctx->uvfd, n ) || (UseFSync && fdatasync( ctx->uvfd ))) { if (write( ctx->uvfd, buf, (uint)n ) != n || ftruncate( ctx->uvfd, n ) || (UseFSync && fdatasync( ctx->uvfd ))) {
error( "Maildir error: cannot write UIDVALIDITY.\n" ); error( "Maildir error: cannot write UIDVALIDITY in %s\n", ctx->path );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
} }
@ -717,7 +717,7 @@ maildir_init_uidval( maildir_store_t *ctx )
static int static int
maildir_init_uidval_new( maildir_store_t *ctx ) maildir_init_uidval_new( maildir_store_t *ctx )
{ {
notice( "Maildir notice: no UIDVALIDITY, creating new.\n" ); notice( "Maildir notice: no UIDVALIDITY in %s, creating new.\n", ctx->path );
return maildir_init_uidval( ctx ); return maildir_init_uidval( ctx );
} }
@ -742,14 +742,14 @@ maildir_uidval_lock( maildir_store_t *ctx )
#endif #endif
lck.l_type = F_WRLCK; lck.l_type = F_WRLCK;
if (fcntl( ctx->uvfd, F_SETLKW, &lck )) { if (fcntl( ctx->uvfd, F_SETLKW, &lck )) {
error( "Maildir error: cannot fcntl lock UIDVALIDITY.\n" ); error( "Maildir error: cannot fcntl lock UIDVALIDITY in %s.\n", ctx->path );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
#ifdef USE_DB #ifdef USE_DB
if (ctx->usedb) { if (ctx->usedb) {
if (fstat( ctx->uvfd, &st )) { if (fstat( ctx->uvfd, &st )) {
sys_error( "Maildir error: cannot fstat UID database" ); sys_error( "Maildir error: cannot fstat UID database in %s", ctx->path );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
if (db_create( &ctx->db, NULL, 0 )) { if (db_create( &ctx->db, NULL, 0 )) {
@ -783,7 +783,7 @@ maildir_uidval_lock( maildir_store_t *ctx )
* But this would mess up the sync state completely. So better bail out and * But this would mess up the sync state completely. So better bail out and
* give the user a chance to fix the mailbox. */ * give the user a chance to fix the mailbox. */
if (n) { if (n) {
error( "Maildir error: cannot read UIDVALIDITY.\n" ); error( "Maildir error: cannot read UIDVALIDITY in %s.\n", ctx->path );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
#endif #endif
@ -1081,11 +1081,11 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
if (uid == entry->uid) { if (uid == entry->uid) {
#if 1 #if 1
/* See comment in maildir_uidval_lock() why this is fatal. */ /* See comment in maildir_uidval_lock() why this is fatal. */
error( "Maildir error: duplicate UID %u.\n", uid ); error( "Maildir error: duplicate UID %u in %s.\n", uid, ctx->path );
maildir_free_scan( msglist ); maildir_free_scan( msglist );
return DRV_BOX_BAD; return DRV_BOX_BAD;
#else #else
notice( "Maildir notice: duplicate UID; changing UIDVALIDITY.\n"); notice( "Maildir notice: duplicate UID in %s; changing UIDVALIDITY.\n", ctx->path );
if ((ret = maildir_init_uid( ctx )) != DRV_OK) { if ((ret = maildir_init_uid( ctx )) != DRV_OK) {
maildir_free_scan( msglist ); maildir_free_scan( msglist );
return ret; return ret;
@ -1098,7 +1098,8 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
if (uid > ctx->nuid) { if (uid > ctx->nuid) {
/* In principle, we could just warn and top up nuid. However, getting into this /* In principle, we could just warn and top up nuid. However, getting into this
* situation might indicate some serious trouble, so let's not make it worse. */ * situation might indicate some serious trouble, so let's not make it worse. */
error( "Maildir error: UID %u is beyond highest assigned UID %u.\n", uid, ctx->nuid ); error( "Maildir error: UID %u is beyond highest assigned UID %u in %s.\n",
uid, ctx->nuid, ctx->path );
maildir_free_scan( msglist ); maildir_free_scan( msglist );
return DRV_BOX_BAD; return DRV_BOX_BAD;
} }
@ -1180,7 +1181,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
break; break;
if (want_tuid && starts_with( lnbuf, bufl, "X-TUID: ", 8 )) { if (want_tuid && starts_with( lnbuf, bufl, "X-TUID: ", 8 )) {
if (bufl < 8 + TUIDL) { if (bufl < 8 + TUIDL) {
error( "Maildir error: malformed X-TUID header (UID %u)\n", uid ); error( "Maildir error: malformed X-TUID header in %s\n", buf );
continue; continue;
} }
memcpy( entry->tuid, lnbuf + 8, TUIDL ); memcpy( entry->tuid, lnbuf + 8, TUIDL );

Loading…
Cancel
Save