git: 14b475c47905 - main - Remove gbde support from swapon(8)

From: Poul-Henning Kamp <phk_at_FreeBSD.org>
Date: Tue, 07 May 2024 07:40:40 UTC
The branch main has been updated by phk:

URL: https://cgit.FreeBSD.org/src/commit/?id=14b475c47905357c4cf64b3b72d822b2feb23c36

commit 14b475c47905357c4cf64b3b72d822b2feb23c36
Author:     Poul-Henning Kamp <phk@FreeBSD.org>
AuthorDate: 2024-05-07 07:21:46 +0000
Commit:     Poul-Henning Kamp <phk@FreeBSD.org>
CommitDate: 2024-05-07 07:21:46 +0000

    Remove gbde support from swapon(8)
---
 include/paths.h        |  1 -
 sbin/swapon/swapon.c   | 60 --------------------------------------------------
 share/man/man5/fstab.5 |  3 +--
 3 files changed, 1 insertion(+), 63 deletions(-)

diff --git a/include/paths.h b/include/paths.h
index 9f9071af915c..86900664230b 100644
--- a/include/paths.h
+++ b/include/paths.h
@@ -61,7 +61,6 @@
 #define	_PATH_FIRMWARE	"/usr/share/firmware"
 #define	_PATH_FTPUSERS	"/etc/ftpusers"
 #define	_PATH_FWMEM	"/dev/fwmem"
-#define	_PATH_GBDE	"/sbin/gbde"
 #define	_PATH_GELI	"/sbin/geli"
 #define	_PATH_HALT	"/sbin/halt"
 #ifdef COMPAT_libcompat
diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c
index 26a7dc22654a..a09f2598e2ac 100644
--- a/sbin/swapon/swapon.c
+++ b/sbin/swapon/swapon.c
@@ -56,7 +56,6 @@
 
 static void usage(void) __dead2;
 static const char *swap_on_off(const char *, int, char *);
-static const char *swap_on_off_gbde(const char *, int);
 static const char *swap_on_off_geli(const char *, char *, int);
 static const char *swap_on_off_md(const char *, char *, int);
 static const char *swap_on_off_sfile(const char *, int);
@@ -238,12 +237,6 @@ swap_on_off(const char *name, int doingall, char *mntops)
 	basebuf = strdup(name);
 	base = basename(basebuf);
 
-	/* Swap on encrypted device by GEOM_BDE. */
-	if (fnmatch("*.bde", base, 0) == 0) {
-		free(basebuf);
-		return (swap_on_off_gbde(name, doingall));
-	}
-
 	/* Swap on encrypted device by GEOM_ELI. */
 	if (fnmatch("*.eli", base, 0) == 0) {
 		free(basebuf);
@@ -269,59 +262,6 @@ swap_basename(const char *name)
 	return (dname);
 }
 
-static const char *
-swap_on_off_gbde(const char *name, int doingall)
-{
-	const char *ret;
-	char pass[64 * 2 + 1];
-	unsigned char bpass[64];
-	char *dname;
-	int i, error;
-
-	dname = swap_basename(name);
-	if (dname == NULL)
-		return (NULL);
-
-	if (which_prog == SWAPON) {
-		arc4random_buf(bpass, sizeof(bpass));
-		for (i = 0; i < (int)sizeof(bpass); i++)
-			sprintf(&pass[2 * i], "%02x", bpass[i]);
-		pass[sizeof(pass) - 1] = '\0';
-
-		error = run_cmd(NULL, "%s init %s -P %s", _PATH_GBDE,
-		    dname, pass);
-		if (error) {
-			/* bde device found.  Ignore it. */
-			free(dname);
-			if (qflag == 0)
-				warnx("%s: Device already in use", name);
-			return (NULL);
-		}
-		error = run_cmd(NULL, "%s attach %s -p %s", _PATH_GBDE,
-		    dname, pass);
-		free(dname);
-		if (error) {
-			warnx("gbde (attach) error: %s", name);
-			return (NULL);
-		}
-	}
-
-	ret = swap_on_off_sfile(name, doingall);
-
-	if (which_prog == SWAPOFF) {
-		error = run_cmd(NULL, "%s detach %s", _PATH_GBDE, dname);
-		free(dname);
-		if (error) {
-			/* bde device not found.  Ignore it. */
-			if (qflag == 0)
-				warnx("%s: Device not found", name);
-			return (NULL);
-		}
-	}
-
-	return (ret);
-}
-
 /* Build geli(8) arguments from mntops */
 static char *
 swap_on_geli_args(const char *mntops)
diff --git a/share/man/man5/fstab.5 b/share/man/man5/fstab.5
index 6a357e497ca7..9cdcf818cf32 100644
--- a/share/man/man5/fstab.5
+++ b/share/man/man5/fstab.5
@@ -423,10 +423,9 @@ resides in
 # Swap space on a block device.
 /dev/da0p1	none		swap	sw		0	0
 #
-# Swap space using a block device with GBDE/GELI encryption.
+# Swap space using a block device with GELI encryption.
 # aalgo, ealgo, keylen, sectorsize options are available
 # for .eli devices.
-/dev/da1p1.bde	none		swap	sw		0	0
 /dev/da1p2.eli	none		swap	sw		0	0
 #
 # tmpfs.