Commit graph

637 commits

Author SHA1 Message Date
Bjoern A. Zeeb ad31d47642 bsdinstall: update comment related to pkg
pkg_add has been gone since 2013(?).  Refer to pkg(8) instead.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	jrtc27
Differential Revision: https://reviews.freebsd.org/D44946
2024-04-25 17:44:18 +00:00
Warner Losh 560931508c Revert "bsdinstall/distfetch.c: check environment variables before downloading and handle memory allocation errors"
This reverts commit 91bdebc958. It wasn't
as ready as I thought
2024-04-23 21:18:56 -06:00
rilysh 91bdebc958 bsdinstall/distfetch.c: check environment variables before downloading and handle memory allocation errors
1. Currently, distfetch checks environment variables existence
when it will use them or in a case (in chdir()) it doesn't check
at all. As they are necessary to set before doing anything with
it, check them, if they set or not, before proceeding any further.
This also avoids extra cleaning when that environment variable
isn't set.

2. Handle memory allocation error in malloc(PATH_MAX) and replace
(sizeof const char *) with (sizeof char *). Both are similar and
const doesn't have a size.

3. Indent the error message a bit in chdir().

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1071
2024-04-23 16:42:38 -06:00
Mike Karels 970ea0b2cb bsdinstall: draw attention to new network config options
The network configuration options have changed in bsdinstall, with
an Auto option to proceed directly to DHCP and IPv6 autoconfig (which
is the default) as well as Manual (the old mode).  For users like me
that were used to hitting return automatically to select an interface,
but want manual configuration, attempt to call out the difference:
Change the menu caption to say "Please select a network interface
and configuration mode:" and not just an interface.

Reviewed by:	jrtc27
2024-03-27 15:20:26 -05:00
Philip Paeps 2911c44baf bsdinstall: remove two dead mirrors 2024-02-15 21:49:33 +08:00
Philip Paeps 9c59988175 bsdinstall: prefer HTTP
In 2024, users are more likely to have working HTTP than working FTP.
Present http://ftp.FreeBSD.org as the first option in the installer.
Keep ftp://ftp.FreeBSD.org as the second option.

MFC after:	3 weeks
2024-02-15 21:49:33 +08:00
Jessica Clarke c994f226bb bsdinstall: Add new Auto option to netconfig interface selection dialog
This changes the OK / Cancel buttons into Auto / Manual / Cancel, with
Auto being the default. Manual behaves like OK used to, i.e. presents a
series of dialogs asking exactly how to configure the interface, and
Cancel is unchanged, exiting with exit code 1. Auto will attempt to
configure IPv4+DHCP and IPv6+SLAAC with no interaction, failing only if
neither can be configured, thereby supporting all of IPv4-only,
IPv6-only and dual-stack environments. If at least one DNS server is
provided, it will also skip asking for DNS settings, otherwise it will
act like Manual mode for the purposes of DNS settings and prompt. For a
standard dual-stack environment this cuts down the number of netconfig
dialogs from 6 (interface, IPv4, DHCP, IPv6, SLAAC, DNS) to just the
first one.

Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D43731
2024-02-09 18:13:47 +00:00
Mariusz Zaborski cd724c2592 bsdinstall: complete whitelabeling the installer
The commit 147585b489 introduces
whitlabeling. This commit addresses couple more places where the
os name was missed.

Reviewed by:	imp, asiciliano, brd
Differential Revision:	https://reviews.freebsd.org/D43638
2024-02-04 13:01:08 +01:00
Jessica Clarke 1e75e61d5c bsdinstall: Fix broken netconfig persistence for installed system
The replacement of echo >> with sysrc -f used sysrc key value, which
means "read variables key and value" and thus did nothing useful (and in
fact emitted errors to the log about neither existing). Instead use the
correct sysrc key=value form so the installed system comes back up with
working networking.

Fixes:	60b37735f3 ("bsdinstall netconfig: avoid duplicate entries in rc.conf")
2024-02-03 22:50:47 +00:00
Jessica Clarke 7414d14bd5 bsdinstall: Drop Error from title in netconfig no interfaces dialog
This isn't inherently an error. It is if you're attempting to download
dist tarballs or later install packages, but a FreeBSD system with no
NIC is a reasonable setup to have, especially in a throwaway VM setting,
so we shouldn't say it is one.

Leaving the exit code as 1 is still fine, since auto will ignore it, and
avoids breaking other uses.

MFC after:	1 week
2024-02-03 01:52:53 +00:00
Jessica Clarke b809c7d6a2 bsdinstall: Fix netconfig script when no interfaces are present
The script uses [ -z "$INTERFACES" ] to check if the list of interfaces
is empty and will exit early if so, but INTERFACES always contains at
least a space due to the way it appends the list of wireless devices.
Fix this by only adding the space when there are devices to append,
mirroring the behaviour for non-wireless devices above (both will result
in a redundant leading space when the list is non-empty, but that one is
harmless).

Fixes:		159ca5c844 ("Adapt to new wireless scheme where base wlan interfaces do not show up in ifconfig anymore.")
MFC after:	1 week
2024-02-03 01:52:37 +00:00
Jessica Clarke 7143521f4c Revert "bsdinstall: separate out dist selection in prep for pkgbase support"
Firstly, my review comments were not addressed and instead totally
ignored. Secondly, and a more valid justification for the revert, this
completely breaks the installer, since selectdists isn't installed.
Given the blatant lack of testing, back out this commit until it has
actually been tested and review comments taken on board so that the
installer actually works.

This reverts commit 009d3f66cb.
2024-02-03 01:31:11 +00:00
Brad Davis 009d3f66cb bsdinstall: separate out dist selection in prep for pkgbase support
No functional change intended.

Approved by:	asiciliano
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43621
2024-01-31 15:05:27 -07:00
Michael Gmelin 731704f5ea bsdinstall: Fix installation script splitting
This allows writing setup scripts that contain lines starting with
"#!", e.g., a shebang when creating a shell script using cat:

    #!/bin/sh
    echo "Populate rc.local"
    cat >/etc/rc.local<<EOF
    #!/bin/sh
    echo booted | logger -s -t 'example'
    EOF

Prevent accidentally running a setup script left behind by a
previous invocation of bsdinstall.

Reviewed by:	imp, jrtc27
Differential Revision:	https://reviews.freebsd.org/D43350
2024-01-09 19:14:17 +01:00
Pierre Pronchery 19bb1886be bsdinstall: rename "Live CD" to "Live System"
This uses more generic wording in the FreeBSD installer, when offering
the user to use the system booted without running the installer.

The updated wording is also reflected in freebsd-version(1).

Reviewed by:		emaste
Sponsored by:		The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43233
2023-12-29 15:24:25 -05:00
Simon J. Gerraty 5c8b07fe84 bsdinstall: add include to SUBDIR 2023-12-06 22:17:14 -08:00
Simon J. Gerraty 83d0b8c089 bsdinstall generate opt_osname.h in include
This allows the subdirs that do more work to run in parallel

Reviewed by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D42947
2023-12-06 18:34:52 -08:00
Jessica Clarke 47d669f10e bsdinstall: Encode dists to valid variable names in checksum script
Currently we just strip the .txz of the dist name (and add a status_
prefix) to get the shell variable name for its status, but this doesn't
give a valid result for dists like base-dbg, kernel-dbg and lib32-dbg,
or even kernel.KERNCONF (or, combining the two, kernel.KERNCONF-dbg). As
a result, four things go wrong for such dists:

1. If there is a dot and/or a dash in the name, writing to the variable
   fails and spits an error out on stderr to the log
3. If there is a dot in the name before any dash, the syntax is always
   invalid, reading the variable fails, spits an error out on stderr to
   the log, the result is the empty string and that is interpreted as
   being 0%
2. If there is a dash in the name before any dot, and there is a dist
   whose name is the substring up to that first dash, and it has already
   had its status written to, reading the variable instead reads that
   dist's variable and so the status of that dist is displayed instead
3. If there is a dash in the name before any dot, and either there is
   not a dist whose name is the substring up to that first dash or there
   is such a dist but it has not already had its status written to,
   reading the varaible instead results in the substring after the first
   dash, including any additional string expansion syntax that follows
   (i.e. ${status_kernel-dbg:--11}, the expression used to read the
   variable, is interpreted as reading status_kernel with a default
   value of "dbg:--11")

For example, in a default install with base, kernel, kernel-dbg and
lib32, the following sequence of displays happens:

1. base is In Progress, kernel is Pending, kernel-dbg is 0% (what shows
   for the garbage input "dbg:--11") and lib32 is Pending
2. base is Passed, kernel is In Progress, kernel-dbg is In Progress
   (since kernel has now had its status written to) and lib32 is
   Pending
3. base is Passed, kernel is Passed, kernel-dbg is Passed (again, since
   that is the status of kernel, despite that kernel-dbg is being
   verified at this point) and lib32 is Pending
4. base is Passed, kernel is Passed, kernel-dbg is Passed and lib32 is
   In Progress

Fix this with a crude encoding scheme. More special characters can
easily be added if needed in future.

Note that, prior to bsddialog being used (and thus for branches this is
MFC'ed to where dialog is still used), the same problem existed but
displayed slightly differently due to a combination of different default
values and different behaviour for unintended inputs.

Fixes:		b70047d413 ("Add generation of an installation manifest containing SHA256 checksums as ...")
MFC after:	1 week
2023-12-06 21:37:32 +00: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
John Baldwin 84f773037e bsdinstall.8: Clarify the description of ZFSBOOT_FORCE_4K_SECTORS
This variable does not set the exact sector size of the pool, but
controls the minimum sector size.  The sector size of the underlying
disks can always be larger than the minium controlled by this knob.

PR:		274513
Reported by:	Albin "a12l" Otterhäll <bugs.freebsd.org@a12l.xyz>
2023-11-18 11:45:42 -08:00
John Baldwin de82aed119 bsdinstall zfsboot: Don't override ZFSBOOT_FORCE_4K_SECTORS if it is null.
Only set a default value of 1 if the shell variable is unset.  This allows
installer scripts to disable the variable.

PR:		274513
Reported by:	Albin "a12l" Otterhäll <bugs.freebsd.org@a12l.xyz>
Differential Revision:	https://reviews.freebsd.org/D42319
2023-11-18 11:18:29 -08:00
Alfonso S. Siciliano e44751530e
bsdinstall hostname: Restore bsdconfig API
Restore bsdconfig API to handle hostname dialog because bsddialog 1.0
matches all features required by bsdconfig(1). Implicitly this commit
restores also Xdialog(1) for this script.

This commit reverts:
 - "bsdinstall hostname: Replace dialog with bsddialog"
   6368dcb292
 - "bsdinstall(8) hostname: Update for bsddialog 0.3"
   5f3ec44e7e.

The script continues to use bsddialog(1) by default via $DIALOG in
bsdconfig(1).
2023-10-19 12:59:49 +02:00
Fernando Apesteguía b9cf989234 bsdinstall: Fail nicely in jail target
If the directory is empty we fail with a message regarding mkdir in which
the empty directory can't be seen because it is not quoted.

Show a nice message so the user knows what is going on.

Reviewed by:		bapt@
Differential Revision:	https://reviews.freebsd.org/D42252
2023-10-18 09:46:05 +02:00
John Baldwin 6e8bf24073 bsdinstall partedit: Use snprintf instead of sprintf for error messages
When generating a message for a dialog box into a static buffer, use
snprintf instead of sprintf to avoid buffer overflows.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42240
2023-10-16 16:25:38 -07:00
John Baldwin a8676bf367 bsdinstall partedit: Use asprintf to build wrapper command for newfs
Don't abuse the message[] static buffer used elsewhere for error
messages to generate the command that actually newfs's each
filesystem.  Use asprintf to a more aptly-named 'char *command'
variable to construct the string instead.  This avoids potential bugs
from truncation of the command string.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42239
2023-10-16 16:25:25 -07:00
John Baldwin 51749e05e9 bsdinstall partedit: Replace malloc + sprintf with asprintf
This avoids potential bugs with the length passed to malloc not
matching the string written via sprintf.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42238
2023-10-16 16:25:15 -07:00
John Baldwin ae2fc74fe7 bsdinstall partedit: Avoid potential buffer overflow in newfs_command
Allocate the buffer holding the newfs command string dynamically
(building the string via open_memstream) rather than storing the
command into a caller-supplied buffer of unknown length.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42237
2023-10-16 16:25:03 -07:00
John Baldwin 5307bbcc03 bsdinstall partedit: Apply changes from scripted installs
I got a check inverted in a previous cleanup commit and as a result
partedit was only applying GEOM changes (and generating an /etc/fstab)
if it got an error reading the current GEOM mesh.  Instead, it needed
to do those actions if it succeeded in reading the mesh.

The lack of /etc/fstab meant that bsdinstall mount didn't mount
anything in a scripted install.

PR:		273723
Reported by:	Andrey Fesenko <andrey@bsdnir.info>
Reported by:	Michal Nowak <mnowak@startmail.com>
Reviewed by:	cognet, brooks
Fixes:		2309909919 bsdinstall: Handle errors from geom_gettree.
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42236
2023-10-16 15:13:31 -07:00
Alfonso S. Siciliano 7ef6e99752
sade: Restore UI behavior like dialog(3)
Restore UI behavior like previous disk menu implementation built on
dialog(3):

 * Buttons of Create and Modify forms always active to close the
   dialogs just pressing Enter.
 * Disk menu indentation.
2023-10-16 14:06:06 +02:00
Pierre Pronchery 60b37735f3 bsdinstall netconfig: avoid duplicate entries in rc.conf
This uses sysrc to write and update configuration variables in the
temporary configuration file for network access, ._rc.conf.net. This
replaces the previous mechanism, which was simply appending new values
as they were updated.

PR:		212396
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42194
2023-10-13 12:45:54 -04:00
Pierre Pronchery 01ab86f7e6 bsdinstall: reset the mirror when restarting
It is possible to restart the installation process upon errors, when
installing normally through the `auto` script, or when setting up a jail
with the `jail` script. However, some values obtained interactively from
the user or guessed by some scripts are kept in the environment when
restarting the process; this makes it impossible to run some steps as
expected after the restart.

For instance, if a bad choice of mirror was made in the `mirrorselect`
phase, restarting the installer remembers the choice made, and will
never prompt for a different one. Rebooting is then the only easy way
out of this situation.

This change only affects the `jail` script for now, as otherwise there
is no way to tell if the value had been specifically set by the user
before starting bsdinstall.

Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42183
2023-10-13 12:32:38 -04:00
Pierre Pronchery ac78e3e9c5 bsdinstall: Add "Finish" button to finalconfig
This adds a "Finish" button to the finalconfig step, replacing the
previous first choice, which was to "apply configuration and exit".
The new button is the default action, while the "OK" button is renamed
to "Select".

Also, if an unknown option is chosen, the code flow prompts the user
again instead of exiting.

Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42047
2023-10-13 12:23:01 -04:00
Pierre Pronchery a6d202077d bsdinstall: revisit the finalconfig step
This moves the "finalconfig" step into a dedicated script, where it uses
a loop instead of recursing into itself.

Reviewed by:	bapt
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42046
2023-10-13 12:19:39 -04:00
Alfonso S. Siciliano cdee659f93
sade: Fix F1 help message
Fix F1 message of the disk menu because the button label is "[Modify]".
This is a UI fix, no functional change.
2023-10-13 02:19:45 +02:00
Alfonso S. Siciliano 04b465777a
bsdinstall auto: replace dialog with bsddialog
bsdinstall/scripts/auto: Replace dialog(1) with bsddialog(1).
2023-10-11 18:33:25 +02:00
Alfonso S. Siciliano 160ccec84c
bsdinstall: restore --calendar
Restore --calendar to select a date because bsddialog(1) >= 0.4
provides a calendar dialog.
2023-10-11 15:48:53 +02:00
Alfonso S. Siciliano 8df9efe877
bsdinstall: Fix command line argument list parsing
bsddialog(1) uses getopt_long(3) to parse command line argument list.
Add '--' to avoid errors caused by arguments (menu items) begin
with '-'.
The change is compatible with dialog(1) and Xdialog(1).
2023-10-11 10:17:04 +02:00
Baptiste Daroussin 61ba55bcf7 bsddialog: import version 1.0 2023-10-04 18:12:03 +02:00
Lars Kellogg-Stedman c0e249d32c
bsdinstall: avoid conflicts with fd 3
Throughout the bsdinstall script fd 3 is used by f_dprintf (set through
$TERMINAL_STDOUT_PASSTHRU). In several places in the bsdinstalls scripts,
we use fd 3 to juggle stdout when calling out to other tools, which can
cause the installer to fail with a "Bad file descriptor" error when
f_dprintf attempts to use it.

This commit replaces all constructs like this:

    exec 3>&1
    SOME_VARIABLE=$(some command 2>&1 1>&3)
    exec 3>&-

With:

    exec 5>&1
    SOME_VARIABLE=$(some command 2>&1 1>&5)
    exec 5>&-

PR:			273148
Reviewed by:		corvink
Fixes:			1f7746d81f ("bsdinstall: stop messing with file descriptors")
MFC after:		1 week
2023-09-21 08:41:48 +02:00
Mateusz Piotrowski fea2cffb86 bsdinstall.8: Document BSDINSTALL_SKIP_* variables
Fixes:	17f4ded551 bsdinstall: add variables to allow skipping
MFC after:	3 days
2023-09-18 23:59:09 +02:00
Mateusz Piotrowski a8f5c9d330 bsdinstall.8: Set Bl's -width correctly
MFC after:		3 days
2023-09-18 23:59:09 +02:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
John Baldwin 2309909919 bsdinstall: Handle errors from geom_gettree.
geom_gettree probably never fails, and if it does there isn't much of
a fallback other than aborting partitioning.  However, a few places
were checking the return value and not doing anything with it
triggering a unused-but-set-variable warning.  Checking the errors
resolves the warning.

While here, check for errors in other places that weren't checking for
them at all, remove a spurious double call (the second call overwrote
the mesh structure leaking all the pointers from the first), and close
a few resource leaks on error paths.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D40779
2023-06-28 11:11:00 -07:00
John Baldwin f66a8328c3 bsdinstall: Replace correct, but fragile, string builder with open_memstream.
The old one triggered a false positive -Warray-bounds from GCC (the
compiler assumed len was always 0), but it was also fragile with
manually computed lengths paired with strcat vs using a string
builder.

Differential Revision:	https://reviews.freebsd.org/D40658
2023-06-27 10:19:32 -07:00
Baptiste Daroussin fe06db1817 bsdinstall: remove sendmail hardening option
sendmail is fully disabled in 14.0 by default

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D40367
2023-06-01 23:00:22 +02:00
Mike Karels 3bb92304b4 bsdinstall on zfs: create dataset for /home rather than /usr/home
Now that pw (hence adduser and the initial install) use /home for
user home directories rather than /usr/home, create a dataset for
/home rather than /usr/home.  Update the man page to match.

Reviewed by:	rgrimes, markj
Differential Revision:	https://reviews.freebsd.org/D40086
2023-05-23 07:18:27 -05:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00