roken: Add rk_undumptext() and support ttys and such

Add rk_undumptext(), which NUL-terminates the contents it reads.

rk_undumptext(), and now also rk_undumpdata(), can read from regular and
non-regular files (e.g., ttys, pipes, devices, but -on Windows- not
sockets).

This means that `asn1_print` can now read from `/dev/stdin`, which can
be a pipe.

There's a way to set a limit on how much to read from non-regular files,
and that limit defaults to 10MB.

At any rate, the rk_dumpdata(), rk_undumpdata(), and rk_undumptext() functions
really do not belong in lib/roken but in lib/base.  There are other utility
functions in lib/roken that don't belong there too.  A rationalization of the
split between lib/roken and lib/base is overdue.  And while we're at it -lest I
forget- it'd be nice to move all the krb5_storage functions out of lib/krb5 and
into lib/base, as those could come in handy for, e.g., implementing OpenSSH
style certificates and other things outside the krb5 universe.
This commit is contained in:
Nicolas Williams
2022-12-20 22:22:06 -06:00
parent ca2467a4c4
commit 8b6926f4c0
3 changed files with 149 additions and 1 deletions

View File

@@ -171,6 +171,7 @@ HEIMDAL_ROKEN_2.0 {
rk_tsearch;
rk_twalk;
rk_undumpdata;
rk_undumptext;
rk_unparse_flags;
rk_unparse_time;
rk_unparse_time_approx;