Commit graph

24 commits

Author SHA1 Message Date
Lexi Winter 961bcbeef2 mailwrapper(8): change behaviour if mailer.conf cannot be opened
Previously, mailwrapper(8) would default to invoking _PATH_DEFAULTMTA
(i.e., dma) if mailer.conf couldn't be opened for any reason, including
transient errors like ENFILE.  This behaviour is undesirable, because if
the administrator has configured a different MTA in mailer.conf, they
almost certainly don't want mailwrapper to unpredictably fall back to
the compiled-in default; and in any case, the default MTA is probably
not running, meaning the mail may be queued and then never delivered,
which is worse than not accepting it to begin with.

Change this behaviour depending on why mailer.conf can't be opened:

- If it doesn't exist, keep the existing behaviour of falling back to
  the default MTA, on the assumption that this is a reasonable default
  if mailer.conf hasn't been configured at all.

- If it cannot be opened for any other reason, do not invoke an MTA and
  instead return an error to the caller.

PR: 25218
Reviewed by: imp, emaste, markj
Pull Request: https://github.com/freebsd/freebsd-src/pull/969
2024-04-19 16:20:44 -06:00
Warner Losh 4d65a7c695 usr.sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Stefan Eßer 56d11d4a37 Make use of the getlocalbase() function for run-time adjustment of the
local software base directory, as committed in SVN rev. 367813.

The pkg and mailwrapper programs used the LOCALBASE environment variable
for this purpose and this functionality is preserved by getlocalbase().

After this change, the value of the user.localbase sysctl variable is used
if present (and not overridden in the environment).

The nvmecontrol program gains support of a dynamic path to its plugin
directory with this update.

Differential Revision:	https://reviews.freebsd.org/D27237
2020-11-18 20:00:55 +00:00
Scott Long 8e1031086d Revert the whole getlocalbase() set of changes while a different design is
hashed out.
2020-11-15 20:24:59 +00:00
Scott Long 1b249101df Fix the previous revision, it suffered from an incomplete change to the
getlocalbase API.  Also don't erroneously subtract the lenth from the
buffer a second time.
2020-11-15 07:50:29 +00:00
Scott Long 7ca0d5403e Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3
Reviewed by:	imp, se
2020-11-14 18:01:14 +00:00
Stefan Eßer 1f474190fc Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE
Literal references to /usr/local exist in a large number of files in
the FreeBSD base system. Many are in contributed software, in configuration
files, or in the documentation, but 19 uses have been identified in C
source files or headers outside the contrib and sys/contrib directories.

This commit makes it possible to set _PATH_LOCALBASE in paths.h to use
a different prefix for locally installed software.

In order to avoid changes to openssh source files, LOCALBASE is passed to
the build via Makefiles under src/secure. While _PATH_LOCALBASE could have
been used here, there is precedent in the construction of the path used to
a xauth program which depends on the LOCALBASE value passed on the compiler
command line to select a non-default directory.

This could be changed in a later commit to make the openssh build
consistently use _PATH_LOCALBASE. It is considered out-of-scope for this
commit.

Reviewed by:	imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D26942
2020-10-27 11:29:11 +00:00
Baptiste Daroussin 8b081eaa55 Revert r326844
There has been some fallout from the change. The change itself was not valueable
enough to spend time investigating the corner cases, let's just back it out.

Reported by:	flo
2018-01-02 16:50:57 +00:00
Baptiste Daroussin b37b09244c Replace usage of fparselen(3) by a getline(3)
This allow to remove the dependency on libutil
2017-12-14 08:57:37 +00:00
Pedro F. Giffuni 1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Baptiste Daroussin 24ed0a5759 Allow mailwrapper to use mailer.conf from localbase (respecting LOCALBASE env var if set)
Phabric:	https://reviews.freebsd.org/D412
Reviewed by:	bdrewery
MFC after:	2 weeks
Relnotes:	yes
2014-08-26 22:20:02 +00:00
Xin LI ded7840825 Sync with OpenBSD:
- avoid coredump when there's only one token on a line;
 - Use calloc();
 - Remove a line inherited from example mdoc.

Obtained from:	OpenBSD
MFC after:	1 month
2010-03-30 21:54:25 +00:00
Xin LI 49fe7301af Update NetBSD and OpenBSD SCM tags to match the reality. Note that
NetBSD revisions 1.8 and 1.9 are not actually applied to our code base
because we have solved the problem differently, therefore, these changes
can be safely skipped.
2006-08-07 10:29:18 +00:00
Xin LI 8fe1b8c03e Cleanups for mailwrapper(8):
- K&R -> ANSI prototype [O]
 - Do not bother to do free right before exit() or execve() [O]
 - Remove some dead code in addarg()
 - Make additional parameters specified in mailer.conf(5)
   actually work and document the fact. [N]
 - Avoid using __progname but instead use getprogname()
   and setprogname() to provide more sensible messages. [O, N]
 - Update $OpenBSD$ and $NetBSD$ to reflect the fact that we
   have sync'ed with their code.
 - WARNS=6

Obtained from/Inspired by:	OpenBSD [O], NetBSD [N] (partially)
2006-06-06 05:01:12 +00:00
Philippe Charnier 54ede02d10 add FBSDID 2003-07-06 12:44:11 +00:00
Alfred Perlstein d89167b4ea de-__P() 2002-07-11 18:31:16 +00:00
Dima Dorfman 8c37834db2 Don't free memory that was never allocated. This fixes a core dump in
the case where both the config file and the default MTA don't exist.

PR:		29521
Submitted by:	marius@alchemy.franken.de
2001-08-09 06:20:18 +00:00
Paul Richards 57b6c4a55a You can't free a string and then use it as the error message to
errx. Instead use warn to print the string, then cleanup and exit
normally.

This fixes a core dump if the executable to be run doesn't exist.
2001-06-04 04:22:57 +00:00
Philippe Charnier 39e80db3db Do not add progname in err() strings, it will be printed twice 2000-05-28 15:02:26 +00:00
Warner Losh ff4d7851f0 Merge from OpenBSD:
o Realloc memory leak fixed which won't matter but would trigger purify
o Default to sendmail when no mailer.conf exists.

Fixed bugs in OpenBSD version:
o Add NULL termination in the right place.

Also put back the err.  free shouldn't touch errno.

Pointed out by: theo de raadt (except the NULL bug :-)
2000-01-10 03:20:13 +00:00
Warner Losh 59536d2892 Fix mysterious sendmail coredump on systems where malloc.conf pointed to
a string containign 'J'.

o Properly terminate argv list with a NULL entry.
o Use warn() to report the exec failure because free could change errno and
  err would report the wrong reason.
o Don't terminate string to err with ':' since this results in two colons.
2000-01-10 01:25:53 +00:00
Peter Wemm 521cb9d2af Make mailwrapper build 1999-12-29 17:51:22 +00:00
Peter Wemm 3ae9291301 Import NetBSD's mailwrapper to redirect /usr/sbin/sendmail to the user's
chosen mailer.

Obtained from: NetBSD
1999-12-19 13:50:37 +00:00