Commit Graph

7358 Commits

Author SHA1 Message Date
nat 2d7b3c2cc9 Revert to previous as atf tests were failing. 2022-08-16 22:31:24 +00:00
nat 728612bd0e No need address every time to specify broadcast and netmask.
Previously ifconfig would fail silently.

Addresses PR bin/10911.
2022-08-16 10:47:10 +00:00
riastradh 7605cff464 cgdconfig(8): Handle -P/-S for shared keys with -G too.
This way you can convert an existing parameters file to one that is
derived from a shared key, and derive other subkeys for other disks
from the same shared key.

	cgdconfig -G -S -o /etc/cgd/wd0.shared /etc/cgd/wd0
	cgdconfig -G -S -o /etc/cgd/wd1.shared \
		-P /etc/cgd/wd0.shared /etc/cgd/wd1

This way, if you enter the same new password both times, wd0.shared
and wd1.shared generate the same keys as wd0 and wd1, but only need
one password entry with `cgdconfig -C'.
2022-08-12 10:49:47 +00:00
riastradh 3adc7246cf cgdconfig(8): Add support for generating shared-key parameters files.
Usage model:

- Generate a parameters file that supports sharing its main key:

	cgdconfig -g -S -o /etc/cgd/wd0e -V gpt adiantum

- Make another parameters file that uses the same shared main key but
  derives an independent subkey from it:

	cgdconfig -g -S -P /etc/cgd/wd0e -o /etc/cgd/ld1e \
	    -V disklabel aes-cbc 256
2022-08-12 10:49:35 +00:00
riastradh 920e28df65 cgdconfig(8): Add support for shared keys.
New clause `shared <id> algorithm <alg> subkey <info>' in a keygen
block enables `cgdconfig -C' to reuse a key between different params
files, so you can, e.g., use a single password for multiple disks.
This is better than simply caching the password itself because:

- Hashing the password is expensive, so it should only be done once.

  Suppose your budget is time t before you get bored, and you
  calibrate password hash parameters to unlock n disks before you get
  bored waiting for `cgdconfig -C'.

  . With n password hashings the adversary's cost goes up only by a
    factor of t/n.
  . With one password hashing and n subkeys the adversary's cost goes
    up by a factor of n.

  And if you ever add a disk, rehashing it will make `cgdconfig -C'
  go over budget, whereas another subkey adds negligible cost to you.

- Subkeys work for other types of keygen blocks, like shell_cmd,
  which could be used to get a key from a hardware token that needs a
  button press.

The <info> parameter must be different for each params file;
everything else in the keygen block must be the same.  With this
clause, the keygen block determines a shared key used only to derive
keys; the actual key used by cgdconfig is derived from the shared key
by the specified algorithm.

The only supported algorithm is hkdf-hmac-sha256, which uses
HKDF-Expand of RFC 5869 instantiated with SHA-256.

Example:

	algorithm aes-cbc;
	iv-method encblkno1;
	keylength 128;
	verify_method none;
	keygen pkcs5_pbkdf2/sha1 {
		iterations 39361;
		salt AAAAgMoHiYonye6KogdYJAobCHE=;
		shared "pw" algorithm hkdf-hmac-sha256
		    subkey AAAAgFlw0BMQ5gY+haYkZ6JC+yY=;
	};

The key used for this disk will be derived by

	HKDF-HMAC-SHA256_k(WXDQExDmBj6FpiRnokL7Jg==),

where k is the outcome of PBKDF2-SHA1 with the given parameters.

Note that <info> encodes a four-byte prefix giving the big-endian
length in bits of the info argument to HKDF, just like all other bit
strings in cgdconfig parameters files.

If you have multiple disks configured using the same keygen block
except for the info parameter, `cgdconfig -C' will only prompt once
for your passphrase, generate a shared key k with PBKDF2 as usual,
and then reuse it for each of the disks.
2022-08-12 10:49:17 +00:00
riastradh 732db29a3c cgdconfig(8): New -T operation prints all generated keys in cgd.conf.
For testing purposes.
2022-08-12 10:48:44 +00:00
riastradh a7c16118d0 cgdconfig(8): New -t operation just prints the derived key in base64.
For testing purposes.
2022-08-12 10:48:27 +00:00
andvar 5a58ccfbec fix various typos in comments, documentation and messages.
mainly s/paramater/parameter/ and s/reduntant/redundant/.
2022-08-07 11:06:18 +00:00
rin 422de7d163 Assert postts only if we really obtained a timestamp. 2022-08-06 10:22:22 +00:00
rin eb7145dc97 Do not declare unused tstamp for SMALL. NFC. 2022-08-06 10:19:44 +00:00
rin 82dbd18ccf Get back to the statically-allocated tbuf.
If a string is longer than tbuf, it cannot be a timestamp.
Therefore, no need for buffering anymore in this case.
2022-08-06 10:16:18 +00:00
rin df7debb42d Oops, fix thinko in the previous. 2022-08-06 09:42:33 +00:00
rin 2a3cf2bf71 Do not discard \[.*\] which is not identified as a timestamp. 2022-08-06 09:39:32 +00:00
rin d67befb65b KNF. Do not unnecessarily define ADDC() for SMALL. No binary changes. 2022-08-06 09:33:56 +00:00
mlelstv 876fd04d2a Fix build on 32bit. 2022-07-31 13:49:23 +00:00
mlelstv fa449f06f2 Report error code (SCT/SC). 2022-07-31 12:11:44 +00:00
dholland 3ad018779f Fix misleading fsck_ffs messages about wapbl journal replay.
Apparently fsck doesn't have a way to replay it to its internal memory
only. (Someone(TM) should implement this...)

This means that if you use -n, it can't replay the journal. But the
sequence of prints is such that it looks like it did. This is quite
misleading. Add an additional specific warning.
2022-07-25 05:15:08 +00:00
kre 5c922bdb9e PR bin/56917
If getfsspecname() fails that will usually mean that a NAME=wedge or
ROOT.x partition is unabailable.   raidframe specified unavailable
partitions as "absent" so in this case, pass "absent" rather than the
unaltered NAME= or ROOT.x string, which the kernel has no clue what
do do with, and doesn't configure the raid at all.
2022-07-21 09:19:53 +00:00
mlelstv ac9df4c9d7 Whitespace 2022-07-16 12:57:14 +00:00
snj 91e84632a7 drop reference to smbfs, which was removed in 2020.
while here, s/file-system/file system/
2022-07-10 18:52:34 +00:00
wiz 52bbdadeb2 Fix At argument and remove superfluous Pp. 2022-07-01 16:58:02 +00:00
kre e1c098e157 Bring shutdown(8) into the 21st century.
I found this juxtaposition in the shutdown man page kind of
interesting:

     time  Time is the time at which shutdown will bring the system down
	   and may be the word now or a future time in one of two formats:
	   ... [2nd format:] [[[[[cc]yy]mm]dd]hh]mm,  ...
	   If the century [cc] is not specified, it defaults to 1900 for
	   years [yy] between 69 and 99, ...

In that, all the "[text]" except the one "[[[[["(etc) sequence are my
interjections, The ellipses ("...") represent where I omitted irrelevant
(for here) text.

Interesting yes, bizarre also.   Requiring a future time, and then
defaulting to the (long gone) 20th century (for any random year)
makes no sense at all.    So I fixed it.

In another hundred years or so, anytime from 2100 onwards, but best
left at least a decade into the new century, it will need altering again.
[One could write the code to automate this adjustment, but the man
page would still need updating.]   More significant changes will be
needed as the 101st century approaches (years 10000 and beyond), as
then a 2 digit century will no longer be adequate.   Call me then, and
if I'm able, I'll fix it.

If someone really has a need to schedule a shutdown for sometime
between 1969 and 1999 that can still be done by explicitly giving
the "19" cc value.  It is just no longer ever the default.

Otherwise, now, years 20..90 mean the 21st century (2020..2099)
(the first 2 of those are already unusable, but, IMO, that's OK)
and years 00..19 mean the 22nd century (2100..2119) (except that
00, 2100, is still technically the final year of the 21st century).

This is advance planning for near the end of the 21st century when
someone wants to schedule a shutdown for early in the following
century, and can't be bothered typing the 2 century digits.
2022-07-01 16:45:12 +00:00
kre d73b978a64 Implement "raidctl -t config-file"
This does the same config file parse  that -c/-C do, but only
that (hence no raidframe device is needed, or accepted).

Any syntax errors in the config file will be reported, nothing
else happens.
2022-06-14 08:06:18 +00:00
kre b958b2dc5a Fix some config file parsing.
First, and what got me started on this set of cleanups, the queue
length in the "queue" section (START queue) is limited to what will
fit in a char without losing accuracy (I tried setting it to 200,
rather than the more common (universal?) 100 and found that the
value configured into the array was -56 instead.

Why the value needs to be passed through a char variable I have no
idea (it is an int in the filesystem raidframe headers) - but that's
the way it is done, and changing it would be an ABI change I believe
(and so need versioning to alter) and that isn't worth it for this
(or not now, IMO).

Instead check that the value in the char is the same value as was
read from the config file, and complain if not.   Those of you with
unsigned chars will be able to have queue lengths up to 255, the
rest of us are limited to 127.

While looking at that, I noticed some code that obviously fails to
understand that scanf("%s") will never return a string containing
spaces, and proceeded to attempt to remove trailing spaces from the
result ... amusingly, after having used the result for its intended
purpose (non existent trailing spaces unremoved), after which that
buffer was never used again.   That code is now gone (but for now,
just #if 0'd rather than actually deleted - it should be cleaned up
sometime).

Then I saw some other issues with how the config was parsed - a
simple (unbounded) scanf("%s") into a buffer, which hypothetically
might not be large enough (not a security issue really, raidctl has
no special privs, and it isn't likely that root could easily be
tricked into running it on a bogus config file - or not without
looking first anyway, and a huge long string would rather stand
out).   Bound the string length to something reasonable, and
assert() that the buffer is big enough to contain it.

Lastly, in the event of one particular detected error in the
config file, the code would write a warning, but then just go
ahead and use the bad data (or nothing perhaps) anyway - a
failure of logic flow (unlikely to have ever happened, everyone
seems to simply copy the sample config from the man page, and
make minor adjustments as needed).

If any of these changes make any difference to anyone (except
me with my attempt to make longer queues - for no particularly
well thought out reason), I'd be very surprised.
2022-06-14 08:06:13 +00:00
kre 5a1ff55a3a In the previous (and some earlier) version(s) of raidctl.c
the following comment appeared:

	/*
	 * After NetBSD 9, convert this to not output the numRow's value,
	 * which is no longer required or ever used.
	 */

We are after NetBSD 9 (well after).   The change requested in that
comment is made here, and the comment is thus removed.

A couple of places in rf_configure.c where a value for the "rows"
parameter was output in an error message (always simply as the
constant 0) have also been updated (those messages will no longer
include "row 0", which they always said previously).   One of them
was also slightly reworded to be clearer what problem it was
experiencing (when it said 'unable to get device file' it meant
it was unable to locate the name for the device in the config file,
not that it was found, and there was some other problem with it).
2022-06-14 08:06:07 +00:00
kre 681f9ba5c2 Reorder the getopts() switch () (slightly) to sort the options. NFCI. 2022-06-14 08:06:01 +00:00
kre ee1e729e87 KNF (whitespace & 80 column limits) - NFCI.
This is the first of a series of 5 commits in this
directory, all coming within minutes or now.
2022-06-14 08:05:55 +00:00
nia 402b924225 revert bits and pieces I accidentally included in my last commit
from hannken
2022-06-06 13:28:55 +00:00
nia b7957d1677 build system: Revert all the recent additions of MK[...] knobs that
allow conditionally disabling the building of certain user space
programs in the 'base' set.

There is not enough consensus that this is the right way and a few
people had strong objections, see source-changes-d@.
2022-06-06 10:56:27 +00:00
andvar ff23aff6ad fix various typos in comments, documentation and messages. 2022-05-31 08:43:13 +00:00
andvar 09fb17927e fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
2022-05-28 21:14:56 +00:00
nia cbb875961a mk: Add a MKLFS flag for excluding the log-structured filesystem userspace
tools from the build.
2022-05-27 07:28:20 +00:00
andvar cdc507f0d2 fix various typos in comment, documentation and log messages. 2022-05-24 20:50:17 +00:00
andvar 9f4a9600be fix various typos in comments, docs and log messages. 2022-05-24 06:27:59 +00:00
andvar f42f89fd6f fix various small typos, mainly in comments. 2022-05-22 11:27:33 +00:00
christos 7a3aa8fc03 Use the Makefile.inc from libargon2 (fixes the vax build that requires
a compiler hack).
2022-05-17 18:56:29 +00:00
christos b5df3bed15 make things behave just like before the libcrypt symbol renaming:
The normal cgdconfig binary is built with threads and the crunched one
in rescue without.
2022-05-16 14:57:44 +00:00
christos 0afca0c76d Re-enable threads; apparently we get different results depending if we are
threaded or not... This tastes like a bug.
2022-05-16 10:44:06 +00:00
andvar a5c1e39951 s/wich/which in comments. 2022-05-15 20:37:50 +00:00
christos f3c3951664 Build argon2 inline so that crunched programs work. I also disabled threads
for now; we can put them back if needed.
2022-05-15 19:53:27 +00:00
msaitoh c0c7e2f972 bioctl(8): Don't print garbage bv_seconds.
This bug was added in bioctl.c rev. 1.7.

Before:
Volume Status       Size         Device/Label    Level Stripe
=============================================================
bv_level=5, bv_stripe_size=0
     0 Online       5.5T                 mfi0   RAID 5    64K  65535 seconds

After:
Volume Status       Size         Device/Label    Level Stripe
=============================================================
     0 Online       5.5T                 mfi0   RAID 5    64K
2022-05-10 14:16:25 +00:00
reinoud a72532c0e6 Data is written out in fixed sized packets; discs are normally a multiple of
the packet size but they don't have to be so never write past the last sector.
2022-05-07 08:51:32 +00:00
mrg aaaf76dce5 include the filename in the panic message for missing data.
instead of merely seeing:
	getfile: lost data
now this is seen:
	getfile: lost data: ./usr/libdata/debug/usr/libexec/cc1.debug
2022-05-05 07:45:43 +00:00
reinoud b140a9eb47 Fix endian bug also in commented out code 2022-04-26 15:11:42 +00:00
reinoud daa5db3ac5 Fix endian bug : Logblks recorded in fe/efe VAT is 64 bits 2022-04-26 15:09:52 +00:00
reinoud 823e22a558 Fix endian bug in permission storage 2022-04-26 14:54:40 +00:00
reinoud b9f815db69 Fix endian bug with VAT 1.50 format 2022-04-26 13:40:15 +00:00
reinoud 313c3198fa Fix endian bug in logical volume creation for metadata/VAT partitions. 2022-04-25 20:41:25 +00:00
reinoud ce76bcc2d4 Relax constraints on sequential media detection by checking for VAT format.
This allows fixing images of VAT formatted media too.
2022-04-25 15:37:14 +00:00
reinoud c814daba59 Fix endian bug in descriptor CRC length on updating a FE/EFE 2022-04-25 15:18:15 +00:00
reinoud cb09545664 Fix endian bug in allocation extents processing 2022-04-24 15:07:08 +00:00
hannken 34f99f73c4 Cast read()/write() result to size_t to make this compile again. 2022-04-24 10:35:15 +00:00
mlelstv ab4be66edf Support large disk sectors. 2022-04-23 22:40:28 +00:00
reinoud 0f8e52c944 Fix endian issues with UDF extended attributes 2022-04-22 21:22:14 +00:00
reinoud 628fb0a624 Remove the error condition for these cases; the VAT LVExtension is
missing/corrupt but fsck_udf will reconstruct them anyway.
2022-04-22 21:07:56 +00:00
reinoud 86737809f7 Prevent reading beyond the early_vat_location 2022-04-22 21:00:28 +00:00
reinoud 9b07de2aa1 Fix endian issues with fsck_udf/newfs_udf/makefs 2022-04-22 20:56:46 +00:00
reinoud d77438bc7d Avoid assigned but unused compiler warnings when compiling with clang 2022-04-22 19:21:08 +00:00
andvar f84252b461 fix various typos in comments and log messages. 2022-04-16 18:15:20 +00:00
pgoyette 9724d495e5 iscsid(8) no longer requires scsibus(4) and sd(4) to be built-in to
the kernel.  The scsi_subr module will be loaded if needed to resolve
any dependencies.
2022-04-14 18:52:27 +00:00
andvar bdd61daa31 s/similarily/similarly/ 2022-04-12 20:51:42 +00:00
andvar 75d2abaeb1 fix various typos in comments and output/log messages. 2022-04-10 09:50:44 +00:00
riastradh 272dd0678e fsck_udf(8): Nix trailing whitespace.
No functional change intended.
2022-04-09 09:59:16 +00:00
riastradh 60df76e82b newfs_udf(8): Nix trailing whitespace.
No functional change intended.
2022-04-09 09:58:11 +00:00
riastradh 95e0535276 fsck_udf(8): Mark vat_length as ignored. 2022-04-08 23:48:05 +00:00
riastradh 7274680079 fsck_udf(8): Sprinkle __printflike and omit self-assignment. 2022-04-08 23:47:19 +00:00
andvar 2fa7e14158 fix various typos, mainly in comments, but also log messages, docs, game text. 2022-04-08 10:17:52 +00:00
andvar 2e9df72ec3 fix various typos in comments. 2022-04-07 19:33:37 +00:00
kre 1467a58340 Note that biosboot without -A clears the PMBR "active" flag.
While here, fix some grammar and make the selection options
for biosboot a little clearer.

Ride nia@'s Dd bump.
2022-04-07 13:57:44 +00:00
nia 7a697167f6 gpt.8: Clarify that "windows" partition types are also used for FAT32
("msdos" in NetBSD terms), and UDF partitions. Use the same name as
Wikipedia, "Microsoft basic data".
2022-04-07 09:06:01 +00:00
martin 653864daaf Use PRI macros for uint64_t printf formats, %zu for size_t. 2022-04-06 16:01:06 +00:00
reinoud aaca3d49cd Add the fsck_udf(8) tool to the build and release 2022-04-06 14:20:07 +00:00
wiz 60a361dc89 fsck_udf: match usage to man page; fix typos 2022-04-06 13:42:39 +00:00
wiz 3eb96a9ee8 New sentence, new line. Sort options. 2022-04-06 13:41:13 +00:00
reinoud f41dcb03b1 Initial commit of the fsck_udf(8) utility that checks and repairs UDF
filesystems on optical media as well as on disc images, harddisc partitions
and wedges.
2022-04-06 13:35:50 +00:00
reinoud 8f4e1cd991 Refactor and rewrite of newfs_udf(8) and makefs(8) (-t udf) with a shared
section for fsck_udf(8).

Newfs_udf and makefs support predefined disc image profiles, harddisc
partitions (disklabel and wedges on all generic block devices) and all optical
media types on CD/DVD/BD writers.

Newfs_udf and makefs now also support formatting of UDF 2.50 with a metadata
partition.
2022-04-06 13:29:15 +00:00
andvar e82c4d9bb4 fix various typos, mainly in comments. 2022-04-04 19:33:44 +00:00
mlelstv d6a8de1acc Avoid crashes with invalid or tiny sector sizes. 2022-04-02 19:15:09 +00:00
yamaguchi a5a34c682e Change error code to ENOBUFS on lack of buffer memory
pointed out by k-goda@IIJ
2022-03-31 01:53:22 +00:00
mlelstv a0e4d6d3d7 Silently ignore fstab entries with NAME= entries that cannot be resolved.
Fixes PR 56249.
2022-03-14 18:38:11 +00:00
zafer 7fd3f7926f fix typo 2022-02-27 21:05:11 +00:00
mrg 2104676143 enable blkdiscard(8) build. 2022-02-24 03:35:32 +00:00
andvar 5a1f79d897 remove one whitespace to align report, misalignment occured after typo fix. 2022-02-17 14:33:25 +00:00
andvar 7f4592413f fix various typos, mainly in comments. 2022-02-16 22:00:55 +00:00
andvar 0f1edf6b40 s/Expceted/Expected/ in log message and s/attribtues/attributes/ in comment. 2022-02-12 23:50:14 +00:00
hannken 514b0270dd A component name is a counted string (cn_nameptr, cn_namelen),
not a zero terminated string cn_nameptr.

Change the following operations to work with counted strings:

v7fs_file_lookup_by_name()
v7fs_file_allocate()
v7fs_file_deallocate()
v7fs_directory_add_entry()
v7fs_directory_remove_entry()
v7fs_file_rename()
v7fs_file_link()
v7fs_dirent_filename()

Adapt all vnode operations with component names as argument.
2022-02-11 10:55:15 +00:00
mrg de782e438b convert my fdiscard-stuff.c into blkdiscard.c and give it a UI
that matches the linux-util version.

comes in two forms:  blkdiscard equivalent, and the (almost)
original interface i used (the "-s" option is conflicting and
i've switched to only the not yet implemented secure erase
option.)  the only real difference is that "fdiscard" mode
requires the -R flag to do something, vs blkdiscard needs the
-n flag to not do anything.


not yet hooked into the build or sets.  would like more testing
on it to be performed before doing that (but soon.)
2022-02-07 09:33:26 +00:00
andvar 183889cba7 fix various typos in comments, log messages and documentation.
mainly s/aparently/apparently/ and s/implmented/implemented/.
2022-02-06 20:20:18 +00:00
christos 873fd60810 PR/56643: Paul Goyette: Disable the last block adjustment for now. It seems
to break restore.
2022-01-26 20:22:14 +00:00
andvar 492c086f0a s/begining/beginning/ in comments and messages. 2022-01-24 09:14:36 +00:00
wiz ad6a1e0149 Fix grammar 2022-01-22 09:59:26 +00:00
pho 9f39150738 lib/librefuse: Implement FUSE session API and its signal handling functionality 2022-01-22 07:53:05 +00:00
christos ac31891a27 O_CLOEXEC is not a mode :-) 2022-01-20 14:45:14 +00:00
christos 20f0ca0034 - use /dev/tty instead of stderr for SIGINFO messages
- use uintmax_t instead of ull
- print fractional percentage to show that we are making progress on large
  disks.
2022-01-20 14:44:19 +00:00
mrg da1006fc7e add SIGINFO support. now you can know how far along the scan is. 2022-01-19 01:40:05 +00:00
christos f6c17ff1ea update date 2022-01-17 20:01:43 +00:00
kim f9317bf51a Move the possible optimize_preference values back under the -o flag 2022-01-17 18:03:22 +00:00
bad 83f02db3da mention ifmcstat(8) in SEE ALSO. 2022-01-07 10:17:39 +00:00
msaitoh 988ab2c9fa s/sytem/system/ 2022-01-01 10:32:28 +00:00
christos 962d2193b3 kern.hashstat takes too long and it is meaningless here. 2021-12-28 16:06:57 +00:00