Commit graph

281 commits

Author SHA1 Message Date
Jacob Moody
9e0913fa71 libmemdraw: change openmemsubfont() to accept rune minimum as argument
Subfonts for non ascii characters are offset by some minimum rune,
typically specified within the parent font file.  Because libmemdraw
only deals in subfonts, if we want to have it draw non ascii runes we
need some method of providing that base offset.

This function is only used in one place, so update the function
signature and fix the only caller.
2025-01-03 00:51:43 +00:00
cinap_lenrek
e981a26000 libc: provide netmkaddrbuf() function avoiding the static buffer
We need a reentrant version for netmkaddr() that
can be used in multithreaded programs.
2025-01-02 20:09:50 +00:00
rodri
708ff097a6 libgeometry: add ptincylinder and ptincone 2024-10-14 12:04:35 +00:00
rodri
65ea63e521 libgeometry: add quaternion sandwich product functions
also took the chance to remove the semicolons from
the function signatures in the manpage synopsis, as
is custom in the other manuals.
2024-10-14 11:14:50 +00:00
cinap_lenrek
a97ee572b9 lib9p: add "authok" flag to Srv struct
We want to implement "none" attaches for hjfs,
but only if the 9p-"channel" ran a successfull
authentication before, to prevent anonymous
remote mounts as "none".

Add a flag to the Srv struct for this.
2024-08-24 23:45:51 +00:00
rodri
7059938e94 libgeometry: add lineXsphere function 2024-08-19 21:30:14 +00:00
rodri
9bbbc13ce2 libgeometry: simplify rframes
i got rid of redundant code, and added routines
to get the xform matrix out of an rframe, so it
can be stored and used separately or as part of
a composition of xforms.

also replaced the big example in the man page for
more concise, useful ones.
2024-05-30 21:11:33 +00:00
Sigrid Solveig Haflínudóttir
0d84321e65 libpcm: audio/pcmconv-as-a-library 2024-03-27 23:42:37 +00:00
rodri
e5561c364d libgeometry: add barycentric interpolation routines 2024-03-21 11:38:02 +00:00
Jacob Moody
8a234e57b9 libc, libthread, ape: mark exit functions as _Noreturn and clean up new warnings 2024-01-28 03:36:41 +00:00
rodri
e94d21ee3a libgeometry: add matrix minor and cofactor functions 2023-12-20 11:27:36 +00:00
Jacob Moody
a7a315bff6 libmach: fix dropped header in last commit 2023-09-20 19:31:37 +00:00
cinap_lenrek
38ea1ac105 libbio: bump Bsize to IOUNIT 2023-08-16 23:40:11 +00:00
ori
548f7f971f bio: revert Bsize bump to avoid blowing libthread
libthread stacks are small, and many programs put a
biobuf on the stack; revert the buffer size bump
until this is handled correctly.
2009-01-01 16:43:24 +00:00
Ori Bernstein
b72abe8762 cmd: use increased iounit
add IOUNIT to libc, and replace hard-coded 8k buffers
throughout userspace; this increases the speed for
reading the framebuffer by a factor of at least 3x,
as well as increasing fs performance by a similar
amount, at least on synthetic benchmarks.
2023-08-09 04:17:00 +00:00
cinap_lenrek
09ed7a6e56 libip: Provide iplocalonifc() and ipremoteonifc() functions
These functions are analog to devip's functions
of the same name.

This is mainly to maintain consistent naming...
2023-06-10 18:45:40 +00:00
cinap_lenrek
ed4a0c0642 libndb: add ndbvalfmt() formatter
Some attributes such as vendor and txt require double-quoting
to be parsable by libndb. Provide the fmtinstall(2) formatter
ndbvalfmt for programs outputting ndb(6) format.
2023-05-28 16:09:18 +00:00
Sigrid Solveig Haflínudóttir
6557b0a727 last change did not include the header update 2023-05-18 22:21:14 +00:00
cinap_lenrek
bd43bd6f1a libc: Add poolreset() function
This is intended for the secrmem pool in the kernel,
but could also be used for temporary pools to
recover the memory used by the arenas.
2023-04-08 20:24:44 +00:00
Jacob Moody
04759ec9af runecomp(2) 2023-03-26 01:02:20 +00:00
Jacob Moody
b8ae7708fb ape: add stdnoreturn.h 2023-03-22 04:07:07 +00:00
rodri
a5c6374b77 libgeometry revamp 2023-01-29 23:11:05 +00:00
cinap_lenrek
5a11bcaab0 keyboard.h: comment. 2023-01-06 23:30:04 +00:00
cinap_lenrek
768edd8f21 libsec: fix inconsistent prototypes for des (from drawterm) 2023-01-06 18:57:14 +00:00
cinap_lenrek
916c7f0bd9 keyboard.h: fix misleading comment (F12 is KF|0xC) 2023-01-02 17:54:13 +00:00
Sigrid Solveig Haflínudóttir
b38a3d2a0d nusb/kb, aux/kbdfs: add brightness down/up media keys 2022-10-06 19:45:25 +00:00
Sigrid Solveig Haflínudóttir
d2049c206c aux/kbdfs, nusb/kb: add basic media keys support; add /dev/hidNctl to change repeat/delay; fix a race condition 2022-10-04 23:47:47 +00:00
ori@eigenstate.org
bb2060028e upas/dkim: dkim signing for upas
This change adds support for dkim signing to upas.

It has2 pieces:

1. Adding support for different asn1 formats to auth/rsa2asn1;
   we can now generate SubjectPublicKeyInfo RSA keys, which
   wrap the keys up with an algorithm identifier.
2. Adding a upas/dkim command which filters a message and signs
   it using dkim.

To configure dkim, you need to generate a (small-ish) rsa key;
large keys do not fit into DNS text records:

	# generate the private key and add it to factotum
	ramfs -p
	cd /tmp
	auth/rsagen -b 2048 -t 'service=dkim role=sign hash=sha256 domain=orib.dev owner=*' > dkim.key
	cat dkim.key > factotum.ctl

	# extract the public key, encode it, and strip out the junk
	pubkey=`{
		<dkim.key auth/rsa2asn1 -f spki | \
		auth/pemencode WHATEVER | \
		grep -v 'WHATEVER' | \
		ssam 'x/\n/d'
	}
	domain=example.org
	# then add it to /lib/ndb.local
	echo 'dom=dkim._domainkey.'$domain' soa=
		ip=144.202.1.203
		refresh=600 ttl=600
		ns=ns.orib.dev
		txt="k=rsa; v='$pubkey \
	>> /lib/ndb/local

Then, finally, insert it into your outgoing mail pipeline. One
thing to be careful of is that upas will do some outgoing 'From:'
rewriting, so you may need to make sure that either '$upasname'
is set, or 'upas/dkim' is inserted after the rewrite stage.
A good place is in /mail/lib/qmail, in place of upas/vf:

	% cat /mail/lib/qmail
	rfork s
	upas/dkim -d example.com | upas/qer /mail/queue mail $* || exit 'qer failed'
	upas/runq -n 10 /mail/queue /mail/lib/remotemail </dev/null >/dev/null >[2=1] &
2022-06-24 00:08:34 +00:00
Ori Bernstein
7ca997bf7e ndb: increase buffer size to allow longer lines
when reading a long line such as a dkim key in a
txt record, ndb calls Brdstr, which is limited
to the size of the buffer. This means we would
fail to parse the line from NDB, and bail out
early.

Increasing the buffer size allows us to read and
parse longer lines.
2022-06-19 23:42:04 +00:00
cinap_lenrek
1a90e04c05 ape: export mktemp() in <stdlib.h> when _BSD_SOURCE is set 2022-01-03 18:49:40 +00:00
Ori Bernstein
7efbea82c6 devssl, cpu, import, oexportfs: delete
SSL is implemented by devssl. It's extremely
obsolete by now, and is not used anywhere but
cpu, import, and oexportfs.

This change strips out the devssl bits, but
does not (yet) remove the code from libsec.
2021-12-13 02:17:02 +00:00
cinap_lenrek
2899b719ae libndb: move mkptrname() into libndb to avoid duplication 2021-11-03 19:38:36 +00:00
Noam Preil
2eadf1fa17 venti: fix memory layers 2021-07-21 05:06:05 +00:00
Ori Bernstein
a05d656054 qsort: ...forgot to include headers in the commit. 2021-08-11 13:10:14 +00:00
cinap_lenrek
1ec44ec77c libc: use usize for sbrk() increment 2021-07-25 16:03:14 +00:00
cinap_lenrek
e4b5f170cf libc: change usize to 64-bit for amd64 and arm64, make memory(2) functions use usize 2021-07-25 15:54:22 +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
8ec50b87d5 thread.h: threadnonotes does not exist 2021-06-20 14:55:13 +00:00
cinap_lenrek
57d95c7325 libsec: move zero check to curve25519_dh_finish()
As checking for all zero has to be done in a timing-safe
way to avoid a side channel, it is best todo this here
instead of letting the caller deal with it.

This adds a return type of int to curve25519_dh_finish()
where returning 0 means we got a all zero shared key.

RFC7748 states:

The check for the all-zero value results from the fact
that the X25519 function produces that value if it
operates on an input corresponding to a point with small
order, where the order divides the cofactor of the curve.
2021-06-20 14:41:26 +00: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
Ori Bernstein
6445a14f63 ape/lib9: expose fd2path (thanks phil9)
Fd2path is a useful call for the netsurf plan9 frontend,
so we should expose it.
2021-02-20 21:02:07 -08:00
Ori Bernstein
bb250c4c3b ape/libm: implement log2 in libc 2021-01-30 09:19:57 -08:00
Michael Forney
988bdd05a3 [9front] ape: remove _SUSV2_SOURCE guard from inttypes.h
inttypes.h was added to C99, and this is the only header that used
_SUSV2_SOURCE.

Also, remove now unneeded _SUSV2_SOURCE from python mkfile.
2021-01-23 19:47:12 -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
92d3abd818 ape: unify math.h copies
/$objtype/include/ape/math.h contained an almost
identical copy of math.h for each architecture.

The only difference between them architectures
was that some had an incorrect version of isinf
defined.

This change picks one of the versions of math.h
with a correct definition, moves it to /sys/include,
and removes the redundant versions.
2021-01-01 21:40:00 -08: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
Ori Bernstein
658c1b9f68 libap: add strndup
strndup is part of POSIX.1, so APE should provide it.
This patch adds it, so need to patch it out of fewer
programs going forward.
2020-12-17 19:20:04 -08: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