/* We aren't using a pre-computed rate, so get a previously recorded rate
from the database, which will be updated and written back if required. */
-if (!(dbm = dbfn_open(US"ratelimit", O_RDWR, &dbblock, TRUE, TRUE)))
+if (!(dbm = dbfn_open(US"ratelimit", O_RDWR|O_CREAT, &dbblock, TRUE, TRUE)))
{
store_pool = old_pool;
sender_rate = NULL;
else
goto badopt;
-if (!(dbm = dbfn_open(US"seen", O_RDWR, &dbblock, TRUE, TRUE)))
+if (!(dbm = dbfn_open(US"seen", O_RDWR|O_CREAT, &dbblock, TRUE, TRUE)))
{
HDEBUG(D_acl) debug_printf_indent("database for 'seen' not available\n");
*log_msgptr = US"database for 'seen' not available";
Arguments:
name The single-component name of one of Exim's database files.
flags Either O_RDONLY or O_RDWR, indicating the type of open required;
- O_RDWR implies "create if necessary"
+ optionally O_CREAT
dbblock Points to an open_db block to be filled in.
lof If TRUE, write to the log for actual open failures (locking failures
are always logged).
exists, there is no error. */
dlen = snprintf(CS dirname, sizeof(dirname), "%s/db", spool_directory);
-flen = Ustrlen(name);
-snprintf(CS filename, sizeof(filename), "%.*s/%.*s.lockfile",
- (int)sizeof(filename) - dlen - flen - 11, dirname,
- flen, name);
dbblock->lockfd = -1;
if (!exim_lockfile_needed())
db_dir_make(panic);
else
{
+ flen = Ustrlen(name);
+ snprintf(CS filename, sizeof(filename), "%.*s/%.*s.lockfile",
+ (int)sizeof(filename) - dlen - flen - 11, dirname,
+ flen, name);
if (!lockfile_take(dbblock, filename, flags == O_RDONLY, panic))
{
DEBUG(D_hints_lookup) acl_level--;
it easy to pin this down, there are now debug statements on either side of the
open call. */
-flags &= O_RDONLY | O_RDWR;
snprintf(CS filename, sizeof(filename), "%.*s/%s", dlen, dirname, name);
priv_drop_temp(exim_uid, exim_gid);
-dbblock->dbptr = exim_dbopen(filename, dirname, flags, EXIMDB_MODE);
-if (!dbblock->dbptr && errno == ENOENT && flags == O_RDWR)
+dbblock->dbptr = exim_dbopen(filename, dirname, flags & O_ACCMODE, EXIMDB_MODE);
+if (!dbblock->dbptr && errno == ENOENT && flags & O_CREAT)
{
DEBUG(D_hints_lookup)
debug_printf_indent("%s appears not to exist: trying to create\n", filename);
- dbblock->dbptr = exim_dbopen(filename, dirname, flags|O_CREAT, EXIMDB_MODE);
+ dbblock->dbptr = exim_dbopen(filename, dirname, flags, EXIMDB_MODE);
}
save_errno = errno;
priv_restore();
}
DEBUG(D_hints_lookup)
- debug_printf_indent("opened hints database %s: flags=%s\n", filename,
- flags == O_RDONLY ? "O_RDONLY"
- : flags == O_RDWR ? "O_RDWR"
- : "??");
+ debug_printf_indent("opened hints database %s: flags=%s%s\n", filename,
+ (flags & O_ACCMODE) == O_RDONLY ? "O_RDONLY"
+ : (flags & O_ACCMODE) == O_RDWR ? "O_RDWR"
+ : "??",
+ flags & O_CREAT ? "|O_CREAT" : "");
/* Pass back the block containing the opened database handle and the open fd
for the lock. */
snprintf(CS filename, sizeof(filename), "%.*s/%s", dlen, dirname, name);
priv_drop_temp(exim_uid, exim_gid);
-dbblock->dbptr = exim_dbopen_multi(filename, dirname, flags, EXIMDB_MODE);
-if (!dbblock->dbptr && errno == ENOENT && flags == O_RDWR)
+dbblock->dbptr = exim_dbopen_multi(filename, dirname, flags & O_ACCMODE, EXIMDB_MODE);
+if (!dbblock->dbptr && errno == ENOENT && flags & O_CREAT)
{
DEBUG(D_hints_lookup)
debug_printf_indent("%s appears not to exist: trying to create\n", filename);
- dbblock->dbptr = exim_dbopen_multi(filename, dirname, O_RDWR|O_CREAT, EXIMDB_MODE);
+ dbblock->dbptr = exim_dbopen_multi(filename, dirname, flags, EXIMDB_MODE);
}
save_errno = errno;
priv_restore();
return NULL;
}
-DEBUG(D_hints_lookup) debug_printf_indent(
- "opened hints database %s for transactions: NOLOCK flags=O_RDWR\n", filename);
+DEBUG(D_hints_lookup)
+ debug_printf_indent("opened hints database %s for transactions: NOLOCK flags=%s%s\n",
+ filename,
+ (flags & O_ACCMODE) == O_RDONLY ? "O_RDONLY"
+ : (flags & O_ACCMODE) == O_RDWR ? "O_RDWR"
+ : "??",
+ flags & O_CREAT ? "|O_CREAT" : "");
/* Pass back the block containing the opened database handle */
}
start = clock();
- odb = dbfn_open(s, O_RDWR, dbblock + i, TRUE, TRUE);
+ odb = dbfn_open(s, O_RDWR|O_CREAT, dbblock + i, TRUE, TRUE);
stop = clock();
if (odb)
}
else if (!exim_lockfile_needed() && continue_transport)
{
- dbm_file = dbfn_open_multi(US"retry", O_RDONLY, &dbblock);
+ dbm_file = dbfn_open_multi(US"retry", O_RDWR, &dbblock);
continue_retry_db = dbm_file ? dbm_file : (open_db *)-1;
}
else
DEBUG(D_transport) debug_printf("check serialized: %s\n", key);
-/* Open and lock the waiting information database. The absence of O_CREAT is
-deliberate; the dbfn_open() function - which is an Exim function - always tries
-to create if it can't open a read/write file. It expects only O_RDWR or
-O_RDONLY as its argument. */
+/* Open and lock the waiting information database. */
-if (!(dbm_file = dbfn_open(US"misc", O_RDWR, &dbblock, TRUE, TRUE)))
+if (!(dbm_file = dbfn_open(US"misc", O_RDWR|O_CREAT, &dbblock, TRUE, TRUE)))
return FALSE;
/* See if there is a record for this host or queue run; if there is, we cannot
Arguments:
name The single-component name of one of Exim's database files.
- flags O_RDONLY or O_RDWR
+ flags O_RDONLY or O_RDWR, O_CREAT
dbblock Points to an open_db block to be filled in.
lof Unused.
panic Unused
if (asprintf(CSS &filename, "%s/%s", dirname, name) < 0) return NULL;
-if (flags & O_RDWR) flags |= O_CREAT;
-
if (!(dbblock->dbptr = exim_dbopen(filename, dirname, flags, 0)))
{
printf("** Failed to open hintsdb file %s for %s: %s%s\n", filename,
{
int verify = 1;
- if (!(dbm = dbfn_open(aname, O_RDWR, &dbblock, FALSE, TRUE)))
+ if (!(dbm = dbfn_open(aname, O_RDWR|O_CREAT, &dbblock, FALSE, TRUE)))
continue;
if (Ustrcmp(field, "d") == 0)
printf("Tidying Exim hints database %s/db/%s\n", argv[1], argv[2]);
spool_directory = argv[1];
-if (!(dbm = dbfn_open(argv[2], O_RDWR, &dbblock, FALSE, TRUE)))
+if (!(dbm = dbfn_open(argv[2], O_RDWR|O_CREAT, &dbblock, FALSE, TRUE)))
exit(EXIT_FAILURE);
/* Prepare for building file names */
reached their retry next try time. */
if (!dbm_file)
- dbm_file = dbfn_open(US"retry", O_RDWR, &dbblock, TRUE, TRUE);
+ dbm_file = dbfn_open(US"retry", O_RDWR|O_CREAT, &dbblock, TRUE, TRUE);
if (!dbm_file)
{
memcpy(dt->session, tkt.data, tkt.size);
gnutls_free(tkt.data);
- if ((dbm_file = dbfn_open(US"tls", O_RDWR, &dbblock, FALSE, FALSE)))
+ if ((dbm_file = dbfn_open(US"tls", O_RDWR|O_CREAT, &dbblock, FALSE, FALSE)))
{
/* key for the db is the IP */
dbfn_write(dbm_file, tlsp->resume_index, dt, dlen);
tlsp->resumption |= RESUME_CLIENT_REQUESTED;
DEBUG(D_tls)
debug_printf("checking for resumable session for %s\n", tlsp->resume_index);
- if ((dbm_file = dbfn_open(US"tls", O_RDWR, &dbblock, FALSE, FALSE)))
+ if ((dbm_file = dbfn_open(US"tls", O_RDWR|O_CREAT, &dbblock, FALSE, FALSE)))
{
if ((dt = dbfn_read_with_length(dbm_file, tlsp->resume_index, &len)))
{
dt->ocsp = tlsp->ocsp;
(void) i2d_SSL_SESSION(ss, &s); /* s gets bumped to end */
- if ((dbm_file = dbfn_open(US"tls", O_RDWR, &dbblock, FALSE, FALSE)))
+ if ((dbm_file = dbfn_open(US"tls", O_RDWR|O_CREAT, &dbblock, FALSE, FALSE)))
{
dbfn_write(dbm_file, tlsp->resume_index, dt, dlen);
dbfn_close(dbm_file);
if ( continue_wait_db
? !dbfn_transaction_start(dbp = continue_wait_db)
: !(dbp = dbfn_open(string_sprintf("wait-%.200s", tpname),
- O_RDWR, &dbblock, TRUE, TRUE))
+ O_RDWR|O_CREAT, &dbblock, TRUE, TRUE))
)
return;
sx->ehlo_resp.limit_rcptdom = sx->peer_limit_rcptdom;
# endif
-if ((dbm_file = dbfn_open(US"misc", O_RDWR, &dbblock, TRUE, TRUE)))
+if ((dbm_file = dbfn_open(US"misc", O_RDWR|O_CREAT, &dbblock, TRUE, TRUE)))
{
uschar * ehlo_resp_key = ehlo_cache_key(sx);
dbdata_ehlo_resp er = { .data = sx->ehlo_resp };
open_db dbblock, * dbm_file;
if ( sx->early_pipe_active
- && (dbm_file = dbfn_open(US"misc", O_RDWR, &dbblock, TRUE, TRUE)))
+ && (dbm_file = dbfn_open(US"misc", O_RDWR|O_CREAT, &dbblock, TRUE, TRUE)))
{
uschar * ehlo_resp_key = ehlo_cache_key(sx);
HDEBUG(D_transport)
{
DEBUG(D_transport) debug_printf("ehlo-resp record too old\n");
dbfn_close(dbm_file);
- if ((dbm_file = dbfn_open(US"misc", O_RDWR, &dbblock, TRUE, TRUE)))
+ if ((dbm_file = dbfn_open(US"misc", O_RDWR|O_CREAT, &dbblock, TRUE, TRUE)))
dbfn_delete(dbm_file, ehlo_resp_key);
}
else
{
HDEBUG(D_verify) debug_printf_indent("callout cache: disabled by no_cache\n");
}
-else if (!(dbm_file = dbfn_open(US"callout", O_RDWR, &dbblock, FALSE, TRUE)))
+else if (!(dbm_file = dbfn_open(US"callout", O_RDWR|O_CREAT, &dbblock, FALSE, TRUE)))
{
HDEBUG(D_verify) debug_printf_indent("callout cache: not available\n");
}
Otherwise the value is ccache_accept, ccache_reject, or ccache_reject_mfnull. */
if (dom_rec->result != ccache_unknown)
- if (!(dbm_file = dbfn_open(US"callout", O_RDWR, &dbblock, FALSE, TRUE)))
+ if (!(dbm_file = dbfn_open(US"callout", O_RDWR|O_CREAT, &dbblock, FALSE, TRUE)))
{
HDEBUG(D_verify) debug_printf_indent("callout cache: not available\n");
}
if (done && addr_rec->result != ccache_unknown)
{
if (!dbm_file)
- dbm_file = dbfn_open(US"callout", O_RDWR, &dbblock, FALSE, TRUE);
+ dbm_file = dbfn_open(US"callout", O_RDWR|O_CREAT, &dbblock, FALSE, TRUE);
if (!dbm_file)
{
HDEBUG(D_verify) debug_printf_indent("no callout cache available\n");
if (!pos_cache && !neg_cache)
return FALSE;
-if (!(dbm_file = dbfn_open(US"callout", O_RDWR, &dbblock, FALSE, TRUE)))
+if (!(dbm_file = dbfn_open(US"callout", O_RDWR|O_CREAT, &dbblock, FALSE, TRUE)))
{
HDEBUG(D_verify) debug_printf_indent("quota cache: not available\n");
return FALSE;
if (!pos_cache && !neg_cache)
return;
-if (!(dbm_file = dbfn_open(US"callout", O_RDWR, &dbblock, FALSE, TRUE)))
+if (!(dbm_file = dbfn_open(US"callout", O_RDWR|O_CREAT, &dbblock, FALSE, TRUE)))
{
HDEBUG(D_verify) debug_printf_indent("quota cache: not available\n");
return;
x@y
╎EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> flags=O_RDWR
╎returned from EXIM_DBOPEN: 0xAAAAAAAA
- ╎opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR
+ ╎opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR|O_CREAT
╎x@y in "*"?
╎ list element: *
╎ address match test: subject=x@y pattern=*
Attempting full verification using callout
EXIM_DBOPEN: file <TESTSUITE/spool/db/callout> dir <TESTSUITE/spool/db> flags=O_RDWR
returned from EXIM_DBOPEN: 0xAAAAAAAA
- opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR
+ opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT
dbfn_read: key=remote
dbfn_read: size nnn return
callout cache: found domain record for remote
cmdlog: '220:EHLO:250:MAIL:250:RCPT:550:QUIT:250'
EXIM_DBOPEN: file <TESTSUITE/spool/db/callout> dir <TESTSUITE/spool/db> flags=O_RDWR
returned from EXIM_DBOPEN: 0xAAAAAAAA
- opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR
+ opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT
dbfn_write: key=remote datalen nn
wrote callout cache domain record for remote:
result=1 postmaster=0 random=0
Attempting full verification using callout
EXIM_DBOPEN: file <TESTSUITE/spool/db/callout> dir <TESTSUITE/spool/db> flags=O_RDWR
returned from EXIM_DBOPEN: 0xAAAAAAAA
- opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR
+ opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT
dbfn_read: key=remote
dbfn_read: size nnn return
callout cache: found domain record for remote
Attempting full verification using callout
EXIM_DBOPEN: file <TESTSUITE/spool/db/callout> dir <TESTSUITE/spool/db> flags=O_RDWR
returned from EXIM_DBOPEN: 0xAAAAAAAA
- opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR
+ opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT
dbfn_read: key=y
dbfn_read: null return
callout cache: no domain record found for y
cmdlog: '220:EHLO:250:MAIL:250:RCPT:250:QUIT:220'
EXIM_DBOPEN: file <TESTSUITE/spool/db/callout> dir <TESTSUITE/spool/db> flags=O_RDWR
returned from EXIM_DBOPEN: 0xAAAAAAAA
- opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR
+ opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT
dbfn_write: key=y datalen nn
wrote callout cache domain record for y:
result=1 postmaster=0 random=0
Attempting full verification using callout
EXIM_DBOPEN: file <TESTSUITE/spool/db/callout> dir <TESTSUITE/spool/db> flags=O_RDWR
returned from EXIM_DBOPEN: 0xAAAAAAAA
- opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR
+ opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT
dbfn_read: key=y
dbfn_read: size nnn return
callout cache: found domain record for y
userx@test.ex
╎EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> flags=O_RDWR
╎returned from EXIM_DBOPEN: 0xAAAAAAAA
- ╎opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR
+ ╎opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR|O_CREAT
╎userx@test.ex in "*"?
╎ list element: *
╎ address match test: subject=userx@test.ex pattern=*
userx@test.ex
╎EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> flags=O_RDWR
╎returned from EXIM_DBOPEN: 0xAAAAAAAA
- ╎opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR
+ ╎opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR|O_CREAT
╎userx@test.ex in "*"?
╎ list element: *
╎ address match test: subject=userx@test.ex pattern=*