Commit graph

3047 commits

Author SHA1 Message Date
Cy Schubert
3b032c0698 ipfilter: Set ipf -T optionlist at boot
There is no easy way to set ipfilter optionlist variables during boot.
Add plumbing to the rc script to support this.

PR:			130555
Reviewed by:		jlduran
Differential Revision:	https://reviews.freebsd.org/D47346

(cherry picked from commit 8d6feaaaa26f444abb209360e52b993e39cb81bb)
2024-11-18 16:26:04 -08:00
Jose Luis Duran
f6d94e23d1
rc: Update ipfilter example rules location
It was originally /usr/src/contrib/ipfilter/rules and moved to
/usr/src/share/examples/ipfilter/rules in 41edb306f0.

Point to users to /usr/src/share/examples/ipfilter instead, as the base
directory also contains example rules.

Reviewed by:	emaste
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47392

(cherry picked from commit 8934526be1843ba033e1423f6ecd8b3b3f2a9c23)
2024-11-14 03:21:25 +00:00
Konstantin Belousov
dcdc0d7167 rtld.1: cross-reference rtld_get_var.3
(cherry picked from commit 16d000bdac54d7153f33a0d050bcc4307b702751)
2024-11-14 02:42:17 +02:00
Konstantin Belousov
86a2abab0a rtld: add rtld_{get,set}_var
(cherry picked from commit c56df6ce71ae96f00b088790d3ad2e0ebebdd59a)
2024-11-14 02:42:17 +02:00
Konstantin Belousov
db21e6980b rtld: make it easier to add sparce non-default members to ld_env_var_desc
(cherry picked from commit d7214577ff00221ac84a85e61794a5e126b952dd)
2024-11-14 02:42:17 +02:00
Konstantin Belousov
8ee3da8e73 rtld: 1-bit for bool is enough
(cherry picked from commit 450e684e0fea2785b5770241f51e897070c86726)
2024-11-14 02:42:17 +02:00
Mark Johnston
fc3c731bbf rc.d/kld: Print modules being loaded, take three
Some kernel modules will print informative messages when they are
loaded, making the output confusing.  Print everything up front instead.

Fixes:	152382e6613d ("rc.d/kld: Print the kernel modules being loaded")

(cherry picked from commit 3e55170e0fa2695f6d662e3ab67201138a6f8698)
2024-11-09 01:09:50 +00:00
Mark Johnston
2cb615d015 rc.d/kld: Avoid printing a trailing space
Fixes:		152382e6613d ("rc.d/kld: Print the kernel modules being loaded")
Reported by:	jrtc27

(cherry picked from commit cdb3cda6fd53b89c2bba0308d21aa8edf782dc34)
2024-11-09 01:09:47 +00:00
Mark Felder
bba8c461b9 rc.d/kld: Print the kernel modules being loaded
PR:		282269
MFC after:	2 weeks

(cherry picked from commit 152382e6613d7998fe6f5233767df54d3fdec329)
2024-11-09 01:09:29 +00:00
Baptiste Daroussin
6c682f5c38 nuageinit: add support for OpenStack network config
Add naive support for openstack network config.
if no config driver have been found, try to detect that we are running a
VM on openstack via the smbios information, use the first iface
available and temporary activate dhcp on it, to be able to fetch the
necessary informations for cloudinit.

While here make the rc script execute after devmatch, some ethernet
device might be attached via devmatch and may be needed for cloudinit.

Tested on OVHCloud Public Cloud.

MFC after:	3 weeks
Sponsored by:	OVHCloud

(cherry picked from commit 2775b9b0bcc278dd4183b57784953c26a3fcdc89)
2024-11-06 09:36:12 +01:00
Graham Percival
cdffbea57c manuals: Fix dates
These were reported by `mandoc -T lint ...` as warnings.

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Reviewed by:	mhorne
MFC after:	3 days
Sponsored by:	Tarsnap Backup Inc.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1475

(cherry picked from commit b74aaa1a2199261f9078247d29481a994b6b5e42)
2024-11-04 12:16:22 -04:00
Mateusz Piotrowski
4ff71ffaa7 rc.d/sendmail: Return non-zero if the daemon fails to start or is not running
If you have a mail server that is running sendmail daemon
(sendmail_enable=YES) and sendmail queue runner (sendmail_msp_queue=YES)
and the sendmail daemon dies, /etc/rc.d/sendmail status does see the
daemon is not running but returns 0 as the exit code.  This prevents
other programs (like puppet) from restarting sendmail to fix the issue.

Make sure that the exit code is propagated towards the end of the script
if any of the sendmail services fail.

This patch does not call exit directly but instead just sets the exit
status code by calling exit in a subshell. This way we do not exit the
current shell in case the service script is sourced (e.g., when
rc_fast_and_loose is active).

PR:		223132
MFC after:	2 weeks
Reported by:	pirzyk
Discussed with:	jilles, eugen
Reviewed by:	christos, gshapiro (previous version), markj
Approved by:	christos (mentor), markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D46862
Co-authored-by: Jim Pirzyk <pirzyk@FreeBSD.org>

(cherry picked from commit d2e7bb630b83848a774d8213014a9e0747775019)
2024-11-04 15:55:40 +01:00
Robert William Vesterman
6fb03ddbce libexec/rc/rc.d/netif: Typo fix
Just fixing a typo ("configuriing" => "configuring").

Pull Request:	https://github.com/freebsd/freebsd-src/pull/1484

(cherry picked from commit 65691b2dafda23691c3989749def755a98e731ec)
2024-10-30 17:49:57 -07:00
Mateusz Piotrowski
025535f945 rc/tests: Skip oomprotect tests in a jail
oomprotect cannot be used in a jail.

Reviewed by:	bnovkov, christos, markj
Approved by:	bnovkov (mentor), christos (mentor), markj (mentor)
MFC after:	1 week

(cherry picked from commit 6fa42b91ca3f481912af98c4d49c44507eb1b8e1)
2024-10-21 11:59:16 +02:00
Mateusz Piotrowski
f94127e3ee rc.d/sendmail: Fix stopping service during shutdown
The sendmail service script needs to be stopped during shutdown
to ensure a clean shutdown of active SMTP connections (and writing
any in memory queue files).

rcorder(8) requires the rcorder block to be an uninterrupted sequence of
REQUIRE, PROVIDE, BEFORE, and KEYWORD lines. Having a comment in between
REQUIRE and KEYWORD makes rcorder stop parsing the block when it reaches
the comment.

Fix that by moving the comment out from the rcorder block.

Reviewed by:	bnovkov, christos, gshapiro, markj
Approved by:	bnovkov (mentor), christos (mentor), markj (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D46924

(cherry picked from commit 8751fbe36ff02ed695f02132ee6eac723d2bbe3f)
2024-10-14 12:23:46 +02:00
Mark Johnston
cde4ab289d flua: Add wrappers for sys/utsname.h
This allows one to invoke uname from lua scripts.

Reviewed by:	bapt, kevans, emaste
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D42017

(cherry picked from commit 1726db7af6b3738eb04d962b351d7f4017e1fc77)
2024-10-10 20:28:20 +00:00
Jose Luis Duran
e573007af2 nuageinit: tests: Cleanup
- Export NUAGE_FAKE_ROOTDIR only once
- Use the header section of the test to require the root user
- Use the PWD environment variable
- Set the root/sys shell as /bin/sh
- Use RFC 5737 reserved IP addresses

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit e72457c4f5166eef2a27249e02f3c1e9a1cf852d)
2024-10-08 09:04:02 +02:00
Jose Luis Duran
9881d68b1e nuageinit: Fix passwords
The hashed password usually contains a "$" sign, which, when used on a
shell, must be escaped.  Also, the plain text password may contain
special characters that require escaping.

Add a quick fix by enclosing it in single quotes.  Note that if the
plain text password contains a "'", it will still fail.  This will be
properly fixed in later commits.

Some here documents require the document to be a string literal,
especially when passing invalid characters.  Enclose it in single
quotes.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit b9ce743c5447e90c2c97f4d49e048c301f708527)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
03abe3ac40 nuageinit: Standardize user-facing error messages
Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit 38bb6f79e39a14ea99f559f59129a4cadf92b569)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
182ff41e84 nuageinit: Standardize warning/error messages
Standardize the utilities from nuage.lua, to return nil on failure, plus
an error message as a second result, and some value different from nil
on success.

Make warnmsg() and errmsg() append "nuageinit: " by default.  Pass an
optional second parameter as false to avoid printing this tag.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit 945632ca76117029e7bd1f46d17ccb378973daf7)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
1eaf3331ea nuageinit: Replace os.execute with Lua libraries
Prefer posix.sys.stat's chmod() to os.execute().  While here, change the
name of the locals to be more descriptive.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit 9b2d92addc31ba6f5696c85d184a45d43e9073dc)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
c96dbfbd1b nuageinit: Silence an fstyp(8) warning
Silence a warning emitted by fread(3) in fstyp(8)'s read_buf(), when
detecting the file system type of the cloud-init device:

    % fstyp /dev/iso9660/cidata
    fstyp: fread: Invalid argument
    cd9660

Also rephrase slightly a comment while here.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit d71e2c037c942dbe2a9fd2630d5cf155dd1bf7db)
2024-10-08 09:04:01 +02:00
Jose Luis Duran
68c7c28d0e nuageinit: Lua check and lint files
Mostly white space, style, and luacheck compliance.

Signed-off-by: Jose Luis Duran <jlduran@gmail.com>
(cherry picked from commit 504981357aa36365784458cfe8d9e23097bfac7b)
2024-10-08 09:04:01 +02:00
Mateusz Piotrowski
e3b57f1485 rc.subr: Consistently use an absolute path for sysrc
MFC after:	2 weeks
Approved by:	christos

(cherry picked from commit 401516dbc54e4a4cba3085cd605fbf6cf8293b79)
2024-10-02 11:27:00 +02:00
Mateusz Piotrowski
2ab84513e9 rc.d/dnctl: Chmod +x for consistency with other rc scripts
MFC after:	1 week
Approved by:	bnovkov

(cherry picked from commit 91fac46bf7cff03c3471422c67281041c5fa0f1f)
2024-10-02 11:11:20 +02:00
Bjoern A. Zeeb
d60a0ffecf rc: network.subr update consitency with older change (v6/v4 order)
As of 1b5be7204e we setup parts of IPv6
before IPv4 if configured.  For consistency change a case in ifn_start()
calling ipv6_up() before ipv4_up() and reverse in ifn_stop().

Reviewed by:	zlei
Differential Revision: https://reviews.freebsd.org/D33426

(cherry picked from commit ed4d2a54fc7a0397c2042f496f176305ca03ebdd)
2024-09-28 10:35:11 +00:00
Jessica Clarke
11d7aa07eb rc.d/devmatch: Silence sysctl hw.bus.devctl_nomatch_enabled=1
As with various other rc scripts, we don't want the output from this
being visible in the boot log.

Fixes:		6437872c1d66 ("New sysctl to disable NOMATCH until devmatch runs")
MFC after:	1 week

(cherry picked from commit 62775aebf725a79703592f3276118245a74afdac)
2024-09-07 01:03:16 +01:00
Baptiste Daroussin
701ac3adcb nuageinit: improve debugging when mkdir fails
(cherry picked from commit a6ecbf2b35856e312d1e826b206142b9f930a760)
2024-09-03 09:05:25 +02:00
Baptiste Daroussin
3a73c77f2d nuageinit: readd ssh key parsing when key is in meta_data.json
in openstack when no user is specified but a sshkey is provided
the information is stored in meta_data.json under "public_keys"

PR:	280461
Reported by:	tdb

(cherry picked from commit 19fb9ad746517c7af9d79a982334b2550f285355)
2024-09-03 09:05:24 +02:00
Jose Luis Duran
5f7256579c nuageinit: Fix tests
Commit 07d17ca189fcf3cc44b7706040b05ca8135c3b85 set the recommended
permissions for the SSH authorized keys file and directory.  The tests,
however, were failing on CI.

Use stat to check for the proper permissions.

Fixes:	07d17ca189f nuageinit: Set recommended SSH permissions
Reported by:	Jenkins

(cherry picked from commit 8edd6c07c8dafcc5828bceb5fea0684c7d0d0775)
2024-09-03 09:05:24 +02:00
Jose Luis Duran
3dbc333a9e nuageinit: Fix the homedir variable name
cloud-init uses homedir, not home.

(cherry picked from commit 7aecd689e362330a035a199afbe5707a8c4edc9c)
2024-09-03 09:05:24 +02:00
Jose Luis Duran
6171791787 nuageinit: Set recommended SSH permissions
As stated in sshd(8), the recommended permissions for ~/.ssh are
read/write/execute for the user, and not accessible by others; and the
recommended permissions for ~/.ssh/authorized_keys are read/write for
the user, and not accessible by others.

(cherry picked from commit 07d17ca189fcf3cc44b7706040b05ca8135c3b85)
2024-09-03 09:05:24 +02:00
Jose Luis Duran
c7887c8e2e nuageinit: Accept plain text passwords
Per pw(8), when -H is set, the password should be supplied already
encrypted in a form suitable for writing directly to the password
database (passwd in cloud-init tems); -h provides a special interface by
which interactive scripts can set an account password using pw(8) in
plain text (plain_text_passwd in cloud-init terms).

The default user (freebsd) is defined with a plain_text_passwd
(freebsd), not with an encrypted one.

(cherry picked from commit 7b73ecfe648487c7706ac2b854dcf1435e60e4ca)
2024-09-03 09:05:24 +02:00
Baptiste Daroussin
28094582f0 nuageinit: check for both user_data and user-data
openstack, ec2 and other implementation of cloudinit disagrees on the
name of the file "user-data" or "user_data", test both and use the first
found

PR:	279876
(cherry picked from commit cde6642431bb0ca21aeebc7c521e99c681d31ffb)
2024-09-03 09:05:24 +02:00
John Baldwin
7b9327d6b2 defaults/rc.conf: Remove /usr/lib32 from ldconfig32_paths
Commit 99132daf6f70cb0cc969c555d3612547fa3cf1db prepends /usr/lib32 to
the list of paths in ldconfig32_paths since it is a standard library
path in ld-elf32.so.1.  Remove /usr/lib32 from the value in rc.conf so
that it is not listed twice.

Reviewed by:	olce, kib
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D44752

(cherry picked from commit 4bf5db113f760619bf754c22864b1d7e2acdeabd)
2024-08-27 14:15:55 -04:00
Konrad Witaszczyk
ee104259c7 rc.d/ldconfig: Compute ldconfig paths in a function
Move logic that computes paths passed to ldconfig(8) to a
ldconfig_paths() function that can be called for multiple ABIs.

Reviewed by:	olce, kib
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D44751

(cherry picked from commit e6e38bc522e29de6299536b547bf11dab11e9679)
2024-08-27 14:15:48 -04:00
Isaac Cilia Attard
54bd536723 dhclient: rc.conf option to disable ARP resolution
Introduce a new rc.conf option to not wait for ARP resolution within
dhclient. This is plausible on many modern networks where it is possible
to trust the DHCP server to know whether an IP address is available.

Sponsored by:	Google LLC (GSoC 2024)
Signed-off-by:	Isaac Cilia Attard <icattard@FreeBSD.org>
MFC after:	10 days
Reviwed by:	cperciva, brooks, Tom Hukins, Alexander Ziaee
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1368

(cherry picked from commit 503adcdf1db35eab0f3d35392947a6da3bd19539)
2024-08-19 21:57:09 -07:00
Ed Maste
f06d322e9d Remove "All Rights Reserved" from FreeBSD Foundation copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5c2bc3db201a4fe8d7911cf816bea104d5dc2138)
2024-08-06 15:39:53 -04:00
Konstantin Belousov
279e543dc7 rtld: add LD_NO_DL_ITERATE_PHDR_AFTER_FORK env var
PR:	280318

(cherry picked from commit 860c4d94ac46cee35a678cf3c9cdbd437dfed75e)
2024-08-05 03:32:11 +03:00
Konstantin Belousov
da32a0616b rtld: make ld_get_env_var() usable for all rtld source files
(cherry picked from commit 47315d6d3562111883142bb09320d35f05d34a58)
2024-08-05 03:32:11 +03:00
Konstantin Belousov
f0d4329dc2 rtld(1): Spell value as VALUE, not NAME
(cherry picked from commit bc25bc6850e512c4c45effdff6178d20b5eca558)
2024-08-05 03:32:11 +03:00
Cy Schubert
13f9c4addb rc.conf: Leap-seconds sources: Add IANA back
11da791920ba switched Leap-seconds source from IANA to IERS, as IERS
is the canonoical source. The problem ist that IERS is not accessible
from IPv6 only networks. To work around this we must add IANA back in
order to provide IPv6-only users a source for leap-seconds fetch.

PR:		279413
Fixes:		11da791920ba

(cherry picked from commit 66f360515d2829d261c0ad7bd516e9dd18c2dd83)
2024-07-21 19:36:30 -07:00
Andrew Turner
c2e0dea93f rtld: Add MD_OBJ_ENTRY to extend Struct_Obj_Entry
Add a macro the architectures can use to add per-arch fields to
Struct_Obj_Entry.

Reviewed by:	kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45116

(cherry picked from commit 06db20ffeca9898e5802d63f3b06caaa37c3a4ed)
2024-07-15 12:24:58 +00:00
Dag-Erling Smørgrav
77362b5eb7 tftpd: Code cleanup.
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45871

(cherry picked from commit c15290fb9d8fdf4b11b9c6e7406b67c73a98402d)
2024-07-09 23:40:26 +02:00
Baptiste Daroussin
30346359b3 nuageinit: fix authorized_key test
After miss reading the cloudinit spec I ended up writting a wrong
test for basic ssh key setup, nuageinit has been fixed, but not
the test, here is the actual fix.

Reported by:	markj

(cherry picked from commit 8d7331e62a5aa75760ac54e3cb1594b0001645c6)
2024-06-27 10:56:17 +02:00
Baptiste Daroussin
3cfc085f8a nuageinit: make addsshkey friendly for testsuite
(cherry picked from commit fa07b02f6e09f776b3afe5709e8fee1764c11a2a)
2024-06-27 10:55:07 +02:00
Baptiste Daroussin
12e584c11e nuageinit: use pw(8) instead of getent(1)
pw(8) allows to seek for users in a custom rootdir, which makes it
easier for a testsuite

MFC After:	3 days

(cherry picked from commit 83fcab792c9d7f13f7e8bd73cf1850ba74f49341)
2024-06-27 10:55:06 +02:00
Eugene Grosbein
a3a09bbf21 rc.subr: improve description for ${name}_offcmd
Clarify that ${name}_offcmd is for method start.

(cherry picked from commit af1b0aa5b957bbfedc929167aa3459ad2d8b6653)
2024-06-21 15:27:50 +07:00
Eugene Grosbein
efb1717d21 rc.subr(8): MFC: introduce ${name}_offcmd
New variable ${name}_offcmd may be used to supply commands
executed if named service is not enabled. Previously start_precmd
could be used for such a task but now rc.subr(8) does not call it
if a service is not enabled.

Fix devd startup script to use it instead of start_precmd.

PR:		279198
Reported by:	Dmitry S. Lukhtionov
Tested by:	Dmitry S. Lukhtionov

(cherry picked from commit 32a579e4fc69a65e8901111ad5f65ec56a97dfab)
(cherry picked from commit c2db3a0c7d31116028b38b426a9b139d26cbc7e5)
2024-06-17 11:57:53 +07:00
Emmanuel Vadot
ac658a7c76 rc: Set var_run_enable to enable by default
This will load/save the /var/run directories at boot/shutdown if
and only if /var/run/ is a tmpfs mount so it is a win for tmpfs
users and a no-op for everyone else.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D44097
Sponsored by:	Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 72b045386dd3db8b31ec3067cb9e160cbd1cfbc6)
2024-06-04 13:38:54 +02:00