route(4): Ensure RTA_NETMASK has a valid length and family
When adding a route to the radix tree only the data part of the
sockaddr is preserved. Trailing zeros are also removed which
results in zero length netmask for the default route.
So when we pull the route from the kernel via a route(4) message,
the netmask sockaddr has an invalid family and for the default
route, an invalid length as well.
You can see the effect of this by ensuring a default route is
present and then issuing the command `route -n flush`
which results in an error.
The simple fix is this: when we place the netmask in a route(4)
message and we have a destination address (ie it's a route)
then we can fix the family (it will be either 0x00 or 0xff) and
the length (it will be 0 for the default route).
nrelease: Migrate from cdrtools/mkisofs to makefs(8) for ISO creation
With the recently updated kernel cd9660 and userland makefs(8), we're
able to replace the mkisofs (from port sysutils/cdrtools) with the
in-base makefs(8) utility.
The new ISO has been tested for:
- both legacy BIOS and UEFI boot okay
- installation ok and the installed system worked
nrelease: Fix volume label to comply with cd9660 spec
The iso/cd9660 spec says the volume identifier/label can have a maximum
length of 32 characters, and must contain only A-Z, 0-9 and _, so we
have to fix the label portion of git version string to meet the
requirement.
Although the old label format is accepted by mkisofs, it will be
rejected by makefs(8). So this change helps we migrate to the latter.
cd9660: Recognize IEEE_1282 and IEEE_P1282 as RockRidge identifiers
This allows us to read the ISO images created by makefs(8) utility,
which uses "IEEE_P1282" as the RockRidge extension identifier.
Note that this doesn't mean we actually fully support those specs, which
include the multiple ER/ES entries, sparse files and the file serial
number field in PX entries.
Obtained-from: NetBSD
makefs(8): Fix several warnings and tweak Makefile
ffs.c: In function 'ffs_write_file':
ffs.c:944:9: warning: missing initializer for field 'v_type' of 'struct m_vnode' [-Wmissing-field-initializers]
struct m_vnode vp = { fsopts, NULL };
^~~~~~~
In file included from ffs/ffs_extern.h:38,
from ffs.c:106:
/usr/src/usr.sbin/makefs/ffs/buf.h:57:13: note: 'v_type' declared here
enum vtype v_type; /* DragonFly */
In file included from hammer2.h:41,
from hammer2.c:59:
hammer2/hammer2.h: In function 'hammer2_knote':
hammer2/hammer2.h:2098:51: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
KNOTE(&vp->v_pollinfo.vpi_kqinfo.ki_note, flags);
^
...
makefs(8): Sync cd9660 function with FreeBSD
The major changes are (in chronological order):
* makefs: connect cd9660 El Torito EFI boot image system type
* Fix -Wpointer-sign warnings in makefs and mkimg
* makefs: correct iso9660 Rock Ridge TF timestamps
The bit definitions for the TF_* timestamp bits (TF_MODIFY, etc.) were
incorrect, and timestamps were written in the wrong order.
See RRIP 4.1.6 Description of the "TF" System Use Entry for details.
PR: 203531
Reported by: Thomas Schmitt <scdbackup at gmx.net>
Reviewed by: jrtc27, kevans
Sponsored by: The FreeBSD Foundation
[158 lines not shown]
cd9660: Explicitly treat the timezone byte as a signed value
Otherwise, timezone information for time zones west of GMT gets
discarded.
Obtained-from: FreeBSD (PR kern/128934, commit 5c423e0640bcad0eb90d9c968658347228bc2818)
cd9660: Fix ISO_SUSP_CFLAG_ROOT handling in RockRidge
When encountering a ISO_SUSP_CFLAG_ROOT element in Rock Ridge processing,
this actually means there's a double slash recorded in the symbolic
link's path name. We used to start over from / then, which caused link
targets like "../../bsdi.1.0/include//pathnames.h" to be interpreted as
/pathnahes.h. This is both contradictionary to our conventional slash
interpretation, as well as potentially dangerous.
The right thing to do is (obviously) to just ignore that element.
Obtained-from: FreeBSD (commit f7d5a5328faa1cb0b6ad60860e8f46d748507c88)
cd9660 - Fix bp corruption and excess bp refs
* Fix improper bp reuse without deref / cleanup. In DFly, this improper
use case could also corrupt the previous buffer content with incorrect
data.
* Refactor code logic to make everytyhing more readable.
Taken-From: FreeBSD PR 272856 and fa3cf6cdc68cb6d6f2c440f2653258d68eae1015
Requested-by: aly
stand/boot: Fix rel_rootpath() to avoid duplicate "/boot" prefix
When the /boot is on the root filesystem instead of being a separate
filesystem (e.g., the ISO/IMG installation media), the loader was
setting DirBase to be "/boot/<kernelname>", which already had the
"/boot" prefix. And then rel_rootpath() would return
"/boot/boot/kernel/kernel" for the default kernel (i.e., name "kernel"
and boot file "kernel").
In that case, loadfile() would set "kernelname=/boot/boot/kernel/kernel"
and derive "exported_module_path=/boot/boot/kernel;/boot/modules.local".
Then boot() would move "exported_module_path" to "module_path", which
finally be the value of "kern.module_path" sysctl. As a result,
kldload(8) would fail to load a module without specifying its full path.
This patch fixes the above issue.
Suggested-by: swildner
mount_cd9660(8): Simplify the settings of file/dir mode masks
Meanwhile, update the man page to clarify the default values of uid, gid,
and file/dir modes. (obtained from FreeBSD)
See also: https://reviews.freebsd.org/D47357
route(8): Tweak the hex print format for unknown addresses
Change the old format like "(family) xx xx xx ..." to
"(family)xx.xx.xx..." so it looks better in the monitor output.
Referred to OpenBSD.
route(8): Fix routename() for AF_LINK addresses with sdl_index
The link_ntoa() function is able to handle such link addresses with zero
lengths but only 'sdl_index', so route(8) would print an empty string
for some RTA_GATEWAY and RTA_IFP sockaddrs in the monitor output.
Fix routename() to correctly print such addresses by copying the code
from netstat(1).
cd9660: Fix file/dir mode masks to support setuid/setgid/sticky bits
The old code only allowed max mode to be 777, which caused the special
permissions (i.e., setuid/setgid/sticky) were lost in the filesystem.
That would cause a system installed from ISO to malfunction.
Fix the file/dir mode masks to ALLPERMS by default.
The ISOFSMNT_MODEMASK option is kept for backward compatible with the
old mount_cd9660(8) utility. (It will also be updated.)
See also: https://reviews.freebsd.org/D47357
nrelease: Simplify the adjustments to loader.conf for IMG boot
Use 'sed' similar to fstab adjustments instead of grep+echo to adjust
'boot/loader.conf' to the IMG boot.
nrelease: Adjust fstab and reuse it for IMG boot
The root '/' filesystem is mounted by the kernel, so it can be omitted
from 'etc/fstab'. This also makes the 'fstab' file be used by the IMG
boot, so just reuse it.
nrelease: Adjust fstab to remove '-C' option for /tmp tmpfs mount
For the /tmp mount, no need to copy the origin contents; also, there
shouldn't be any contents at this early boot stage.
nrelease: Add root_rw_mount="NO" to rc.conf to fix ISO boot
The ISO root filesystem is obviously readonly and cannot be remounted to
'rw'. Without setting 'root_rw_mount=NO', the ISO boot would abort
after failing to remount the root filesystem.
This is a follow-up fix to my previous commit
31b00396377857ebb62259aa944f9351fa62ea44.
Reported-by: Sergey Zigachev (servik)