}
else
DEBUG(D_any)
- debug_printf("%s\n", string_open_failed(errno, "pid file %s",
- pid_file_path));
+ debug_printf("%s\n", string_open_failed("pid file %s", pid_file_path));
exim_exit(EXIT_SUCCESS);
}
}
else
DEBUG(D_any)
- debug_printf("%s\n", string_open_failed(errno, "pid file %s",
- pid_file_path));
+ debug_printf("%s\n", string_open_failed("pid file %s", pid_file_path));
}
/* Set up the handler for SIGHUP, which causes a restart of the daemon. */
if (dbblock->lockfd < 0)
{
log_write(0, LOG_MAIN, "%s",
- string_open_failed(errno, "database lock file %s", filename));
+ string_open_failed("database lock file %s", filename));
errno = 0; /* Indicates locking failure */
DEBUG(D_hints_lookup) acl_level--;
return NULL;
if (!dbblock->dbptr)
{
+ errno = save_errno;
if (lof && save_errno != ENOENT)
- log_write(0, LOG_MAIN, "%s", string_open_failed(save_errno, "DB file %s",
+ log_write(0, LOG_MAIN, "%s", string_open_failed("DB file %s",
filename));
else
DEBUG(D_hints_lookup)
- debug_printf_indent("%s\n", CS string_open_failed(save_errno, "DB file %s",
+ debug_printf_indent("%s\n", CS string_open_failed("DB file %s",
filename));
(void)close(dbblock->lockfd);
errno = save_errno;
{
if (devnull < 0) devnull = open("/dev/null", O_RDWR);
if (devnull < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s",
- string_open_failed(errno, "/dev/null", NULL));
+ string_open_failed("/dev/null", NULL));
if (devnull != i) (void)dup2(devnull, i);
}
}
if (!(f = Ufopen(sub_arg[0], "rb")))
{
- expand_string_message = string_open_failed(errno, "%s", sub_arg[0]);
+ expand_string_message = string_open_failed("%s", sub_arg[0]);
goto EXPAND_FAILED;
}
(long int)geteuid());
if (log_fd < 0)
{
- if (log_filename == NULL)
+ if (!log_filename)
{
*error_pointer = US"attempt to obey \"logwrite\" command "
"without a previous \"logfile\"";
log_fd = Uopen(log_filename, O_CREAT|O_APPEND|O_WRONLY, log_mode);
if (log_fd < 0)
{
- *error_pointer = string_open_failed(errno, "filter log file \"%s\"",
+ *error_pointer = string_open_failed("filter log file \"%s\"",
log_filename);
return FF_ERROR;
}
}
}
else
- {
- DEBUG(D_filter) debug_printf_indent("skipping logwrite (verifying or testing)\n");
- }
+ DEBUG(D_filter)
+ debug_printf_indent("skipping logwrite (verifying or testing)\n");
break;
/* Header addition and removal is available only in the system filter. The
extern gstring *string_vformat_trc(gstring *, const uschar *, unsigned,
unsigned, unsigned, const char *, va_list);
-#define string_open_failed(eno, fmt, ...) \
- string_open_failed_trc(eno, US __FUNCTION__, __LINE__, fmt, __VA_ARGS__)
-extern uschar *string_open_failed_trc(int, const uschar *, unsigned,
- const char *, ...) PRINTF_FUNCTION(4,5);
+#define string_open_failed(fmt, ...) \
+ string_open_failed_trc(US __FUNCTION__, __LINE__, fmt, __VA_ARGS__)
+extern uschar *string_open_failed_trc(const uschar *, unsigned,
+ const char *, ...) PRINTF_FUNCTION(3,4);
#define string_nextinlist(lp, sp, b, l) \
string_nextinlist_trc((lp), (sp), (b), (l), US __FUNCTION__, __LINE__)
if ((fileno = Uopen(filename, O_RDONLY, 0)) < 0)
{
- int save_errno = errno;
- *errmsg = string_open_failed(errno, "%s for cdb lookup", filename);
- errno = save_errno;
+ *errmsg = string_open_failed("%s for cdb lookup", filename);
return NULL;
}
if (fstat(fileno, &statbuf) != 0)
{
- int save_errno = errno;
- *errmsg = string_open_failed(errno,
- "fstat(%s) failed - cannot do cdb lookup",
+ *errmsg = string_open_failed("fstat(%s) failed - cannot do cdb lookup",
filename);
- errno = save_errno;
return NULL;
}
if (statbuf.st_size < CDB_HASH_TABLE)
{
- int save_errno = errno;
- *errmsg = string_open_failed(errno,
- "%s too short for cdb lookup",
- filename);
- errno = save_errno;
+ *errmsg = string_open_failed("%s too short for cdb lookup", filename);
return NULL;
}
/* read of hash table failed, oh dear, oh..... time to give up I think....
call the close routine (deallocs the memory), and return NULL */
- *errmsg = string_open_failed(errno,
- "cannot read header from %s for cdb lookup",
+ *errmsg = string_open_failed("cannot read header from %s for cdb lookup",
filename);
cdb_close(cdbp);
return NULL;
if ((s = Ustrrchr(dirname, '/'))) *s = '\0';
EXIM_DBOPEN(filename, dirname, O_RDONLY, 0, &yield);
if (!yield)
- {
- int save_errno = errno;
- *errmsg = string_open_failed(errno, "%s as a %s file", filename, EXIM_DBTYPE);
- errno = save_errno;
- }
+ *errmsg = string_open_failed("%s as a %s file", filename, EXIM_DBTYPE);
return yield;
}
DIR * dp = exim_opendir(dirname);
if (!dp)
{
- int save_errno = errno;
- *errmsg = string_open_failed(errno, "%s for directory search", dirname);
- errno = save_errno;
+ *errmsg = string_open_failed("%s for directory search", dirname);
return NULL;
}
closedir(dp);
json_set_alloc_funcs(json_malloc, json_free);
if (!(f = Ufopen(filename, "rb")))
- {
- int save_errno = errno;
- *errmsg = string_open_failed(errno, "%s for json search", filename);
- errno = save_errno;
- return NULL;
- }
+ *errmsg = string_open_failed("%s for json search", filename);
return f;
}
static void *
lsearch_open(const uschar * filename, uschar ** errmsg)
{
-FILE *f = Ufopen(filename, "rb");
-if (f == NULL)
- {
- int save_errno = errno;
- *errmsg = string_open_failed(errno, "%s for linear search", filename);
- errno = save_errno;
- return NULL;
- }
+FILE * f = Ufopen(filename, "rb");
+if (!f)
+ *errmsg = string_open_failed("%s for linear search", filename);
return f;
}
if (listname[0] == 0)
listname = string_sprintf("\"%s\"", *listptr);
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s",
- string_open_failed(errno, "%s when checking %s", sss, listname));
+ string_open_failed("%s when checking %s", sss, listname));
}
/* Trailing comments are introduced by #, but in an address list or local
if (!f)
{
- *error = string_open_failed(errno, "included file %s", filename);
+ *error = string_open_failed("included file %s", filename);
return FF_INCLUDEFAIL;
}
DEFAULT_ERROR:
default:
- *error = string_open_failed(errno, "%s", filename);
+ *error = string_open_failed("%s", filename);
*yield = FF_ERROR;
return NULL;
}
}
else
{
- if (filename == NULL)
+ if (!filename)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "non-existent configuration file(s): "
"%s", config_main_filelist);
else
- log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s", string_open_failed(errno,
- "configuration file %s", filename));
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s",
+ string_open_failed("configuration file %s", filename));
}
/* Now, once we found and opened our configuration file, we change the directory
temp_string = string_sprintf("scan/%s", message_id);
if (!directory_make(spool_directory, temp_string, 0750, FALSE))
{
- log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
- "scan directory %s/scan/%s", spool_directory, temp_string));
+ log_write(0, LOG_MAIN|LOG_PANIC, "%s",
+ string_open_failed("scan directory %s/scan/%s", spool_directory, temp_string));
goto OUT;
}
if (!(mbox_file = modefopen(mbox_path, "wb", SPOOL_MODE)))
{
- log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
- "scan file %s", mbox_path));
+ log_write(0, LOG_MAIN|LOG_PANIC, "%s",
+ string_open_failed("scan file %s", mbox_path));
goto OUT;
}
if ( !(yield = Ufopen(mbox_path,"rb"))
|| fstat(fileno(yield), &statbuf) != 0
)
- log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
- "scan file %s", mbox_path));
+ log_write(0, LOG_MAIN|LOG_PANIC, "%s",
+ string_open_failed( "scan file %s", mbox_path));
else
*mbox_file_size = statbuf.st_size;
"Permission denied", reads and includes the euid and egid.
Arguments:
- eno the value of errno after the failure
format a text format string - deliberately not uschar *
... arguments for the format string
*/
uschar *
-string_open_failed_trc(int eno, const uschar * func, unsigned line,
+string_open_failed_trc(const uschar * func, unsigned line,
const char *format, ...)
{
va_list ap;
va_start(ap, format);
(void) string_vformat_trc(g, func, line, STRING_SPRINTF_BUFFER_SIZE,
SVFMT_REBUFFER, format, ap);
-string_from_gstring(g);
-gstring_release_unused(g);
va_end(ap);
-return eno == EACCES
- ? string_sprintf("%s: %s (euid=%ld egid=%ld)", g->s, strerror(eno),
- (long int)geteuid(), (long int)getegid())
- : string_sprintf("%s: %s", g->s, strerror(eno));
+g = string_catn(g, US": ", 2);
+g = string_cat(g, US strerror(errno));
+
+if (errno == EACCES)
+ {
+ int save_errno = errno;
+ g = string_fmt_append(g, " (euid=%ld egid=%ld)",
+ (long int)geteuid(), (long int)getegid());
+ errno = save_errno;
+ }
+gstring_release_unused(g);
+return string_from_gstring(g);
}
-#endif /* COMPILE_UTILITY */
-#ifndef COMPILE_UTILITY
/* qsort(3), currently used to sort the environment variables
for -bP environment output, needs a function to compare two pointers to string
pointers. Here it is. */
debug_printf("D-H parameter cache file \"%s\" does not exist\n", filename);
}
else
- return tls_error(string_open_failed(errno, "\"%s\" for reading", filename),
+ return tls_error(string_open_failed("\"%s\" for reading", filename),
NULL, NULL, errstr);
/* If ret < 0, either the cache file does not exist, or the data it contains