Commit Diff


commit - 7bc4d7c9959e45c21425a193ef38eb0034b03f95
commit + 8b9e99284f76ecf38f14af3340a7914d6b49545b
blob - 9a118bcd3c4a6b53f842f85534e12c0ff29aa30d
blob + 9d16a5268ffd4e2b654cd9b21ca6cd590aff7025
--- Symbols.list
+++ Symbols.list
@@ -41,5 +41,7 @@ osmtpd_local_session
 osmtpd_local_message
 osmtpd_need
 osmtpd_run
+osmtpd_warn
+osmtpd_warnx
 osmtpd_err
 osmtpd_errx
blob - 4d551f0f161ea841d896117f7a9a8521263adc7e
blob + 436d24cb94104e562908df378c7f43458949cebe
--- opensmtpd.c
+++ opensmtpd.c
@@ -1014,6 +1014,32 @@ osmtpd_run(void)
 	io_free(io_stdin);
 	io_free(io_stdout);
 	event_base_free(evbase);
+}
+
+void
+osmtpd_warn(struct osmtpd_ctx *ctx, const char *fmt, ...)
+{
+	va_list ap;
+
+	if (ctx)
+		fprintf(stderr, "%016"PRIx64, ctx->reqid);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	fprintf(stderr, ": %s\n", strerror(errno));
+}
+
+void
+osmtpd_warnx(struct osmtpd_ctx *ctx, const char *fmt, ...)
+{
+	va_list ap;
+
+	if (ctx)
+		fprintf(stderr, "%016"PRIx64, ctx->reqid);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	fprintf(stderr, "\n");
 }
 
 __dead void
blob - dc06d018816c18df0c231914fd9c582c9db0c7cd
blob + 41f4aa485141d8a8e041197ba07b27bf8dfcb9a6
--- opensmtpd.h
+++ opensmtpd.h
@@ -189,5 +189,7 @@ void osmtpd_filter_rewrite(struct osmtpd_ctx *, const 
 void osmtpd_filter_dataline(struct osmtpd_ctx *, const char *, ...)
 	__attribute__((__format__ (printf, 2, 3)));
 void osmtpd_run(void);
+void osmtpd_warn(struct osmtpd_ctx *, const char *fmt, ...);
+void osmtpd_warnx(struct osmtpd_ctx *, const char *fmt, ...);
 __dead void osmtpd_err(int eval, const char *fmt, ...);
 __dead void osmtpd_errx(int eval, const char *fmt, ...);
blob - 5e9e8ca23ddbceca7c1a2c5a9600bd3475c324c6
blob + 75877a9b789949faab1755d45524211d65d0d491
--- osmtpd_run.3
+++ osmtpd_run.3
@@ -58,6 +58,8 @@
 .Nm osmtpd_filter_rewrite ,
 .Nm osmtpd_filter_dataline ,
 .Nm osmtpd_run ,
+.Nm osmtpd_warn ,
+.Nm osmtpd_warnx ,
 .Nm osmtpd_err ,
 .Nm osmtpd_errx
 .Nd C filter API for
@@ -228,6 +230,10 @@
 .Fn osmtpd_filter_dataline "struct osmtpd_ctx *ctx" "const char *line" ...
 .Ft void
 .Fn osmtpd_run void
+.Ft void
+.Fn osmtpd_warn "struct osmtpd_ctx *ctx" "const char *fmt" ...
+.Ft void
+.Fn osmtpd_warnx "struct osmtpd_ctx *ctx" "const char *fmt" ...
 .Ft void
 .Fn osmtpd_err "int eval" "const char *fmt" ...
 .Ft void
@@ -508,14 +514,28 @@ functions' callbacks without argument can't use
 callback can only use osmtpd_filter_dataline.
 .El
 .Pp
+.Nm osmtpd_warn ,
+.Nm osmtpd_warnx ,
 .Nm osmtpd_err
 and
 .Nm osmtpd_errx
 can be used as a standin for
+.Xr warn 3
+,
+.Xr warnx 3
+,
 .Xr err 3
 and
 .Xr errx 3
 without printing the program name to stderr.
+Additionally,
+.Nm osmtpd_warn
+and
+.Nm osmtpd_warnx
+prints the request ID on the logline when
+.Fa ctx
+is not
+.Dv NULL .
 .Sh SEE ALSO
 .Xr event_init 3 ,
 .Xr smtpd.conf 5