summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
16 hoursfix variable nameLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
16 hoursutil/nvmutil: re-add fallback timer randLeah Rowe
for 1989 enabled via ifdef. not enabled by default. Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/nvmutil: remove arandom fallback on randLeah Rowe
openbsd 2.1 has arc4random, which we detect here. arandom was apparently added much later, so this is dead code. remove it. Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/nvmutil: rand: use getrandom on newer linuxLeah Rowe
we still fall back to the old /dev/urandom read on older linux, via runtime detection (ENOSYS). getrandom is better, because it guarantees entropy via blocking, and works even when /dev/urandom is unavailable. it has the same practical benefit as arc4random, which i use on bsd. linux can have arc4random, but not every linux libc has it, so it's better to use getrandom on linux. older linux will fall back to /dev/urandom Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/nvmutil: buffered urandom readsLeah Rowe
also generally tidied the code and made it more robust e.g. retries Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hourstidy some commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
26 hoursnvmutil: make tmpdir string much more randomLeah Rowe
more random characters i added support for higher than the standard 6 characters so i can go nuts XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Signed-off-by: Leah Rowe <leah@libreboot.org>
26 hoursutil/nvmutil: hardened mkstempLeah Rowe
200 retries, not 100. and open with O_NOFOLLOW and O_CLOEXEC check X on mkstemp support more than 6 X in mkstemp make PATH_LEN 4096 1024 is a bit low make default mkstemp length 4096 Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursnvmutil: rename lseek_loop to lseek_on_eintrLeah Rowe
that's what it does! Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursnvmutil: rename x_i_close to close_on_eintrLeah Rowe
that's what it does. waits for eintr to stop firing Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursnvmutil: don't have finite eintr waitLeah Rowe
this is technically incorrect. we don't control faults in the hardware. Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursnvmutil: rename x_i_fsync to fsync_on_eintrLeah Rowe
that's what it does. waits on eintr. Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/rename: rename x_i_fsyncLeah Rowe
rename to fsync_on_eintr, because that's what it does Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursnvmutil: remove memcmp/memcpy/strrchr/renameLeah Rowe
i had this idea in my head of later porting this to k&r c for fun. but screw it. compiling on everything since 1989 is enough Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: tidy up includesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/nvmutil: major cleanupLeah Rowe
handle init in xstatus() it's now a singleton design also tidied up some other code also removed todo.c. bloat. will do all those anyway. too much change. i just kept touching the code until it looked good Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursnow remove the .empty filesLeah Rowe
but git still has these directories in history now, so people should have it now when cloning. Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: add obj dir to gitLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: add rule to create lib objdirLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursnvmutil: move lib files to lib/Leah Rowe
only keep nvmutil.c in main Signed-off-by: Leah Rowe <leah@libreboot.org>
45 hoursutil/nvmutil: put objects in obj/Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
46 hoursnvmutil makefile: use portable assignmentsLeah Rowe
question mark respects environmental variables but isn't portable you can just pass as argument on the command line question mark is more useful for build systems, but i'm not really bothered. the old way works. Signed-off-by: Leah Rowe <leah@libreboot.org>
46 hoursnvmutil: split nvmutil.c into multiple filesLeah Rowe
this is a big program now. act like it. Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: remove global variable xLeah Rowe
make a singleton function instead now there are technically no global variables, so i can more easily start splitting this up into multiple linked programs Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: disable arc4random on obsd below 2.1Leah Rowe
arc4random added in openbsd 2,1 Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: initialise st in tmpdirLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: use strlen for tmpdir lengthLeah Rowe
sizeof includes the null Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil tmpdir: check world-writeable / sticky bitsLeah Rowe
must be world writeable and not have sticky bits a bit theoretical, but we're also reading TMPDIR, which could be anything due to how this is called, it defaults back to /tmp if null is returned, so itt's safe Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: fix modulo bias in mkstempLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: limit EAGAIN/EINTR retriesLeah Rowe
set it really high though, so it's still basically reliably an EINTR/EAGAIN storm could cause problems in prw() Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: use real fsyncLeah Rowe
that function i added was a load of crap. it worked, but it was a bit dumb, and crap. Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: don't disable blocking on randomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysre-add arc4random in nvmutilLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: remove randomness fallbackLeah Rowe
not secure. i'll just re-add arc4random and use urandom as the fallback Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: don't read urandom fd if fd not openLeah Rowe
yeah. obvious bug Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: new urandom fd every time (rlong)Leah Rowe
otherwise, a stale descriptor could be manipulated easily by an attacker over time very theoretical to be honest Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: fix typo in unveil callLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: fix rlong static variablesLeah Rowe
whoops Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: remove redundant srand callLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: remove redundant checkLeah Rowe
the actual cat function just writes to stdout we need only check that the input is null, which i've now done. Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: obsessively check null cmdLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: tidy up variablesLeah Rowe
where feasible, don't assign them at declaration this is especially important for the next change i'm working on Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysstricter S_ISREG checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: even stronger double-run protectionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysutil/nvmutil: guard against running twiceLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2 daysnvmutil: make commands check themselvesLeah Rowe
check yourself before you execute yourself Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: check file flags properlyLeah Rowe
masking O_ACCMODE tells you which flag it is Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: tighter pledge and unveilLeah Rowe
call it sooner. set new_state afterward. i had to uncouple nv from some functions for this, and i also added some extra checks especially at exit, about whether to touch nv (whether it is initialised) Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: stricter work buf checkLeah Rowe
check it right after initialisation Signed-off-by: Leah Rowe <leah@libreboot.org>
3 days79-character rule must be obeyedLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>