diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-04-25 22:39:47 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-04-25 22:39:47 +0000 |
commit | 6da168c9141aae0c15f9da588d567dd87a67f1c3 (patch) | |
tree | d0e35d1f14503cff11c2aa371a6cdb9e791fc3d7 /sbin | |
parent | f8e4c18351840b7189b0181b9f578e38c1408134 (diff) |
Remove vnconfig functionality, and try to adapt the manual page.
I'm considering simply deleting mount_vnd -- are there any users of this
bizzare feature?
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/mount_vnd/mount_vnd.8 | 139 | ||||
-rw-r--r-- | sbin/mount_vnd/mount_vnd.c | 191 |
2 files changed, 37 insertions, 293 deletions
diff --git a/sbin/mount_vnd/mount_vnd.8 b/sbin/mount_vnd/mount_vnd.8 index 676aa06d557..62875a4f5f2 100644 --- a/sbin/mount_vnd/mount_vnd.8 +++ b/sbin/mount_vnd/mount_vnd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mount_vnd.8,v 1.21 2014/05/30 16:53:02 tedu Exp $ +.\" $OpenBSD: mount_vnd.8,v 1.22 2019/04/25 22:39:46 deraadt Exp $ .\" .\" Copyright (c) 1993 University of Utah. .\" Copyright (c) 1980, 1989, 1991, 1993 @@ -49,13 +49,12 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 30 2014 $ +.Dd $Mdocdate: April 25 2019 $ .Dt MOUNT_VND 8 .Os .Sh NAME -.Nm mount_vnd , -.Nm vnconfig -.Nd configure vnode disks +.Nm mount_vnd +.Nd mount vnode disks .Sh SYNOPSIS .Nm mount_vnd .Bk -words @@ -66,40 +65,17 @@ .Op Fl t Ar disktype .Ar image .Ar vnd_dev -.Ek -.Nm vnconfig -.Bk -words -.Op Fl ckluv -.Op Fl K Ar rounds -.Op Fl S Ar saltfile -.Op Fl t Ar disktype -.Ar vnd_dev -.Ar image -.Ek .Sh DESCRIPTION -The -.Nm vnconfig -command configures vnode pseudo disk devices. -It will associate (or disassociate) the special file -.Ar vnd_dev -with the regular file -.Ar image , -allowing the latter to be accessed as though it were a disk. -.Pp .Nm mount_vnd works similarly to -.Nm vnconfig , +.Xr vnconfig 8 , but it provides an interface that can be used by the .Xr fstab 5 infrastructure, so that an .Ar image file can be configured to a device -.Ar node +.Ar vnd_dev while booting. -.Nm mount_vnd -defaults to the -.Pa vnd0 -device. .Pp For .Xr fstab 5 @@ -124,20 +100,11 @@ when using the following syntax: .Bd -ragged -offset 4n .Nm mount Op options -t vnd -.Ar image Ar node +.Ar image Ar vnd_dev .Ed .Pp The options are as follows: .Bl -tag -width Ds -.It Fl c -.Nm vnconfig -only. -Configures the device. -If successful, references to -.Ar vnd_dev -will access the contents of -.Ar image . -This is the default operation. .It Fl K Ar rounds Associate an encryption key with the device. All data will be encrypted using the Blowfish cipher before it is @@ -157,16 +124,7 @@ DO NOT LOSE THE SALT FILE. Associate an encryption key with the device. All data will be encrypted using the Blowfish cipher before it is written to the disk. -.It Fl l -.Nm vnconfig -only. -List the vnd devices and indicate which ones are in use. -If a specific -.Ar vnd_dev -is given, then only that one will be described. .It Fl o Ar options -.Nm mount_vnd -only. Options are specified with a .Fl o flag followed by a comma separated string of options. @@ -196,41 +154,13 @@ of the specified .Ar disktype . The defaults are 512-byte sectors, 100 sectors per track and 1 track per cylinder. -.It Fl u -.Nm vnconfig -only. -Unconfigures a -.Ar vnd_dev . -.It Fl v -.Nm vnconfig -only. -Print messages to stdout describing actions taken. .El .Sh FILES .Bl -tag -width /etc/rvnd?? -compact .It Pa /dev/{,r}vnd* .El .Sh EXAMPLES -Configure a CD-ROM or DVD image file as vnode disk vnd0 -and mount the ISO 9660 file system contained in it: -.Bd -literal -offset indent -# vnconfig vnd0 /tmp/diskimage -# mount -t cd9660 /dev/vnd0c /mnt -.Ed -.Pp -Configure an encrypted image file as vnode disk vnd0 and mount the FFS -file system contained in the -.Sq a -partition of the disklabel. -The encryption key does not echo and must be entered every time -the vnode disk is configured. -.Bd -literal -offset indent -# vnconfig -k vnd0 /tmp/cryptimg -Encryption key: -# mount /dev/vnd0a /mnt -.Ed -.Pp -An equivalent +An example .Xr fstab 5 entry is: .Bd -literal -offset indent @@ -238,40 +168,6 @@ entry is: /dev/vnd0a /mnt ffs rw,noauto 0 0 .Ed .Pp -Same as above, but now configure the vnode using PKCS #5 PBKDF2 and -a salt file with 20000 rounds: -.Bd -literal -offset indent -# vnconfig -K 20000 vnd0 /tmp/cryptimg -Encryption key: -Salt file: /tmp/cryptsalt -# mount /dev/vnd0a /mnt -.Ed -.Pp -An equivalent -.Xr fstab 5 -entry is: -.Bd -literal -offset indent -/tmp/cryptimg /dev/vnd0c vnd rw,noauto,-K=20000 0 0 -/dev/vnd0a /mnt ffs rw,noauto 0 0 -.Ed -.Pp -Unmount the file system and unconfigure the vnode device: -.Bd -literal -offset indent -# umount /mnt -# vnconfig -u vnd0 -.Ed -.Pp -A sample of commands to put in -.Xr rc.local 8 -in order to have vnd images configured at boot time is listed here: -.Bd -literal -offset indent -# Example for automatically configuring a vnd device on startup -echo "configuring vnd devices:" -mount /dev/vnd0c -fsck -p /dev/rvnd0a -mount /mnt -.Ed -.Pp Mounting images during the first pass of .Xr fsck 8 and @@ -290,22 +186,3 @@ The .Nm command first appeared in .Ox 4.2 . -.Sh CAVEATS -The -.Sq c -partition of a vnd image should not be used. -When a superblock becomes damaged, -.Xr fsck_ffs 8 -needs information contained in the disklabel -to determine the location of alternate superblocks. -This information is not available when directly using the -.Sq c -partition, -so checking the file system image will fail. -.Pp -Swapping to vnd devices is no longer supported. -.Pp -The encryption used is obsolete. -Consider using -.Xr softraid 4 -instead. diff --git a/sbin/mount_vnd/mount_vnd.c b/sbin/mount_vnd/mount_vnd.c index 55f01a07598..8b04f6307e9 100644 --- a/sbin/mount_vnd/mount_vnd.c +++ b/sbin/mount_vnd/mount_vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_vnd.c,v 1.20 2016/01/24 06:32:33 mmcc Exp $ */ +/* $OpenBSD: mount_vnd.c,v 1.21 2019/04/25 22:39:46 deraadt Exp $ */ /* * Copyright (c) 1993 University of Utah. * Copyright (c) 1990, 1993 @@ -31,10 +31,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * from: Utah $Hdr: vnconfig.c 1.1 93/12/15$ - * - * @(#)vnconfig.c 8.1 (Berkeley) 12/15/93 */ #include <sys/param.h> /* DEV_BSIZE */ @@ -57,42 +53,20 @@ #include <limits.h> #include <util.h> -#define DEFAULT_VND "vnd0" - -#define VND_CONFIG 1 -#define VND_UNCONFIG 2 -#define VND_GET 3 - -int verbose = 0; -int run_mount_vnd = 0; - __dead void usage(void); -int config(char *, char *, int, struct disklabel *, char *, - size_t); -int getinfo(const char *); +int config(char *, char *, struct disklabel *, char *, size_t); char *get_pkcs_key(char *, char *); int main(int argc, char **argv) { - int ch, rv, action, opt_c, opt_k, opt_K, opt_l, opt_u; - char *key, *mntopts, *rounds, *saltopt; + int ch, rv, opt_k = 0, opt_K = 0; + char *key = NULL, *mntopts = NULL, *rounds = NULL, *saltopt = NULL; size_t keylen = 0; - extern char *__progname; struct disklabel *dp = NULL; - if (strcasecmp(__progname, "mount_vnd") == 0) - run_mount_vnd = 1; - - opt_c = opt_k = opt_K = opt_l = opt_u = 0; - key = mntopts = rounds = saltopt = NULL; - action = VND_CONFIG; - - while ((ch = getopt(argc, argv, "ckK:lo:S:t:uv")) != -1) { + while ((ch = getopt(argc, argv, "kK:o:S:t:")) != -1) { switch (ch) { - case 'c': - opt_c = 1; - break; case 'k': opt_k = 1; break; @@ -100,9 +74,6 @@ main(int argc, char **argv) opt_K = 1; rounds = optarg; break; - case 'l': - opt_l = 1; - break; case 'o': mntopts = optarg; break; @@ -114,12 +85,6 @@ main(int argc, char **argv) if (dp == NULL) errx(1, "unknown disk type: %s", optarg); break; - case 'u': - opt_u = 1; - break; - case 'v': - verbose = 1; - break; default: usage(); /* NOTREACHED */ @@ -128,54 +93,26 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (opt_c + opt_l + opt_u > 1) - errx(1, "-c, -l and -u are mutually exclusive options"); - - if (opt_l) - action = VND_GET; - else if (opt_u) - action = VND_UNCONFIG; - else - action = VND_CONFIG; /* default behavior */ - - if (saltopt && (!opt_K)) + if (saltopt && !opt_K) errx(1, "-S only makes sense when used with -K"); - if (action == VND_CONFIG && argc == 2) { - int ind_raw, ind_reg; - - if (opt_k || opt_K) { - fprintf(stderr, - "WARNING: Consider using softraid crypto.\n"); - } - if (opt_k) { - if (opt_K) - errx(1, "-k and -K are mutually exclusive"); - key = getpass("Encryption key: "); - if (key == NULL || (keylen = strlen(key)) == 0) - errx(1, "Need an encryption key"); - } else if (opt_K) { - key = get_pkcs_key(rounds, saltopt); - keylen = BLF_MAXUTILIZED; - } - - /* fix order of arguments. */ - if (run_mount_vnd) { - ind_raw = 1; - ind_reg = 0; - } else { - ind_raw = 0; - ind_reg = 1; - } - rv = config(argv[ind_raw], argv[ind_reg], action, dp, key, - keylen); - } else if (action == VND_UNCONFIG && argc == 1) - rv = config(argv[0], NULL, action, NULL, NULL, 0); - else if (action == VND_GET) - rv = getinfo(argc ? argv[0] : NULL); - else + if (argc != 2) usage(); + if (opt_k || opt_K) + fprintf(stderr, "WARNING: Consider using softraid crypto.\n"); + if (opt_k) { + if (opt_K) + errx(1, "-k and -K are mutually exclusive"); + key = getpass("Encryption key: "); + if (key == NULL || (keylen = strlen(key)) == 0) + errx(1, "Need an encryption key"); + } else if (opt_K) { + key = get_pkcs_key(rounds, saltopt); + keylen = BLF_MAXUTILIZED; + } + rv = config(argv[1], argv[0], dp, key, keylen); + exit(rv); } @@ -247,54 +184,7 @@ get_pkcs_key(char *arg, char *saltopt) } int -getinfo(const char *vname) -{ - int vd, print_all = 0; - struct vnd_user vnu; - - if (vname == NULL) { - vname = DEFAULT_VND; - print_all = 1; - } - - vd = opendev((char *)vname, O_RDONLY, OPENDEV_PART, NULL); - if (vd < 0) - err(1, "open: %s", vname); - - vnu.vnu_unit = -1; - -query: - if (ioctl(vd, VNDIOCGET, &vnu) == -1) { - if (print_all && errno == ENXIO && vnu.vnu_unit > 0) { - close(vd); - return (0); - } else { - err(1, "ioctl: %s", vname); - } - } - - fprintf(stdout, "vnd%d: ", vnu.vnu_unit); - - if (!vnu.vnu_ino) - fprintf(stdout, "not in use\n"); - else - fprintf(stdout, "covering %s on %s, inode %llu\n", - vnu.vnu_file, devname(vnu.vnu_dev, S_IFBLK), - (unsigned long long)vnu.vnu_ino); - - if (print_all) { - vnu.vnu_unit++; - goto query; - } - - close(vd); - - return (0); -} - -int -config(char *dev, char *file, int action, struct disklabel *dp, char *key, - size_t keylen) +config(char *dev, char *file, struct disklabel *dp, char *key, size_t keylen) { struct vnd_ioctl vndio; char *rdev; @@ -313,26 +203,11 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key, vndio.vnd_keylen = keylen; /* - * Clear (un-configure) the device - */ - if (action == VND_UNCONFIG) { - rv = ioctl(fd, VNDIOCCLR, &vndio); - if (rv) - warn("VNDIOCCLR"); - else if (verbose) - printf("%s: cleared\n", dev); - } - /* * Configure the device */ - if (action == VND_CONFIG) { - rv = ioctl(fd, VNDIOCSET, &vndio); - if (rv) - warn("VNDIOCSET"); - else if (verbose) - printf("%s: %llu bytes on %s\n", dev, vndio.vnd_size, - file); - } + rv = ioctl(fd, VNDIOCSET, &vndio); + if (rv) + warn("VNDIOCSET"); close(fd); fflush(stdout); @@ -345,17 +220,9 @@ config(char *dev, char *file, int action, struct disklabel *dp, char *key, __dead void usage(void) { - extern char *__progname; - - if (run_mount_vnd) - (void)fprintf(stderr, - "usage: mount_vnd [-k] [-K rounds] [-o options] " - "[-S saltfile] [-t disktype]\n" - "\t\t image vnd_dev\n"); - else - (void)fprintf(stderr, - "usage: %s [-ckluv] [-K rounds] [-S saltfile] " - "[-t disktype] vnd_dev image\n", __progname); - + (void)fprintf(stderr, + "usage: mount_vnd [-k] [-K rounds] [-o options] " + "[-S saltfile] [-t disktype]\n" + "\t\t image vnd_dev\n"); exit(1); } |