Commit graph

248 commits

Author SHA1 Message Date
kvik 431dbabcc1 graphics(2): fix typo 2021-07-14 20:38:12 +00:00
Jacob Moody 5a23b752eb strcat(2): 0 → nil in manpage in refrence to pointers 2021-07-12 21:42:39 +00:00
cinap_lenrek 88060e7501 libsec: add X509reqtoRSApub() function and return subject alt names in X509to*pub() name buffer
We need a way to parse a rsa certificate request and return the public
key and subject names. The new function X509reqtoRSApub() works the
same way as X509toRSApub() but on a certificate request.

We also need to support certificates that are valid for multiple domain
names (as tlshand does not support certificate selection). For this
reason, a comma separated list is returned as the certificate subject,
making it symmetric to X509rsareq() handling.

A little helper is provided with this change (auth/x5092pub) that takes
a certificate (or a certificate request when -r flag is provided) and
outputs the RSA public key in plan 9 format appended with the subject
attribute.
2021-07-04 22:00:24 +00:00
Ori Bernstein e934530ee4 libc: add encode(2) variants for custom alphabets
There are a number of alphabets in common use for base32
and base64 encoding, such as url-safe encodings.

This adds support for passing a function to encode into
arbitary alphabets.
2021-07-03 20:03:17 +00:00
Sigrid Solveig Haflínudóttir e390486e92 tmdate(2): "ttt" is a valid format too, mention it 2021-06-23 08:07:16 +00:00
Jacob Moody 370ef39bf9 lib9p: add auth* functions to man page 2021-06-12 23:12:41 +00:00
Ori Bernstein 2321062d2f 9pfid(2): document Srv* in Req (thanks kjn)
This struct member is available for any user of
the library, and is not part of our internal API.
It should be documented.
2021-05-17 09:17:22 -07:00
cinap_lenrek 013b2cad19 memory(2): mention tsmemcmp (thanks kemal) 2021-05-15 12:40:11 +02:00
cinap_lenrek ee289c2415 lib9p: remove Srv.srvfd, make postsrv() and threadpostsrv() return the mountable file descriptor, update documentation
Now that we have these new functions,
we can also make them return an error
instead of calling sysfatal() like
postmountsrv().

Remove the confusing Srv.srvfd, as it
is only temporarily used and return
it from postsrv() instead.
2021-05-01 19:58:58 +02:00
cinap_lenrek f6509078ed lib9p: expose Srv.forker handler and srvforker(), threadsrvforker() and threadsrv() functions
To use srvrease()/srvaquire() we need to have a way to spawn
new processes to handle the service loop. This functionality
was provided by the internal _forker() function which was
eigther rfork or libthread based implementation depending on
if postmountsrv() or threadpostmountsrv() where called.

For servers who want to use srv() directly, _forker would not
be initialized so srvrelease() could not be used.

To untangle this, we get rid of the global _forker handler
and put the handler in the Srv structure. Which will get
initialized (when nil) to eigther srvforker() or threadsrvforker()
depending on if the thread or non-thread entry points where used.

For symmetry, we provde new threadsrv() and threadpostsrv()
functions which handle the default initialization of Srv.forker.

This also allows a user to provide his own forker function,
maybe to conserve stack space.

To avoid dead code, we put each of these function in their
own object file. Note, this also allows a user to define its
own srvforker() symbol.
2021-05-01 16:37:00 +02:00
qwx c3593c1a7a opl3(1), exec(2): fix manpage typos (thanks umbraticus) 2021-04-27 16:08:06 +02:00
Romano aebdf1010b minor man page typos 2021-04-08 21:42:31 +02:00
kvik bc1cc79225 libstdio: sync bits of vfprintf from APE
* Add the %ll length modifier,
* Convert nil to "<nil>" under %s (not in APE),
* Cast void* to uintptr under %p,
* Use "0x" hex prefix under %p,
* Fix manual page mentions of %P to %p,
* Fix empty result for fp conversions,
* Fix zero padding of left-aligned fp conversions,
* Remove deprecated #pragma ref uses.

Most of these were introduced in APE prior to 9front.

I've omitted the %z conversion specifier since Plan 9 code
rarely uses the usize type. This may need to be added later
for the benefit of native ports of alien code.
2021-02-19 23:04:09 +01:00
kvik 1ce6f0f2ab nan(2): document isInf(x, 0) matching +∞ and -∞ 2021-02-18 21:40:30 +01:00
Ori Bernstein e2e973a34b tmdate(2): correct example in manpage
add missing tmdate() call around %τ format.
2021-01-16 14:24:32 -08:00
Ori Bernstein c207b78d07 libdraw: add bezierpts
This patch exposes the bezierpts function,
providing a way to get the points on a path,
similar how bezsplinepts gives them for b
splines.
2021-01-09 12:20:49 -08:00
Ori Bernstein dda99bbfe5 9pfid(2): document struct Qid (thanks sirjofri)
The Qid struct is pervasive when writing 9p servers,
but is not described in the manpages. This adds a
definition to the 9pfid manpage.
2021-01-06 10:07:10 -08:00
cinap_lenrek dced7255ec libc: re-implement getuser() by stating /proc/$pid/status
The idea is to avoid the magic files that contain
per process information in devcons when possible.
It will make it easier to deprecate them in the future.
2020-12-23 02:31:28 +01:00
cinap_lenrek fc5070c600 libauth: add procsetuser() function to change user id of the calling process
Provide a central function to change the user id
of the calling process.

This is mostly used by programs to become the none
user, followed by a call to newns().
2020-12-19 17:46:55 +01:00
cinap_lenrek 672cf179a1 libc: implement getppid() reading /proc/$pid/ppid instead of /dev/ppid
The devcons driver is really the wrong place to
serve per process information.
2020-12-19 15:15:38 +01:00
cinap_lenrek 0b33b3b8ad kernel: implement per file descriptor OCEXEC flag, reject ORCLOSE when opening /fd, /srv and /shr
The OCEXEC flag used to be maintained per channel,
making it shared between all the file desciptors.

This has a unexpected side effects with regard to
channel passing drivers such as devdup (/fd),
devsrv (/srv) and devshr (/shr).

For example, opening a /srv file with OCEXEC
makes it impossible to be remounted by exportfs
as it internally does a exec() to mount and
re-export it. There is no way to reset the flag.

This change makes the OCEXEC flag per file descriptor,
so a open with the OCEXEC flag only affects the fd
group of the calling process, and not the channel
itself.

On rfork(RFFDG), the per file descriptor flags get
copied.

On dup(), the per file descriptor flags are reset.

The second modification is that /fd, /srv and /shr
should reject the ORCLOSE flag, as the files that
are returned have already been opend.
2020-12-13 16:04:09 +01:00
Ori Bernstein 07e8c324a8 tmdate(2): remove lies
Initially the code tried to guess the date format. This
turned out to be a bit too magical, so the feature was
removed, but the manpage still documented the nonfeature.
2020-11-30 07:41:49 -08:00
Sigrid 808acd51f4 tmdate(2): failed to (p)arse 2020-11-18 20:14:26 +01:00
Sigrid 23620bb1db ctime(2): add tmdate(2) to "see also" 2020-11-18 20:11:55 +01:00
Ori Bernstein dbd54342fd libbio: add aux pointer to bio
This allows us to attach additional context
to the biobuf so can read from some sort of
data structure without a global variable.
2020-11-01 11:42:54 -08:00
Ori Bernstein 9bb519ac50 mp(2): correct documentation of error handling (thanks LordCreepity)
The documentation for mp(2) claimed we'd return nil on error, when
we actually sysfatal. This corrects the documentation to match our
actual behavior.
2020-10-24 17:24:59 -07:00
Ori Bernstein 9afa5550f7 tmdate(1): fix missing arg, fix formatting (thanks joe9) 2020-09-25 21:22:47 -07:00
Ori Bernstein eb6b1e672c merge 2020-09-25 16:51:08 -07:00
Ori Bernstein 022bc980b8 tmdate(2): fix mistakes in prototype (thanks moody) 2020-09-25 16:32:32 -07:00
Ori Bernstein 9f8d62ab64 libc: ignore '?' in date format strings
Ignoring '?' when formatting date strings allows
the format strings to be reused for parsing. This
is convenient, since we don't need to duplicate
the format strings.
2020-09-22 19:24:01 -07:00
Ori Bernstein 26cf6ec073 tmdate(1): document tz field 2020-09-12 17:36:14 -07:00
Ori Bernstein 732082c095 ctime(2), tmdate(2): document ctime/tmparse incompatibility
Tmparse and ctime don't mix. The timezone name may be
too long for the number of characters ctime mandates.
Document this footgun.
2020-09-10 16:26:42 -07:00
Ori Bernstein 703b0d3e6d tmdate(2): one more typo
no more top arse. only bottom arse.
2020-09-07 19:32:50 -07:00
Ori Bernstein ce5b6036f0 tmdate(2): fix examples, stale references (thanks deuteron)
There were a number of ideas that were tried out as the tmdate
api evolved. As a result, there were some references in the
manpage to things that are no more.

Fix them.
2020-09-07 19:28:30 -07:00
Ori Bernstein 4a1186ddfe tmdate(2): fix name of tm struct
There was a leftover from when this library was separate
with different types.
2020-09-07 18:49:00 -07:00
Ori Bernstein f444d6c3f2 tmparse: put in local timezone hack
Ctime is defined as printing a 3-character timezone
name. The timezone name is ambiguous. For example,
EST refers to both Australian and American eastern
time. On top of that, we don't want to make the
tzabbrev table exhaustive. So, we put in this hack:

Before we consult the well known table of timezones,
we check if the local time matches the timezone name.

On top of that, tm2sec

If you want unambiguous timezone parsing, use numeric
timezone offsets (Z, ZZ formats).
2020-09-01 19:32:45 -07:00
Ori Bernstein 17abfa51ca libc: tmparse should ignore leading whitespace
We almost always want to skip leading whitespace in time
formats, so make tmparse just do it. This fixes upas mbox
parsing, which leaves a leading whitespace at the start of
the date.
2020-08-26 10:23:00 -07:00
Alex Musolino 8727bfd9bd getwd(2): add reference to chdir(2) in SEE ALSO section 2020-08-25 20:51:38 +09:30
Alex Musolino 6fe18e7c7b chdir(2): add reference to getwd(2) in SEE ALSO section 2020-08-25 20:51:24 +09:30
Ori Bernstein 69c3c0e6f0 tmdate(2): fix typo (thanks mveety)
sysfata => sysfatal
2020-08-10 20:33:39 -07:00
Ori Bernstein 56e869ac70 libc: new date apis
The current date and time APIs on Plan 9 are not good. They're
inflexible, non-threadsafe, and don't expose timezone information.

This commit adds new time APIs that allow parsing arbitrary
dates, work from multiple threads, and can handle timezones
effectively.
2020-08-09 18:58:44 -07:00
kvik 359362395f graphics(2): fix typo 2020-06-28 23:45:18 +02:00
kvik f0ea4af5ef 9p(2): fix typo 2020-06-25 23:23:23 +02:00
cinap_lenrek febe84af75 libc: revert date change again. this is getting ridicuoulus.
this breaks the sample from the seconds manpage, and overall
produces funky results. this needs alot more testing.

term% seconds '23 may 2011'
seconds: tmparse: invalid date 23 may 2011 near 'may 2011'

term% seconds '2019-01-01 00:00:00'
-118370073600
2020-06-15 00:12:57 +02:00
Ori Bernstein 8b3efcfc4e libc, seconds: new time and date apis (try 2)
Redo date handling in libc almost entirely. This allows
handling dates and times from outside your timezones,
fixes timezone loading in multithreaded applications,
and allows parsing and formatting using custom format
strings.

As a test of the APIs, we replace the formatting code in
seconds(1), shrinking it massively.

The last commit missed a few removals, and made it
unnecessarily hard to do an update.
2020-06-14 09:33:32 -07:00
cinap_lenrek f380851ddb libc: reverting previous change until ori can fix it 2020-06-14 04:47:22 +02:00
Ori Bernstein e2ee991490 libc, seconds: new time and date apis.
Redo date handling in libc almost entirely. This allows
handling dates and times from outside your timezones,
fixes timezone loading in multithreaded applications,
and allows parsing and formatting using custom format
strings.

As a test of the APIs, we replace the formatting code in
seconds(1), shrinking it massively.
2020-06-13 12:38:49 -07:00
Alex Musolino a3f6976a76 notify(2): fix typo 2020-04-07 12:14:12 +09:30
Ori Bernstein 8589a591de we prefer nil over 0, make the example show it. 2020-03-28 20:32:53 -07:00
cinap_lenrek e9e55a21f6 lib9p: implement automatic remove-on-close cleanup in postsharesrv(), remove postfd() and sharefd() functions
with the latest changes to shr(3), we can use ORCLOSE on
the control file to get the mount in the share automatically
removed when the server exits or something goes wrong during
postsharesrv().

do not expose postfd() and sharefd() functions. they where
undocumented and leak the control file descriptors.
2020-03-08 22:00:23 +01:00