Commit graph

7037 commits

Author SHA1 Message Date
cinap_lenrek 55a0abdd43 auth/as: fix wrong filesystem permissions due to wrong factotum being attached
to change user, have to (re-)mount factotum under the new user,
so it can authenticate us under the correct user for the filesystems.
2022-04-04 22:25:08 +00:00
cinap_lenrek 90a08cf1fd vncv: some fixes to work with intel amt kvm 2022-04-03 04:23:25 +00:00
cinap_lenrek 1a4e03cf93 ip/sol: kvm (vnc) redirect, bring back plain authentication as a fallback (when unsupported) 2022-04-03 04:19:46 +00:00
cinap_lenrek 8597051d64 uartpci: AMT SOL Redirection interface (x200s) 2022-04-03 04:06:27 +00:00
cinap_lenrek 31294b6c1a ip/sol: use httpdigest authentication
httpdigest authentication allows one to share the key
in factotum with the amt webserver on https://target:16993
2022-04-02 21:47:00 +00:00
cinap_lenrek fc0eee2980 webfs: do not reuse digest Authorization headers
We must use the digest authorization header only
once for a single request.
2022-04-02 20:29:20 +00:00
cinap_lenrek 8166868375 webfs: implement RFC2617 qop extension for http digest authentication 2022-04-02 19:20:56 +00:00
Sigrid Solveig Haflínudóttir 945fef7ff2 devdraw: printmesg: implement "z" fmt arg (safe since printmesg is disabled) 2022-04-02 11:12:12 +00:00
cinap_lenrek ca60e03c5b ip/sol: add intel AMT serial-over-lan console program 2022-04-01 21:24:42 +00:00
Sigrid Solveig Haflínudóttir 5ddff68167 libtags: m4a: do not div by zero 2022-03-30 20:55:33 +00:00
Sigrid Solveig Haflínudóttir cb4d441cb8 libtags: wav: do not div by zero (fixup) 2022-03-30 20:54:11 +00:00
Sigrid Solveig Haflínudóttir 2cdd31f8f4 libtags: wav: do not div by zero 2022-03-30 20:51:03 +00:00
Sigrid Solveig Haflínudóttir 7f2e622965 libtags: id3v2: make sure extra id3 tag does not cause infinite loop 2022-03-30 20:28:03 +00:00
cinap_lenrek f05b8af71e devsd: cache SDunit pointer in Chan.aux, improve error handling
Avoid calling sdgetdev() for every I/O. Instead,
put the SDunit pointer for #S/sdXX/* files in Chan.aux
and keep a reference to SDev between sdopen()/sdclose().

This avoids having to do the sdindex() lookup and
qlock(),incref(),decref() on every read/write
operation. Removal of SDev's is quite rare and only
can happen with pcmcia ide controllers, and i assume
that for that we can assume thet fileservers having
been exited properly and closed their files before
we attempt to remove a device.

The rest is improving waserror() codepaths, making
sure we release the locks for any of the interface
callbacks (verify/online).

Also get rid of tas() and instead only change the
unit's rawopen flag while holding raw qlock.
2022-03-30 19:23:26 +00:00
Sigrid Solveig Haflínudóttir 12802b94c6 libtags: flac: check sample rate before dividing by zero; also check number of channels 2022-03-30 16:59:35 +00:00
Sigrid Solveig Haflínudóttir bc5b0254d0 pc: do not access out of bounds array element 2022-03-28 17:23:04 +00:00
cinap_lenrek 89ae389eb6 libsec: fix wrong tls1.0 prf regression
The change 775a4bea43
"libsec: various changes to tls"
...
4. simply prf code...

... broke the TLS1.0 prf function, missing the fact
that the prf ouput for sha1 and md5 need to be
xored together.
2022-03-27 20:28:41 +00:00
cinap_lenrek 00542efd15 devuart: allow serial console on late detected uarts
pci uarts are detected late and usually do not contain
the console= parameter logic.

for these, we can just enable them when devuart is reset,
and replay the boot messages once enabled.

this is usefull as it allows us to use these uarts for
kernel debugging in interrupt context.
2022-03-19 15:53:40 +00:00
Michael Forney 27fe8ee356 games/gb: minor style fixes 2022-03-18 17:32:11 -07:00
Michael Forney d5368b0799 games/gb: various RTC fixes
MBC3 write switches on a>>13, so the RTC register is 5 (0xA000-0xBFFF).

Mask off upper bits of DH register when updating the timer. Only the
lowest bit is part of the day counter.

Use uint for x in timerforward() so that we don't set negative values
for timer registers if it happens to overflow.

Update timer and then latch rather than the other way around.
Otherwise, timer remains static and will overflow after 512 days.
2022-03-18 17:25:43 -07:00
Michael Forney 638b82129e git/fetch: use read for reading packfiles instead of readn 2022-03-18 23:45:43 +00:00
cinap_lenrek 02d1725d71 uartpci: add serial-over-lan uart from x230/AMT 2022-03-18 20:18:19 +00:00
cinap_lenrek e83917a658 ip/dhcpd: ignore ipv6 addresses when looking up static binding 2022-03-18 19:54:23 +00:00
cinap_lenrek 488f378470 sdide: add pci id for AMT IDE-r controller on x230 2022-03-18 19:53:11 +00:00
Michael Forney d55a64c905 git: use commit date as traversal hint instead of author date
Although git9 always uses the same commit date and author date, other
implementation do make a distinction.  Since commit date is more
representative of the commit graph order, use this as a traversal hint
instead of author date.
2022-03-17 01:41:44 +00:00
Michael Forney 8bd5be7c70 git/fetch: improve detection of dumb http protocol
If the server only supports the dumb protocol, the first 4 bytes of
response will be the initial part of the hash of the first ref.

The http-protocol documentation says that we should fall back to the
dumb protocol when we don't see a content-type of
application/x-$servicename-advertisement.  Check this before
attempting to read a smart git packet.
2022-03-17 01:41:09 +00:00
Michael Forney 2e47badb88 git/query: refactor graph painting algorithm (findtwixt, lca)
We now keep track of 3 sets during traversal:
- keep: commits we've reached from head commits
- drop: commits we've reached from tail commits
- skip: ancestors of commits in both 'keep' and 'drop'

Commits in 'keep' and/or 'drop' may be added later to the 'skip' set
if we discover later that they are part of a common subgraph of the
head and tail commits.

From these sets we can calculate the commits we are interested in:
lca commits are those in 'keep' and 'drop', but not in 'skip'.
findtwixt commits are those in 'keep', but not in 'drop' or 'skip'.

The "LCA" commit returned is a common ancestor such that there are no
other common ancestors that can reach that commit.  Although there can
be multiple commits that meet this criteria, where one is technically
lower on the commit-graph than the other, these cases only happen in
complex merge arrangements and any choice is likely a decent merge
base.

Repainting is now done in paint() directly.  When we find a boundary
commit, we switch our paint color to 'skip'.  'skip' painting does
not stop when it hits another color; we continue until we are left
with only 'skip' commits on the queue.

This fixes several mishandled cases in the current algorithm:
1. If we hit the common subgraph from tail commits first (if the tail
   commit was newer than the head commit), we ended up traversing the
   entire commit graph.  This is because we couldn't distinguish
   between 'drop' commits that were part of the common subgraph, and
   those that were still looking for it.
2. If we traversed through an initial part of the common subgraph from
   head commits before reaching it from tail commits, these commits
   were returned from findtwixt even though they were also reachable
   from tail commits.
3. In the same case as 2, we might end up choosing an incorrect
   commit as the LCA, which is an ancestor of the real LCA.
2022-03-16 21:41:59 +00:00
Igor Böhm 873f381e29 acme: fix hiding of top windows when loading a dump file (thanks Xiao-Yong)
When loading an acme dump file that contains a window with only one
tag line, there are cases where acme hides that window (i.e.  not even
its tag is visible).

The following commands reproduce the issue:

 % ed <<EOE
1
i
/tmp
/lib/font/bit/pelm/unicode.8.font
/lib/font/bit/pelm/unicode.8.font
          0
f          0           5         175         175           1
          5          40         175           1           0 /sys/src/cmd/acme/ Del Snarf Get | Look
f          0           4         330         330           3
          4          27         330           1           0 /tmp/ Del Snarf Get | Look
.
,w /tmp/test.dump
Q
EOE
 % window -dx 900 -dy 600  'acme -l /tmp/test.dump'

This issue was introduced in commit 47b7dc5ccd.
2022-03-15 10:49:00 +00:00
cinap_lenrek ca313087c1 ip(3): use flags instead of tag for 8 column route add/remove
This avoids ipconfig having to explicitely specify the tag
when we want to set route type, as the tag can be provided
implicitely thru the "tag" command.
2022-03-14 18:45:27 +00:00
cinap_lenrek d4e89fe76a ape: fix wrong write size for _assert() 2022-03-14 11:16:11 +00:00
cinap_lenrek 263251da75 ip/dhcpd: ignore icmp advice
should ignore advice as we are handling all connections
thru a single udp connection.
2022-03-13 20:43:16 +00:00
cinap_lenrek c8507f428f ipconfig(8): add -t flag to enable source address translation 2022-03-13 17:29:16 +00:00
cinap_lenrek 6e4a1fda8c devip: allow setting the "trans" flag on a logical interface
This makes the interface route have the "t"-flag,
which causes packets routed to the interface to get
source translated.
2022-03-13 17:16:54 +00:00
cinap_lenrek d2a7d88662 devip: implement network address translation routes
This adds a new route "t"-flag that enables network address translation,
replacing the source address (and local port) of a forwarded packet to
one of the outgoing interface.

The state for a translation is kept in a new Translation structure,
which contains two Iphash entries, so it can be inserted into the
per protocol 4-tuple hash table, requiering no extra lookups.

Translations have a low overhead (~200 bytes on amd64),
so we can have many of them. They get reused after 5 minutes
of inactivity or when the per protocol limit of 1000 entries
is reached (then the one with longest inactivity is reused).

The protocol needs to export a "forward" function that is responsible
for modifying the forwarded packet, and then handle translations in
its input function for iphash hits with Iphash.trans != 0.

This patch also fixes a few minor things found during development:

- Include the Iphash in the Conv structure, avoiding estra malloc
- Fix ttl exceeded check (ttl < 1 -> ttl <= 1)
- Router should not reply with ttl exceeded for multicast flows
- Extra checks for icmp advice to avoid protocol confusions.
2022-03-12 20:53:17 +00:00
cinap_lenrek c14ea9fdd1 awk: fix off-by-one string buffer overflow from gsub
the bug happens when we did the fast exit thru "done" label,
where we would not make sure that theres space in the buffer
for the NUL terminator.

instead, avoid the fast exit and always do the final
adjbuf() that makes sure we have space for the NUL terminator.

remove the pointless pb checks, they'r wrong (should'v
been bp >= buf+bufsz) and adjbuf() already makes sure this
can never happen.
2022-03-12 12:29:15 +00:00
Alex Musolino af6f03e528 hjfs: fix group ownership of home dirs created by newuser command 2022-03-08 13:25:52 +00:00
Michael Forney 0f890140f2 igfx: fix some typos in comments 2022-03-05 01:06:20 +00:00
Michael Forney d52f25ecdc igfx: add TypeILK, since it differs slightly from SNB
ILK's LVDS transcoder select field only has 1 bit, like G45.
2022-03-02 10:26:37 +00:00
Michael Forney a00957efee igfx: maintain single/double-channel LVDS mode from BIOS 2022-03-02 10:26:36 +00:00
Michael Forney 79c7e4514d igfx: fix FDI link training on ironlake
Ironlake uses bits 29:28 in the RX control register to select the
training pattern.
2022-03-02 10:26:38 +00:00
cinap_lenrek 9c02337fc3 merge 2022-03-02 18:54:36 +00:00
Michael Forney 954f9f1fcf aux/vga: return modes according to EDID timing priority order
EDID 1.3 section 5 gives a table describing the priority order of
timing information. Use this ordering when constructing the EDID
mode list.

Since aux/vga selects the first mode in the modelist that matches
the given size, it will now select the mode of that size with the
highest preference. Or, if you set vgasize=auto (or some other
string without an 'x'), aux/vga will select the Preferred Detailed
Timing.

This should make it unnecessary to modify vgadb in many cases.
2022-02-28 21:20:52 +00:00
cinap_lenrek d082a8972f ether82563: add pci id for ethernet on dell optiplex 7090 micro (thanks leimy)
0.31.6: net  02.00.00 8086/15f9 255 0:70900000 131072
         Intel Corporation
2022-02-28 13:18:13 +00:00
cinap_lenrek 5886b999d5 devbridge: fix vlan range parsing 2022-02-27 13:32:58 +00:00
Ori Bernstein 840d16912a git/revert: update modification time on revert
when reverting files, 'cp -x' updates the mtime
to the time the file was committed. this prevents
'mk' from rebuilding the file, leading to stale
builds.

this change touches the file on revert, so that
we rebuild the file.
2022-02-27 04:27:56 +00:00
cinap_lenrek fd1cfc824a snoopy: add vlan protocol (802.1q) 2022-02-27 03:33:01 +00:00
cinap_lenrek 9944e16b16 devbridge: improve locking, unbind ports automatically on read error and more...
Use an RWlock so readers can work in parallel in
the common case (no cache updates).

When a reader needs to update the cache to add
a new learned source mac address, it will drop
the rlock and aquire the wlock to do the update.

When we get a read error, we now unbind the
port to avoid further packets being forwarded
to it.

This is usefull for hotplug ethernet devices
like usb ones or tunnels.

Simplify the unbind, getting rid of the refcount,
by having only the reader proc call freeport().

Avoid holding the bridge lock while opening
and closing ethernet/tunnel device files during
bind and unbind.

Dont use smalloc() (especially when holding locks).

Allocate bridges dynamically, so we do not waste
the memory when we do not need them.

Reject non-hostowner from allocating new bridges.

Use consistent naming: port -> port

Use consistent comment style: // -> /* */
2022-02-26 22:05:32 +00:00
cinap_lenrek be0a80faf3 nusb/disk: use setalt(), print argv0 in prints instead of "disk:" 2022-02-23 18:38:28 +00:00
cinap_lenrek 045936a778 nusb/cam: fix mistake (nil vs -1) 2022-02-23 18:13:00 +00:00
cinap_lenrek 8bf71adc94 nusb/audio: use setalt(), make sure endpoint has right direction. 2022-02-23 18:03:53 +00:00
cinap_lenrek 11e12ea0c0 nusb/cam: use setalt() 2022-02-23 18:02:02 +00:00
cinap_lenrek 67750a093f nusb/ether: use setalt() 2022-02-23 18:01:15 +00:00
cinap_lenrek bea20cd152 nusb/lib: provide a setalt() function to set the interface to its altsetting 2022-02-23 18:00:34 +00:00
cinap_lenrek 9cd55a085d nusb/ether: remove csp check for rndis, already done in nusbrc 2022-02-23 17:59:13 +00:00
Sigrid Solveig Haflínudóttir 0e3a955652 libFLAC: update to 1.3.4 2022-02-21 21:11:19 +00:00
cinap_lenrek 065d601916 nusb: Fix handling of interface altsetting.
The altsetting was handled only for a single endpoint
(per interface number), but has to be handled for each
endpoint (per interface *AND* altsetting number).

A multi function device (like a disk) can have
multiple interfaces, all with the same interface number
but varying altsetting numbers and each of these
interfaces would list distict endpoint configurations.

Multiple interfaces can even share some endpoints (they
use the same endpoint addresses), but
we still have to duplicate them for each
interface+altsetting number (as they'r part of
actually distict interfaces with distict endpoint
configurations).

It is also important to *NOT* make endpoints bi-directional
(dir == Eboth) when only one direction is used in a
interface/altsetting and the other direction in another.
This was the case for nusb/disk with some seagate drive
where endpoints where shared between the UAS and
usb storage class interface (but with distict altsettings).

The duplicate endpoints (as in using the same endpoint address)
are chained together by a next pointer and the head
is stored in Usbdev.ep[addr], where addr is the endpoint
address. These Ep structures will have distinct endpoint
numbers Ep.id (when they have conflicting types), but all
will share the endpoint address (lower 4 bits of the
endpoint number).

The consequence is that all of the endpoints configuration
(attributes, interval) is now stored in the Ep struct and
no more Altc struct is present.

A pointer to the Ep struct has to be passed to openep()
for it to configure the endpoint.

For the Iface struct, we will now create multiple of them:
one for each interface *AND* altsetting nunber,
chained together on a next pointer and the head being
stored in conf->iface[ifaceid].

--
cinap
2022-02-21 19:50:16 +00:00
cinap_lenrek 14bb9734a6 usbxhci: endpoint address needs to be masked with Epmax from endpoint number 2022-02-21 18:46:47 +00:00
cinap_lenrek 4b637a24f9 devbridge: implement experimental vlan support 2022-02-16 22:38:03 +00:00
cinap_lenrek 7289f371a0 devip: dont hold ifc wlock during medium bind/unbind
Wlock()'ing the ifc causes a deadlock with Medium
bind/unbind as the routine can walk /net, while
ndb/dns or ndb/cs are currently blocked enumerating
/net/ipifc/*.

The fix is to have a fake medium, called "unbound",
that is set temporarily during the call of Medium
bind and unbind.

That way, the interface rwlock can be released while
bind/unbind is in progress.

The ipifcunbind() routine will refuse to unbind a
ifc that is currently assigned to the "unbound"
medium, preventing any accidents.
2022-02-16 22:31:31 +00:00
cinap_lenrek 755880b19f rc: fix globbing with lists (thanks qwx)
Pattern matching with lists no longer works:

	; ls /tmp/*.c
	/tmp/npage.c
	/tmp/pagedebug.c
	/tmp/pageold.c
	/tmp/scheduler.c
	/tmp/writeimagetest.c
	; ls /tmp/^(*.c)
	ls: /tmp/*.c: '/tmp/*.c' directory entry not found
	; 9fs dump
	; bind /n/dump/2021/1002/amd64/bin/rc /bin/rc
	; rc
	; ls /tmp/^(*.c)
	/tmp/npage.c
	/tmp/pagedebug.c
	/tmp/pageold.c
	/tmp/scheduler.c
	/tmp/writeimagetest.c

the fix:

we have to propagate the glob attribute thru lists
as well. before it was only handled for single words
and propagated thru concatenations...

the Xglob instruction now works on list, and we
propagate the glob attribute thru PAREN and WORDS
and ARGLIST nodes.

also, avoid using negative numbers for the Tree.glob
field as char might be unsigned on some targets.
2022-02-16 18:07:21 +00:00
Michael Forney 5c96a51f3a nusb/serial: fix pl2303 usbcmd error checks
Since e0087b2a, usbcmd with Rh2d returns the size of the data stage
(excluding the setup packet), so adjust the expected return values
accordingly.
2022-01-01 22:51:18 +00:00
Tobias Heinicke 53fb93e64a delete import, oexportfs src 2021-12-14 19:39:59 +00:00
qwx af561602ea aux/wacom: fix race in read queue
this fixes `no concurrent reads, please' errors when using
aux/wacom with aux/tablet on eg. x61t
2021-12-14 23:54:05 +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
qwx b4d4cf69be vga/igfx: add missing pci did's for hwblank for known mobile models 2021-12-08 09:52:07 +00:00
Ori Bernstein 3710ed60fd git: fully init objq
we were leaving objq.best uninitialized, and
would therefore read garbage if we didn't
find a best match.
2021-12-08 00:20:32 +00:00
Humm 69249e8313 troff: we are not htmlroff
If we don’t explicitly check for ‘h’ in troff, we can’t reliably check
for non-htmlroff well.

Consider the following:

	.if h \{\
	.	de M
	.		tm m
	..\}

Without this change, this will print m and not define macro M.
2021-11-24 19:56:44 +00:00
Ori Bernstein f0adfb4ded git: improve pack cache heuristics
the pack cache was very stupid: it would close packs
as early as possible, which would prevent packs from
getting reused effectively. It would also select a
bad pack to close.

This picks the oldest pack, refcounts correctly, and
keeps up to Npackcache open at once (though it will
go over if more are in use).
2021-12-05 00:13:54 +00:00
cinap_lenrek 78c7ad88ff kernel: add extra negative and power-of-two check to pcibarsize() 2021-11-26 21:47:15 +00:00
cinap_lenrek 2a531d444c aux/vga: use vlong for pci bar size 2021-11-26 20:55:58 +00:00
cinap_lenrek 20ea113790 kernel: support large 64-bit pci membars, increase pc64 VMAPSIZE to 1TB
This makes vmap()/vunmap() take a vlong size argument,
and change the type of Pci.mem[].size to vlong as well.

Even if vmap() wont support large mappings, it is nice to
get the original unruncated value for error checking.

pc64 needs a bigger VMAP window, as system76 pangolin
puts the framebuffer at a physical address > 512GB.
2021-11-26 20:51:45 +00:00
Sigrid Solveig Haflínudóttir add3a0a4da aescbc: flush before exit and report an error (if any) 2021-11-25 21:42:12 +00:00
qwx b5a2fa5e5e audiohda: add support for intel cannon point-lp (t490s) 2021-11-18 17:15:08 +00:00
cinap_lenrek fc412aef3d 6c: extern registers must be considered used on return
the peephole optimizer would remove stores to extern
register before a return statement as it would think
they are only set, but not used.
2021-11-17 01:23:57 +00:00
Sigrid Solveig Haflínudóttir 78b55b64c8 mklatin: fix compose sequences starting with a space char (␣ and ı) 2021-11-14 20:16:30 +00:00
Sigrid Solveig Haflínudóttir 0f50c54b5e kbdfs: allow X and x to be used not just for hex composition 2021-11-14 14:27:15 +00:00
qwx 2ab25e3ec0 vgaigfx: add x1 carbon 3rd gen 2021-11-13 23:04:04 +00:00
Kyle Milz 41ac2d80c7 igfx: add x1 carbon 3rd gen (broadwell) 2021-11-12 18:37:33 +00:00
Igor Böhm c7775b365e rc: fix leaking runq->cmdfile
To reproduce run the following on a terminal:
<snip>
cpu% leak -s `{pstree | grep termrc | sed 1q | awk '{print $1}'}
src(0x00209a82); // 12
src(0x0020b2a6); // 1
cpu% acid `{pstree | grep termrc | sed 1q | awk '{print $1}'}
/proc/358/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x0020b2a6)
/sys/src/cmd/rc/plan9.c:169
 164		if(runq->argv->words == 0)
 165			poplist();
 166		else {
 167			free(runq->cmdfile);
 168			int f = open(runq->argv->words->word, 0);
>169			runq->cmdfile = strdup(runq->argv->words->word);
 170			runq->lexline = 1;
 171			runq->pc--;
 172			popword();
 173			if(f>=0) execcmds(openfd(f));
 174		}
acid:
</snap>

Another `runq->cmdfile` leak is present here (captured on a cpu server):
<snip>
277         ├listen [tcp * /rc/bin/service <nil>]
321         │├listen [/net/tcp/2 tcp!*!80]
322         │├listen [/net/tcp/3 tcp!*!17019]
324         ││└rc [/net/tcp/5 tcp!185.64.155.70!3516]
334         ││ ├rc -li
382         ││ │└pstree
336         ││ └rc
338         ││  └cat
323         │└listen [/net/tcp/4 tcp!*!17020]
278         ├listen [tcp * /rc/bin/service.auth <nil>]
320         │└listen [/net/tcp/1 tcp!*!567]
381         └closeproc
cpu% leak -s 336
src(0x00209a82); // 2
src(0x002051d2); // 1
cpu% acid 336
/proc/336/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x002051d2)
/sys/src/cmd/rc/exec.c:1056
 1051
 1052	void
 1053	Xsrcfile(void)
 1054	{
 1055		free(runq->cmdfile);
>1056		runq->cmdfile = strdup(runq->code[runq->pc++].s);
 1057	}
acid:
</snap>

These leaks happen because we do not free cmdfile on all execution paths
where `Xreturn()` is invoked. In `/sys/src/cmd/rc/exec.c:/^Xreturn`

<snip>
void
Xreturn(void)
{
	struct thread *p = runq;
	turfredir();
	while(p->argv) poplist();
	codefree(p->code);
	runq = p->ret;
	free(p);
	if(runq==0)
		Exit(getstatus());
}
</snip>

Note how the function `Xreturn()` frees a heap allocated instance of type
`thread` with its members *except* the `cmdfile` member.

On some code paths where `Xreturn()` is called there is an attempt to free
`cmdfile`, however, there are some code paths where `Xreturn()` is called
where `cmdfile` is not freed, leading to a leak.

The attached patch calls `free(p->cmdfile)` in `Xreturn()` to avoid leaking
memory and handling the free in one place.

After applying the patch this particular leak is removed. There are still
other leaks in rc:

<snip>
277         ├listen [tcp * /rc/bin/service <nil>]
321         │├listen [/net/tcp/2 tcp!*!80]
322         │├listen [/net/tcp/3 tcp!*!17019]
324         ││└rc [/net/tcp/5 tcp!185.64.155.70!3516]
334         ││ ├rc -li
382         ││ │└pstree
336         ││ └rc
338         ││  └cat
323         │└listen [/net/tcp/4 tcp!*!17020]
278         ├listen [tcp * /rc/bin/service.auth <nil>]
320         │└listen [/net/tcp/1 tcp!*!567]
381         └closeproc
cpu% leak -s 336
src(0x00209a82); // 2
src(0x002051d2); // 1
cpu% acid 336
/proc/336/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x00209a82)
/sys/src/cmd/rc/subr.c:9
 4	#include "fns.h"
 5
 6	void *
 7	emalloc(long n)
 8	{
>9		void *p = malloc(n);
 10		if(p==0)
 11			panic("Can't malloc %d bytes", n);
 12		return p;
 13	}
 14
</snap>

To help fixing those leaks emalloc(…) and erealloc(…) have been amended to use
setmalloctag(…) and setrealloctag(…). The actual fixes for other reported leaks
are *not* part of this merge and will follow.
2021-11-10 13:01:38 +00:00
cinap_lenrek a4c1f3cc18 devtls: reject zero length records (thanks sigrid)
zero length record causes ensure() todo nothing,
while qgrab() assumes there is at least one buffer
in the queue and would dereference the nil buffer.
2021-11-09 01:46:13 +00:00
cinap_lenrek 68572ab451 diff: revert last change, this breaks git/diff 2021-11-09 01:29:30 +00:00
cinap_lenrek a87ce74d60 kernel/rdb: need to reenable polling mode on the uart, remove cruft 2021-11-07 17:58:52 +00:00
cinap_lenrek 9eb192f586 bcm64: parse the emmc2bus/dma-ranges device-tree property and provide *emmc2bus kernel parameter
/*
  * emmc2 has different DMA constraints based on SoC revisions. It was
  * moved into its own bus, so as for RPi4's firmware to update them.
  * The firmware will find whether the emmc2bus alias is defined, and if
  * so, it'll edit the dma-ranges property below accordingly.
  */
 emmc2bus: emmc2bus {
 compatible = "simple-bus";
 ranges = <0x0 0x7e000000  0x0 0xfe000000  0x01800000>;
 dma-ranges = <0x0 0xc0000000  0x0 0x00000000  0x40000000>;
 emmc2: mmc@7e340000 {
 compatible = "brcm,bcm2711-emmc2";
 reg = <0x0 0x7e340000 0x100>;
 interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
 clocks = <&clocks BCM2711_CLOCK_EMMC2>;
 status = "disabled";
 };
 };
2021-11-07 17:51:12 +00:00
cinap_lenrek 80268af29e bcm64/sdhc: add *emmc2bus kernel parameter to set dma dram bus address
On the raspberry pi 4, depending on the chip revision,
the emmc2 controller has different dram bus address window,
so make it configurable.
2021-11-07 17:47:09 +00:00
cinap_lenrek a2baa86348 bcm/emmc: remove unused cardr wakeup(), use MACHP(0) as tick reference 2021-11-07 17:43:36 +00:00
cinap_lenrek 2925fb09a6 sdmmc: do card init in a background process after the first try
Some mmc controllers have no card detect pin, so the only
way to detect card presence is to issue the ACMD41 which will
fail after a pretty long timeout.

To avoid mmconline() blocking, we only try to initialize the
card synchronous once, and then retry in a background process,
while returning immediately from mmconline() while the retry
is in progress.

This speeds up network boot times significantly on a raspi
without a sdcard inserted.
2021-11-07 17:41:57 +00:00
Igor Böhm efa6937460 acme: fix leaking memory allocated by getenv("font")
If the font chosen for acme is retrieved via `getenv("font")` its
memory is leaked:

<snip>
	if(fontnames[0] == nil)
		fontnames[0] = getenv("font");
		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> getenv(…) mallocs memory

	if(fontnames[0] == nil)
		fontnames[0] = "/lib/font/bit/vga/unicode.font";
	if(access(fontnames[0], 0) < 0){
		fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
		exits("font open");
	}
	if(fontnames[1] == nil)
		fontnames[1] = fontnames[0];
	fontnames[0] = estrdup(fontnames[0]);
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> if the `getenv("font")` path was taken above, this assignment
> will leak its memory.
</snap>

The following leak/acid session demonstrates the issue:

<snip>
cpu% leak -s 212252
src(0x002000cb); // 1
cpu% acid 212252
/proc/212252/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: src(0x002000cb)
/sys/src/cmd/acme/acme.c:107
 102			fprint(2, "usage: acme [-aib] [-c ncol] [-f font] [-F fixedfont] [-l loadfile | file...]\n");
 103			exits("usage");
 104		}ARGEND
 105
 106		if(fontnames[0] == nil)
>107			fontnames[0] = getenv("font");
 108		if(fontnames[0] == nil)
 109			fontnames[0] = "/lib/font/bit/vga/unicode.font";
 110		if(access(fontnames[0], 0) < 0){
 111			fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
 112			exits("font open");
acid:
</snap>

The fix tries to first check if a font has been set via
command line options in which case the font string is
malloced via estrdup(…).

If no font has been selected on the command line getenv("font")
is used. If no getenv("font") var is found we malloc a default
font via estrdup(…).

<snip>
	if(fontnames[0] != nil)
		fontnames[0] = estrdup(fontnames[0]);
	else
		if((fontnames[0] = getenv("font")) == nil)
			fontnames[0] = estrdup("/lib/font/bit/vga/unicode.font");
	if(access(fontnames[0], 0) < 0){
		fprint(2, "acme: can't access %s: %r\n", fontnames[0]);
		exits("font open");
	}
	if(fontnames[1] == nil)
		fontnames[1] = fontnames[0];
	fontnames[1] = estrdup(fontnames[1]);
</snap>

This resolves the memory leak reported by leak(1).
2021-11-05 23:51:55 +00:00
Kyle Milz cd7480f68f diff: fix -u when comparing identical files 2021-11-05 19:03:20 +00:00
qwx 9827a6b178 audiohda: add support for intel comet lake-s, fix typo 2021-11-05 22:26:28 +00:00
cinap_lenrek 6c70026fa4 acme: fix plumb message leaks (thanks igor) 2021-11-05 18:49:40 +00:00
Kyle Milz e2e4a46f26 git/revert: fix empty invocation
git/revert requires a file name argument, but when none is given
it fails in a strange way:

	% git/revert
	usage: cleanname [-d pwd] name...
	/bin/git/revert:15: null list in concatenation
2021-11-04 19:08:02 +00:00
Stuart Morrow 3f49507786 mainly just spelling and typos 2021-11-01 20:49:43 +00:00
cinap_lenrek cdf3be65ea snoopy: dns: add caa record type, fix rrtypestr() 2021-11-03 21:44:24 +00:00
cinap_lenrek c37de33463 ndb/dns: use decimal encoding for txt rr string escapes
rfc883 suggests to use decimal digits to escape txt rr strings,
and unix dig appears to use the same.
so change from octal to decimal.
2021-11-03 20:38:23 +00:00
cinap_lenrek 6285c19b33 snoopy: adjust for new dns txt rr format 2021-11-03 20:21:03 +00:00
cinap_lenrek 5de1f3d9cf ndb/dns: handle txt rr strings as binary, remove nullrr ndb code
txt and caa rr strings might contain binary control characters
such as newlines and double quotes which mess up the output
in ndb(6) format.
so handle them as binary blobs internally and escape special
characters as \DDD where D is a octal digit when printing.

txtrr() will unescape them when reading into internal
binary representation.

remove the undocumented nullrr ndb attribute parsing code.
2021-11-03 20:09:02 +00:00
cinap_lenrek 2899b719ae libndb: move mkptrname() into libndb to avoid duplication 2021-11-03 19:38:36 +00:00
Sigrid Solveig Haflínudóttir 2d56837b2f zuke: fix search function ignoring matching artist name 2021-11-03 14:45:27 +00:00
cinap_lenrek 498d86b921 ndb/dnsquery: make ! bang work with reverse lookups, document in ndb(8) 2021-11-01 16:31:39 +00:00
cinap_lenrek 3cd87bc3fb ndb/dns: use correct attribute when serializing caa record in ndb format 2021-11-01 15:12:17 +00:00
cinap_lenrek 5e3ded2242 ndb/dnsdebug: dont duplicate rrfmt()
introduce our own RR* format %P for pretty
printing and call %R format internally,
then use it to print the rest of the line
after the tab, prefixed with the padded
output.
2021-11-01 14:39:18 +00:00
cinap_lenrek 28f67bba84 ndb/dns: fix ndb serialization of RR*
have todo multiple fmtprint() calls for idnname()
as the buffer is shared.

do not idnname() rp->os and rp->cpu, these are symbols.

always quote txt= records.
2021-11-01 14:37:19 +00:00
qwx 987d15e7b2 tinc: fix typo in unknown host error message 2021-10-31 22:48:20 +00:00
Sigrid Solveig Haflínudóttir 023882f0a4 libtags: no tags is still fine if format is known 2021-10-31 17:38:18 +00:00
cinap_lenrek 1051b023a8 libc: idn2utf()/utf2idn(): check for < 1 buffer, can't insert terminating NUL. 2021-10-31 12:43:47 +00:00
cinap_lenrek 32665f51c7 libsec: no point in checking for "xn--" marker, just call idn2utf(). 2021-10-31 12:40:47 +00:00
cinap_lenrek 9d15403fda libc: fix overflow of domain component rune buffer for idn2utf()
If the source string has a run of more than 256 runes without
a "." dot, we'd overflow the runebuffer in idn2utf().

The utf2idn() routine had a check in the while loop, but that
is actually wrong too, as it would insert a dot and restart
the loop in the middle of a domain component. Just error
out if a domain component is too long.
2021-10-31 12:39:46 +00:00
Ori Bernstein 7b4e3be27e ape: add missing idn2utf, utf2idn to lib9
this fixes the libsec build under ape.
2021-10-31 04:42:34 +00:00
cinap_lenrek aebf92224f acmed: pass original utf8 subject domain to challengefn, simplify
try to keep everything in utf8 format.
2021-10-31 02:16:17 +00:00
cinap_lenrek 3f2a206151 libsec: decode international domain names in certificat subject, fix overflow botch
this is for consistency, so all certificte subjects
will be returned in utf8.
2021-10-31 01:49:25 +00:00
cinap_lenrek a9e533ad1e acmed: handle international domain names 2021-10-31 00:12:36 +00:00
cinap_lenrek bda0561f45 libsec: handle international domain names in certificate request 2021-10-31 00:10:13 +00:00
Sigrid Solveig Haflínudóttir 35a8152ebc git/pack: check pf->pack for nil before Bterming it 2021-10-28 15:26:57 +00:00
Sigrid Solveig Haflínudóttir 18521fc8c6 mkplist: add -s option to enable "simple" sort (thanks qwx) 2021-10-28 15:20:13 +00:00
Sigrid Solveig Haflínudóttir a84f3ef581 zuke: simplify volume control logic 2021-10-28 14:59:46 +00:00
Sigrid Solveig Haflínudóttir 4b7e72689d zuke: reset before tokenize, increase player thread stack 2021-10-27 22:02:31 +00:00
Ori Bernstein c5a0909b67 acmed: remove unused define
we don't use or care about the user agent.
2021-10-27 19:34:29 +00:00
Ori Bernstein d8a1437cf4 acmed: move from ip/ to auth/
Getting certs is more tied to authentication than it
is to ip.
2021-10-27 19:33:22 +00:00
cinap_lenrek 96560abe44 acmed: reject -t flag when -e is given, dup stderr to stdout of -e cmd 2021-10-27 17:08:20 +00:00
Sigrid Solveig Haflínudóttir e8083eca17 zuke: do not change volume with delta == 0 2021-10-26 15:37:04 +00:00
Sigrid Solveig Haflínudóttir 8c6daa778a zuke: support other volume handles, update volume when /dev/audio is opened 2021-10-26 15:08:35 +00:00
cinap_lenrek 79c6a0f342 acmed: tokenize domains from subject also with spaces (fixed multidom cert) 2021-10-25 18:15:53 +00:00
cinap_lenrek 87eb9bc2b7 acmed: add external command flag -e, improvements, bugs
- allow for external command to be run to install a challenge using -e flag
- remove the challengedom argument, it is given by the subject in the csr
- fix some filedescriptor leaks in error paths
2021-10-25 16:59:29 +00:00
cinap_lenrek 20cff04fd2 ndb/dns: implement caa record type in ndb
this allows the caa records to be specified
in ndb as:

caa=<value> tag=<tag> flags=<flags>

where tag defaults to "issue" and flags to 0
when omited.
2021-10-24 22:15:26 +00:00
Ori Bernstein c2661f86fc git/serve: one more silencing of non-interactive prints 2021-10-24 14:37:36 +00:00
Ori Bernstein a7f6b58d0d git/serve: don't show progress when not interactive
this prevents console spam
2021-10-24 01:36:46 +00:00
cinap_lenrek 5b5f69513a kernel: make growfd(), findfreefd() and newfd2() static 2021-10-23 15:54:30 +00:00
cinap_lenrek 1180631421 devswap: improve setswapchan()
- check for unusable file types like directories and append-only files.
- we should eigther error without any side effects or succeed.
2021-10-23 15:12:27 +00:00
cinap_lenrek db971a6189 kernel: fix stat bugs
In a few places, we where using a fixed buffer of sizeof(Dir)+100
size for stat. This is not correct and fails if the name returned
in stat is long.

This results in being unable to seek to the end of file with a
long filename.

The kernel should do the same thing as dirfstat() from libc;
handling the conversion and buffer allocation and returning a
freeable Dir* pointer.

For this, a new dirchanstat() function was added.

The fstat syscall was not rewriting the name to the last path
element; fix it.

In addition, gracefully handle the mountfix case, reallocating
the buffer to accomidate the required stat length plus
size of the new name so dirsetname() does not fail.
2021-10-23 13:40:06 +00:00
cinap_lenrek e54b6c6cbd libsec: fix wrong assert condition (introduced in 775a4bea43) 2021-10-22 13:37:27 +00:00
cinap_lenrek ee31c78080 libsec: fix operator precedence bugs (thanks kemal) 2021-10-17 23:35:37 +00:00
cinap_lenrek e0d2453f56 libsec: fix bugs in tls extension handling (thanks kemal)
this patch fixes bugs in tls extension handling:

1. if conn->serverName is an empty string, tlsClientExtensions
will generate a SNI with an empty hostname, which is forbidden
according to RFC 6066:

opaque HostName<1..2^16-1>;

check if conn->serverName has at least one char.

2. checkClientExtensions fail with clients that doesn't have
extensions, because it doesn't check if ext is nil. fix that
up.

3. rewrite checkClientExtensions. some parts of the code does
not check the length properly, and it could be simplified
heavily.
2021-10-17 23:19:33 +00:00
cinap_lenrek 2731ae50d3 libaml: resolve refs in ObjectType instruction
The standard states in section 19.5.93:

.... Notice that if this operation is performed
on an obeject reference such as one produced by
the Alias, Index, or RefOf statements, the obect
type of the base object is returned.
2021-10-17 19:52:28 +00:00
cinap_lenrek 31bb950b70 libaml: implement ObjectType instruction (thanks sigrid) 2021-10-17 19:29:09 +00:00
cinap_lenrek d0909089b2 libaml: implement ToString instruction 2021-10-17 18:45:05 +00:00
cinap_lenrek 72d08816ab devtls: implement "hangup" ctl message
This makes devtls connection directories compatible to
hangup function (see dial(2)).
2021-10-16 15:07:39 +00:00
cinap_lenrek 20429fb04f kernel: call freebroken() for kproc() when out of processes 2021-10-16 13:14:14 +00:00
cinap_lenrek a557c515c8 kernel: dont block allocating kstack for new processes
Have newproc() fail returning nil if we can't allocate
the kernel stack instead of locking up in smalloc().
2021-10-16 13:12:59 +00:00
Ori Bernstein 4c7745b202 acmed: import acme (RFC8555) client 2021-10-15 00:32:32 +00:00
cinap_lenrek 5a807265a8 libthread: fix debug prints, simplify
Do the debuglevel check before calling the print
function for _threaddebug, by making it a macro.
Do not waste cycles passing arguments.

Generalize the _threaddebug function into _threadprint()
and add a varargcheck pragma. This function can
also be used from _threadassert().

Fix missing arguments in one case, fix trailing
newlines in _threaddebug().

Make _threadgetproc()/_threadsetproc() a macro,
just dereferencing Proc**_threadprocp.

Simplify the mainjump, just call _threadsetproc()
directly without that mainp dance. Remove the
_schedinit() argument, it uses _threadgetproc() now.
Get rid of Mainarg struct, just have a global variable
for argc.
2021-10-13 17:08:26 +00:00
cinap_lenrek 3fe3e370e3 usbxhci: xhcirecover proc does not need to check status every 10ms
The timing loop is here for the case if the
controller doesnt produce an interrupt when
becoming broken. In normal case, we should
just get worken up from the interrupt.

In any case, 100 times a second polling is
not neccessary here, increase to 1 second.
2021-10-13 16:57:38 +00:00
cinap_lenrek 03d870e028 kernel: return error from sysrfork instead of waiting and retrying
The old strategy of wait and retry doesnt seem to
work very well as it keeps all the forking parents
stuck waiting in the kernel worsening the situation.

The idea with this change is to have rfork() return
error quickly; and without whining; as most callers
would just react with a sysfatal() which might be
better for surviving this.
2021-10-12 11:30:42 +00:00
cinap_lenrek b3c3c3e63d cc: do not expand function-like macros for non-function invocations
It is a bit of a annoyance that kenc will try to expand
function like macros on any symbol with the same name
and then complain when it doesnt see the '(' in the
invocation.

test case below:

void
foo(int)
{
}

struct Bar
{
	int	baz;	/* <- should not conflict */
};

void
main(void)
{
	baz(123);
}
2021-10-12 03:06:20 +00:00
cinap_lenrek 1656782f79 libthread: remove unused _workerdata() prototype from threadimpl.h 2021-10-12 01:09:40 +00:00
cinap_lenrek b474f546f0 libthread: remove more garbage: _threadnotefd, _threadpasserpid. 2021-10-12 00:52:56 +00:00
cinap_lenrek 928b38c7b9 libthread: remove unused skip() function 2021-10-12 00:51:02 +00:00
cinap_lenrek 07608c768f libthread: deal with _schedfork() and _schedexec() returning -1
The current behaviour of the kernel to deadlock itself
instead of returning an error on fork.

This might change in the future, so prepare libthread
to handle this case.

For _schedfork(), we'r going to just retry forking
on every switch, while for _schedexec(), the exec
will fail and send ~0 down the pid channel.
2021-10-12 00:49:12 +00:00
Igor Böhm 24bd67f990 acme: remove superfluous print arguments (patch from plan9port) 2021-10-05 09:40:30 +00:00
Igor Böhm a73f41bf4e sam: fix spurious overwrite message (patch from plan9port)
Fixes:

% sam -d
 -.
w /tmp/foo
/tmp/foo: (new file) #0
w /tmp/foo
?warning: write might change good version of `/tmp/foo'
2021-10-05 09:27:45 +00:00
Igor Böhm 659496081e tweak: add missing return to fix double close(…) on file descriptor…
… and avoid printing conflicting messages.
2021-10-06 13:37:39 +00:00
james palmer a13c5c3dda realemu: fix typo in usage message. 2021-10-11 18:26:14 +00:00
cinap_lenrek b51d7ca3ba devip: improve tcp error handling for ipoput
The ipoput4() and ipoput6() functions can raise an error(),
which means before calling sndrst() or limbo() (from tcpiput()),
we have to get rid of our blist by calling freeblist(bp).

Makse sure to set the Block pointer to nil after freeing in
ipiput() to avoid accidents.

Fix wrong panic string in sndsynack, and make any sending
functions like sndrst(), sndsynack() and tcpsendka()
return the value of ipoput*(), so we can distinguish
"no route" error.

Add a Enoroute[] string constant.

Both htontcp4() and htontcp6() can never return nil,
as they will allocate new or resize the existing block.
Remove the misleading error handling code that assumes
that it can fail.

Unlock proto on error in limborexmit() which can
be raised from sndsynack() -> ipoput*() -> error().

Make sndsynack() pass a Routehint pointer to ipoput*()
as it already did the route lookup, so we dont have todo
it twice.
2021-10-11 15:55:46 +00:00
cinap_lenrek ad1ab7089d devip: add comment to ip.h explaining Routehint struct 2021-10-11 12:16:21 +00:00
cinap_lenrek 5484260b42 kernel: move waserror() macro to port/portfns.h 2021-10-11 11:52:37 +00:00
cinap_lenrek 365e63b36a devip: properly rlock() the routelock for v4lookup() and v6lookup()
i'm not confident about mutating the route tree
pointers and have concurrent readers walking the
pointer chains.

given that most route lookups are bypassed now
for non-routing case and we are not building a
high performance router here, lets play it safe.
2021-10-10 14:27:08 +00:00
cinap_lenrek e687d25478 devip: use top bit (type) | subnet-id for V6H() route hash macro
theres no structure in the lower 32 bits of an ipv6 address.

use the top bit to distinguish special stuff like multicast
and link-local addresses, and use the 16-bit subnet-id bits
for the rest.
2021-10-10 14:22:14 +00:00
cinap_lenrek 1a6324970d devip: cache arp entry in Routehint
Instead of having to do an arp hash table lookup for each
outgoing ip packet, forward the Routehint pointer to the
medium's bwrite() function and let it cache the arp entry
pointer.

This avoids route and arp hash table lookups for tcp, il
and connection oriented udp.

It also allows us to avoid multiple route and arp table
lookups for the retransmits once an arp/neighbour solicitation
response arrives.
2021-10-09 18:26:16 +00:00
risto.salminen@gmx.com d280f411f6 upas/fs: add missing newline to a debug print
Noticed while doing some debugging.
2021-10-09 10:53:39 +00:00
james palmer a8ad3fb3d0 acme: don't let tag button draw over tag border. 2021-10-06 09:19:58 +00:00
cinap_lenrek 6ebb8b9e35 devip: use better hashipa() macro, use RWlock for arp cache 2021-10-03 15:58:58 +00:00
cinap_lenrek 55c3138c64 kernel: ensure that all accesses to Mhead.mount is done with Mhead.lock acquired
The Mhead structures have two sources of references to them:

- from Pgrp.mnthash hash-table
- from a channels Chan.umh pointer as returned by namec() for a union directory

Unless one holds the Mhead.lock RWLock, the Mhead.mount chain
can be mutated by eigther cmount(), cunmount() or closepgrp().

Readers, skipping acquiering the lock where:

mountfix(): responsible for rewriting directory entries for
union directory reads; was walking the Mhead.mount chain to
detect if the passed channel itself appears in the mount list.

cmount(): had a check and copy when "new" chan was a union itself
and if the MCREATE flag is set and would copy the mount table.
All this needs to be done with Mhead read-locked while copying
the mount entries.

devproc(): in the handler for reading /proc/n/ns file.

namec(): while checking if the Chan->umh should be initialized.

In addition to this, cmount() is changed to do the mountfree()
of the original mount chain when MREPL is done after releasing
the locks.

Also, some cosmetic changes...
2021-10-03 15:56:51 +00:00
Igor Böhm b638114186 vncv: enable connecting to Darwin hosts
Tested on MacOS Catalina and Big Sur releases.

Update man page to highlight weak encryption of vnc, recommending to
tunnel via ssh (thanks unobe).
2021-09-25 20:40:47 +00:00
Sigrid Solveig Haflínudóttir bd63aeb60d libtags: opus: fix duration on truncated files 2021-09-28 01:17:10 +00:00
Noam Preil df25039bb3 venti: fix fprint format string 2021-09-27 04:19:00 +00:00
cinap_lenrek d43d79bda4 devip: implement ipv4 arp timeout with icmp host unreachable notification
The IPv4 ARP cache used to indefinitely buffer packets in the Arpent hold list.
This is bad in case of a router, because it opens a 1 second
(retransmit time) window to leak all the to be forwarded packets.

This change makes the ipv4 arp code path similar to the IPv6 neighbour
solicitation path, using the retransmit process to time out old entries
(after 3 arp retransmits => 3 seconds).

A new function arpcontinue() has been added that unifies the point when
we schedule the (ipv6 sol retransmit) / (ipv4 arp timeout) and reduce
the hold queue to the last packet and unlock the cache.

As a bonus, we also now send a icmp host unreachable notification
for the dropped packets.
2021-09-26 18:43:29 +00:00
cinap_lenrek 1cff923af4 devtls: fix bwrite memory leak when channel stops being open
tlsbwrite() would call checkstate() before calling tlsrecwrite()
to make sure the channel is open. however, because checkstate()
only raises the error, the Block* passed wont be freed and
would result in a memory leak.

move the checkstate() call inside tlsrecwrite() to reuse the
error handling that frees the block on error.
2021-09-25 20:35:04 +00:00
Ori Bernstein 235ef367d7 vmx: update openbsd kernel heuristics
in OpenBSD 6.9 and up, the kernel (bsd, bsd.mp) still has
the ostype symbols, but bsd.rd appears to have lost them,
even when decompressed.

so, as a result, we should use what we have, which isn't
much.
2021-09-25 16:57:58 +00:00
nessabeene@gmail.com 3ac6d894d7 audiohda: Add DID for Intel 200 Series PCH HD Audio 2021-09-11 12:07:16 +00:00
Ori Bernstein 8f4842d346 git: when stealing from the old packs list, keep what we stole.
we were missing a return after stealing, which killed the point
of doing the theft.
2021-09-14 16:13:58 +00:00
Ori Bernstein 390abbd1c7 archacpi: leave acpi enabled with *acpi=
*acpi= was treated the same as *acpi=0, when we
want it to be treated the same as *acpi=1
2021-09-13 23:56:26 +00:00
Sigrid Solveig Haflínudóttir 4f310b8f51 devvmx: skip tsc offset writing if CPU doesn't support it 2021-09-13 22:54:05 +00:00
Ori Bernstein c7dcc82b0b git/query: fix spurious merge requests
Due to the way LCA is defined, a using a strict LCA
on a graph like this:

 <--a--b--c--d--e--f--g
     \               /
       +-----h-------

can lead to spurious requests to merge. This happens
because 'lca(b, g)' would return 'a', since it can be
reached in one step from 'b', and 2 steps from 'g', while
reaching 'b' from 'a' would be a longer path.

As a result, we need to implement an lca variant that
returns the starting node if one is reachable from the
other, even if it's already found the technically correct
least common ancestor.

This replaces our LCA algorithm with one based on the
painting we do while finding a twixt, making it give
the resutls we want.
git/query: fix spurious merge requests

Due to the way LCA is defined, a using a strict LCA
on a graph like this:

 <--a--b--c--d--e--f--g
     \               /
       +-----h-------

can lead to spurious requests to merge. This happens
because 'lca(b, g)' would return 'a', since it can be
reached in one step from 'b', and 2 steps from 'g', while
reaching 'b' from 'a' would be a longer path.

As a result, we need to implement an lca variant that
returns the starting node if one is reachable from the
other, even if it's already found the technically correct
least common ancestor.

This replaces our LCA algorithm with one based on the
painting we do while finding a twixt.
2021-09-11 17:46:26 +00:00
cinap_lenrek 546f8cfeca 9boot: fix isowalk() for directories spanning multiple sectors
directory entries cannot span sector boundaries, meaning
that the end of a sector would be zero padded until the
next sector.

we have to skip over these zero paddings to fully read
the directory.
2021-09-11 12:26:35 +00:00
qwx e279699344 plumber: remove $plumbsrv, add optional srvname, usage check
Plumber both posts a service to /srv and sets a $plumbsrv environment
variable.  Our libplumb no longer uses $plumbsrv and nothing else
does.  It's a silly hack;  rc doesn't update /env immediately, and
scripts, which for instance set up subrios, cannot rely on it to
clean up the plumber at the end.

Instead, add the option to specify a srvname, actually check for some
common errors and print a usage string.

Thanks to Ori for input and a preliminary patch.
2021-09-10 21:03:47 +00:00
cinap_lenrek d1986d8c0e ether82598: add pci device id for ixgbe i52899 (thanks izaki) 2021-09-09 23:13:30 +00:00
cinap_lenrek df66e62842 ndb/dns: make dblookup() consistent with cachedb operation, bring back txtrr for compatibility
- enforce same behaviour as cachedb server in dblookup():
	- force Taaaa record type on ipv6= attributes, regardless of value
	- return Taaaa records for ip= attributes containing ipv6 values
	- return Ta records only for ip= attributes containing ipv4 values

- for compatibility, bring back support for txtrr= type, but handle consistently
2021-09-08 17:34:04 +00:00
cinap_lenrek 1299ea4d89 ndb/dnsdebug: make usage flags consistent 2021-09-08 17:26:31 +00:00
Ori Bernstein 7ea6821a83 rc: revert 2f8a59f4b5
this patch doesn't pull its weight; it's not worth it.
2021-09-08 14:24:25 +00:00
cinap_lenrek 41369692bf ndb/dns: fix wrong ndb attribute "txtrr" vs. "txt" for caching server 2021-09-08 13:34:23 +00:00
Ori Bernstein d116b2d47c etheriwl: add did for Intel Centrino Advanced-N + WiMAX 6250 (thanks Nessa) 2021-09-05 00:16:22 +00:00
qwx bcdfdab41b ether82563: add pci id for i219-v on t490s 2021-09-04 23:55:20 +00:00
Ori Bernstein d9564c0642 git: separate author and committer
Git has the ability to track the person who
creates a commit separately from the person
who wrote the commit. For git9, we ignored
this feature.

However, as we start using git/import more,
it will be useful to figure out who imported
a commit, as well as who wrote it.

This change adds support for seeing this
information in git, as well as setting the
author and committer separately in git/import.
2021-09-03 02:47:18 +00:00
Amavect 485b334608 cmd/mkfile: major cleanup
Target generation is revised, split into $YTARG and $TARG.
$PROGS is inlined to the cmd target.
%.cpus is added to allow chaining: mk all.cpus
$POWERLESS is added, since dtracy doesn't build yet on ppc.
$DIRS regexp is simplified, simplifing $NOMK.
$cpuobjtype is replaced with cp's recipe for copying itself on $cputype.
$APEDIRS is removed.
The none target is renamed to usage, since it prints out usage.
The ape target is removed.
The dirs target is replaced by all.dirs
%.directories is replaced by %.dirs
The all target serializes directories after cmds to match the install target recipe.
All regexp rules are replaced with nonregexp versions for clarity.
The &:n: rule is removed. Just build the $O.$cmd file.
.y files now build .c files, not .tab.c files, and remove (bc|units|mpc|pc).c:R:
All safeinstall rules are removed.
The cleanfiles rule is renamed to cleancmds and simplified.
%.clean is removed. Just use mk cleancmds.
The install rule serializes cp and yacc before building anything else, avoiding races.
The installall recipe is simplified with the install.cpus prereq.
%.installall is removed. Just use mk $cmd.install.cpus
The $O.cj, %.update, and compilers rules are removed.
2021-08-28 13:15:02 +00:00
kemal 1a444750d6 ssh: use RSA/SHA-256 instead of RSA/SHA-1 as the public key algorithm
openssh now disables RSA/SHA-1 by default, so using RSA/SHA-1 will
eventually cause us problems:

https://undeadly.org/cgi?action=article;sid=20210830113413

in addition, github will disable RSA/SHA-1 for recently added RSA keys:

https://github.blog/2021-09-01-improving-git-protocol-security-github/

this patch modifies ssh.c to use RSA/SHA-256 (aka rsa-sha2-256)
instead of RSA/SHA-1 (aka ssh-rsa) as the public key algorithm.

NOTE: public rsa keys and thumbprints are ***NOT AFFECTED***
by this patch.

while we're here, remove the workaround for github.com. it seems
that github has fixed their implementation, and does not look into
macalgs when we're using an aead cipher.
---
2021-09-02 13:28:48 +00:00
qwx 6d4261baab add joy(1): joystick script for all emulators, and docs
remove old /sys/src/games/nes/joynes in favor of joy(1).
joy(1) has more buttons for the other emulators;  there is
no longer a significance in the order of the keys.
document nusb/joy, add information in each emulator manpage.
2021-09-01 22:47:30 +00:00
cinap_lenrek 6c94627105 vga: add eeepc1005ha graphics (thanks Andrew Eggenberger)
> This patch enables use of the igfx controller rather than vesa on the
> eeepc1005ha netbook. This means using the full screen resolution of
> 1024x600.

> *Andrew Eggenberger*
2021-08-31 15:53:37 +00:00
qwx 49b5319f76 audiohda: fix syntax error 2021-08-30 16:55:30 +00:00
Sigrid Solveig Haflínudóttir 7bdcdeafaf audiohda: add ztom z36*/z37* device id 2021-08-29 23:59:45 +00:00
Sigrid Solveig Haflínudóttir ec33d29cf6 ether8169: support rtl8402 variant 2021-08-29 23:12:33 +00:00
rodri d87fb23a93 bring games/swar from 1ed sources. 2021-08-26 20:04:59 +00:00
Ori Bernstein 0741147eab git/serve: add a '\n' after HEAD
Per the docs:

	the sender SHOULD include a LF, but the
	receiver MUST NOT complain if it is not
	present.

I typoed away the SHOULD, and got missed the
MUST NOT.

thanks qbit.
2021-08-25 22:15:34 +00:00
Ori Bernstein 9ca6ca345f git/compat: add support for ls-remote [-d]
This is used by 'go get' sometimes, so add it.
2021-08-25 02:24:15 +00:00
Ori Bernstein fb2e0a1987 git/diff: clean up diffs
We were overzealous about showing the changed
header, as well as setting a junk variable for
files that didn't exist; fix both.
2021-08-23 01:22:04 +00:00
Ori Bernstein 9a69a2bf2a git/commit: remove trailing 'subst -g'
the subst utility no longer supports a '-g'
flag, but this was left behind in commit;

this means that the lines listing modified
files were not correctly commented in the
commit header.

This is mostly harmless, but when using an
editor like sam to edit the commit message,
the modified lines would have to be removed
manually.
2021-08-23 00:22:04 +00:00
Ori Bernstein bcfee7b547 revert 8c228a123fa0c6062570964011854302bbf57242: accidental commit
was testing out the git/import tweaks and accidentally
pushed this commit. No comment on whether we want it,
but it definitely wasn't ready for merge.

Oops.
2021-08-22 17:47:38 +00:00
ori@eigenstate.org abe0534492 git/{diff,import}: make it easier to handle manually-asembled patch emails
Often, people (including myself) will write emails that
can almost be applied with git/import.  This changes
git/diff and git/import so that things will generally
work even when assembling diffs by hand:

1.	git/import becomes slightly more lax:

		^diff ...
		^--- ...

	will both be detected as the start of a patch.

2.  git/diff produces the same format of diff
	as git/export, starting with paths:

		--- a/path/to/file
		+++	b/path/to/file

	which means that the 'ape/patch -p1' used
	within git/import will just work.

So with this, if you send an email to the mailing list,
write up a committable description, and append the
output of git/diff to the end of the email, git/import
should just work.

[this patch was send through the mailing list using the
above procedure, and will be committed with git/import
to verify that it works as advertised]
2021-08-22 17:18:35 +00:00
kemal c5c79d61e6 etheriwl: fixes for 7260 ac
2021-08-14 17:50 GMT, kemal <kemalinanc8@gmail.com>:
> 1- as driver reads 8 bytes from nvm instead of 6 so fw doesn't
> spit us an ADVANCED_SYSASSERT, it was reading 2 more
> extra bytes. apparently those 2 extra bytes were put to
> the first 2 bytes of our buffer, so we got to skip that.

some more thoughts on this, i think as 0x15*2 is not multiple
of 8, fw rounds the offset to 0x14*2. i have touched to code
to read data from 0x14*2 then ignore the first 2 bytes, just
so it's not confusing. if this causes mac to be read wrong again,
report.

also, some more changes:

1. set the fwname at iwlpci, just to align the behavior with 8000+.
this is a cosmetic change.

2. i have discovered that on device boot/reset/shutdown functions,
our driver slept way much more than it should. the reason for that is,
driver used the function delay() on places where it needs to use
microdelay() instead. i have modified the code to use microdelay().
wpi likely needs similar changes too. i hope that this does not
break the code.

3. zzz a bit more on tx/rx scheduler shutdowns and niclock.

4. openbsd's iwm and linux apparently does not check if ownership
was obtained anymore in their handover functions. instead they
just loop until the hw is ready. aligned the behavior.
see linux commit: 289e5501c3141191dd830957f1d764d3dc14a54f

5. don't take antenna masks from nvm. it's apparently empty
in some cards from 7k family. we will rely on what the fw file gives
us.

6. when the calibration is completed, wakeup the proc that runs
postboot. otherwise that thing sleeps for like 2 whole seconds
even if calibration completed earlier.

i honestly don't think any of these changes will fix 7260 not
being able to get calibration results, but i don't see anything
wrong at all in postboot7000 at this point. i will just hope
these changes somehow make it get calibration results.

NOTE: latest patch on the 9front ml, posted Mon, 14 Feb 2022 15:26:55 +0300
(non functional as of yet)
2021-08-21 22:23:12 +00:00
Ori Bernstein 2367a2aeae git/branch: fix order of operations (thanks qwx) 2022-02-10 01:33:36 +00:00
qwx beeb054209 gba: fix flash chip id for 128k and add setting
Some gba cartridges use flash chips produced by a few different
manufacturers for backup memory.  A game rom may then try to read the
device id for its flash chip and break if it's the wrong one.  There's
no way for us to know which chip is supposed to be there, save for
looking it up in some database.  These chips are either 64k or 128k
big.  gba(1) hardcodes the id for the SST 64k chip, but games like the
Pokémon ones use a 128k Macronix chip and expect a different id,
completely breaking them.

This patch sets a different default for 128k flash backups, and gives
the ability to set the exact type when creating the save file if it's
really necessary.  This new default fixes the Pokémons.  The type is
saved in the save file, but this will *not* break existing ones.  It
may be that we don't need to worry about the type and just have an id
that corresponds to the right chip size, which is why these defaults
make sense, but I haven't tested more than a dozen roms, mostly since
I don't really know which games use 128k flash.
2022-02-10 00:35:13 +00:00
Sigrid Solveig Haflínudóttir a72a4c8b91 audio/flacdec: handle read errors properly to avoid endless looping saturating cpu 2022-02-09 00:42:10 +00:00
Igor Böhm 876907a530 rio: fix parsing of directory path (-cd) when creating a new window via wctl
Before applying this patch the following will fail to open ed
in the '/tmp/s p a c e' folder:

<snip>
% mkdir '/tmp/s p a c e'
% window -cd '/tmp/s p a c e' ed
!pwd
/tmp/s p a c e
!
q
<snap>

After applying the patch the above sequence works as expected,
opening ed in the '/tmp/s p a c e' folder, printing the present
working directory, and quitting ed.

The root cause was a faulty computation of the pointer `s`,
being off by one, leading to any arguments after the
directory path to be skipped.

This regression was introduced in revision:
• 614f1d6268

Thanks umbraticus for finding and reporting the issue.
2022-02-09 00:11:44 +00:00
cinap_lenrek 4ab2d149d4 nusb/usbd: use per hname collision counter instead of device address to resolve collisions
The device address is highly variable and depends on
all prior enumerated devices.

This can happen with some devices that do not have
a serial number and all devices of the same type
having the same hname.

Using a counter of collisions per hname makes more sense
and is more stable (given that the order devices are
enumerated is deterministic).
2022-02-06 01:19:01 +00:00
cinap_lenrek c0f142d993 bcm: fix rebootcode linkage 2022-02-05 16:20:56 +00:00
cinap_lenrek e4f30c89f4 ip/tftpd: add -m argument for name substitution using regular expressions
This allows mapping incoming filenames to a different name
using regular expressions, followed by subtitutions
of the %[ICE] format strings.

I needed this to have individual cmdline.txt files for
netbooted raspberry pi's. In this example, i map cmdline.txt
to %C, which gets substituted for /cfg/pxe/$ether of the client.
2022-02-05 01:34:22 +00:00
cinap_lenrek dc72530159 devgpio: make reading ctl file return 0 bytes 2022-02-05 01:25:28 +00:00
cinap_lenrek 251c3cfd61 acne/Mail: fix double-free (Bterm() in mesgshow()) 2022-01-29 20:50:03 +00:00
Michael Forney 2833aecc68 vmx: fix PCI ID for virtio block devices
The transitional PCI device ID for block devices is 0x1001, and the
virtio spec says that devices must have the transitional device ID or
0x1040 + the virtio device ID (2).
2022-01-24 23:48:13 +00:00
Kristo 8dc8e3a019 mothra: fix rendering of <samp> tag
Mothra does not currently render text inside <samp> tags inline
similar to <code>, but instead treats them like <pre> which is actually
incorrect behavior. The following small patch should fixes issue.
2022-01-22 18:00:22 +00:00
cinap_lenrek 60adc40118 devenv: allow environment total size of up to 1MB
Sometimes, there is the one-off occation when one needs to
pass a huge list in rc...

This change makes devenv track total memory consumption
of environment groups allowing them to grow up to 1MB in
size (including overhead).

(Before, only the variable size was restricted, but
not the amount of files being created).

The maximum value size of a single environment variable
is set to half of the total size, which allows the
occational large value. (But not many of them).

Because we track all memory consuption, it is also
now possible to create around 10k small environment
variales.

A hashtable is added for name lookups and the qid.path
was changed to allow direct indexing into the entry
array without needing a scan lookup.

All smalloc() calls have been removed, exhaustion is
handled with error(Enomem) avoiding deadlock
in case we run out of kernel memory.
2022-01-23 21:33:58 +00:00
Michael Forney a5a8a92adf git/query: leave range commits in topological order
This prevents commits from getting reordered incorrectly during rebase
or export.
2022-01-23 00:39:21 +00:00
Michael Forney b9adc507d2 cc: fix incorrect octal range condition in mpatov
This does not have any adverse effect, since yylex never calls mpatov
with a string with leading 0 (and not 0x) that contains non-octal
digits, but the condition was wrong regardless.
2022-01-23 01:05:27 +00:00
Benjamin Riefenstahl 108d74cb0a cmd/sshfs.c (recvproc): prefer error codes over error strings
Strings for existing codes in the most used server (OpenSSH) just
repeat the error code name.  OTOH we like to have wording of the
strings under our control as much as possible, so we can easier find
and process them.  Error strings are still usefull as fallback for
compatibility with future versions of the server.
2022-01-07 10:37:02 +00:00
qwx 9d43029ff9 page: performance fixes
- fix showpage1 only decrementing proc counter once limit is reached;
this blocked having more than one loadpages process after NPROC calls,
since the next one has to wait until the last has exited
- allow procs to skip pages currently being loaded by others; this
forced processes to wait for each other at the same page
- bump NPROC from 4 to 8
- (hack) immediately fork a few times after adding all pages at
startup to force loading a batch of pages in parallel
2022-01-19 22:58:53 +00:00
Sigrid Solveig Haflínudóttir aa14ba62fd flacdec: do not loop forever on write/decode errors 2022-01-19 02:16:09 +00:00
cinap_lenrek 6f9838a6a5 kernel: make Page.txtflush into an array
To avoid a MAXMACH limit of 32 and make
txtflush into an array for the bitmap.

Provide portable macros for testing and clearing
the bits: needtxtflush(), donetxtflush().

On pc/pc64, define inittxtflush()/settxtflush()
as no-op macros, avoiding the storage overhead of
the txtflush array alltogether.
2022-01-16 19:25:11 +00:00
cinap_lenrek 538b810712 rc: fix pwrd() regression, forgot <= ' ' case from needsrcquote()... sorry :( 2022-01-10 17:41:46 +00:00
cinap_lenrek 85bfb0e9eb reduce: use if() to test for exit status of pipeline
The new rc's exit status will be '' for a successfull
pipeline execution instead of '|'.

This is a bit too tightly coupled, so just use if()
statement instead, handling this in a portable way.
2022-01-10 02:01:11 +00:00
Ori Bernstein 4d872079d3 iostats: bind /srv into the namespace, its magic
programs that try to use /srv would choke when running
under iostats, because we intercepted operations on the
special, magic fd passing; we should instead give them
access to the real /srv.
2022-01-09 17:38:58 +00:00
Ori Bernstein 9e79aaceba git/commit: squelch error when run outside repository
when running outside of a repository, we would try to
remove '$msgfile.tmp', but we had never actually set
'$msgfile'.

the error is harmless, but annoying.
2022-01-09 17:37:29 +00:00
Igor Böhm 47b7dc5ccd acme: fix window and scrollbar display glitches at bottom fringe of column
The following patch fixes acme display glitches at the bottom fringe
of columns when adding/moving/resizing windows.

Here an example of an easy to reproduce case:

• https://invidio.xamh.de/watch?v=iLekQrxycaM

…opening acme and resizing a column to the right is all that is needed.

The functions winresize(…) and textresize(…) are extended with an
additional parameter `fillfringe` to indicate if a window/tag shall
fill a potential fringe area that would otherwise remain white.

The changes have been inspired by the approach taken in plan9port
acme.
2022-01-04 19:11:07 +00:00
cinap_lenrek 369cba5f93 rc: read heredoc when receiving '\n' (thanks Eckard Brauer)
Eckard's test case:

cat <<! | cat
asdf
!

The issue is that we have to continue parsing until we see
the '\n' before consuming the here document.

So we revert to the old approach of having two functions:

heredoc() which remembers if we'v seen a heredoc redirection
and a second readhere() function that reads the doc from
the lexers input and sets Tree.str on thee REDIR node.
2022-01-07 20:50:00 +00:00
Ori Bernstein 70edb7fbae git/fs: remove trailing null bytes from parent file (thanks mcf)
due to the way the size of buf was calculated, the parent
file had one trailing null byte for each parent. also, while
we're here, replace the sprint with seprint, and compute the
size from how much we printed in.
2022-01-07 01:43:52 +00:00
Benjamin Riefenstahl bf322dfbf3 ape/mkstemp: better options
Use O_EXCL and make the file descriptor writeable.  This is more
usefull and it conforms to Single Unix and other specs.
2021-12-10 20:44:26 +00:00
Ori Bernstein 370bfd26ce git: fix typo in git/log output
Commiter => Committer
2022-01-06 06:38:56 +00:00
cinap_lenrek 3568e27ec8 rc: only have single instance of a symbol, extern in header (thanks mcf) 2022-01-04 00:19:36 +00:00
cinap_lenrek 699d2e0ed9 rc: simplify Makefile, use yacc default rule (thanks k0ga) 2022-01-03 22:48:44 +00:00
cinap_lenrek b34fc2a9cf ape: allow exporting rc functions in environ[] 2022-01-03 18:47:56 +00:00
cinap_lenrek 189731aad0 rc: make it portable (for UNIX)
Fixup remaining Plan9 dependencies (chartorune()).
Add Makefile for UNIX-like systems (tested with Linux and APE).
Make error printing consistent, use Errstr() explicitely.
Get rid of NSTATUS buffer limit, just malloc it.
2022-01-03 18:41:48 +00:00
cinap_lenrek c51a5cfa06 rc: Xerror is not a instruction, remove from pfnc 2022-01-03 18:22:29 +00:00
Ori Bernstein f63d1d3ced git: size cache in bytes, not objects
git used to track cache size in object
count, rather than bytes. This had the
unfortunate effect of making memory use
depend on the size of objects -- repos
with lots of large objects could cause
out of memory deaths.

now, we track sizes in bytes, which should
keep our memory usage flatter.
2022-01-02 03:37:23 +00:00
cinap_lenrek 99d54e420e rc: add Xhereq instruction to trace 2022-01-02 03:35:50 +00:00
cinap_lenrek 11d573d7f9 rc: rstr() shouldnt skip trailing NUL bytes (thanks ori) 2022-01-02 03:33:34 +00:00
qwx c4e30bede2 remove ssl from zynq and remaining kernel configurations 2022-01-01 15:23:46 +00:00
cinap_lenrek 2025214dfc rc: fix here document handling with quoted end-marker (thanks sigrid)
when end marker is quoted, we should not substitute.
also, pcmd() needs to print the end marker without quotes.
2021-12-31 23:26:59 +00:00
cinap_lenrek d0c9127b10 remove devssl.c 2021-12-31 16:21:54 +00:00
cinap_lenrek b00b3d3739 rc(1): fix synopsis 2021-12-31 16:08:30 +00:00
cinap_lenrek 9773f55318 rc: add err != nil check for early exit 2021-12-31 16:05:28 +00:00
cinap_lenrek b90036a062 rc: fix everything
Untangle the lexer and interpreter thread state.

Fix the file and line number error reporting, getting rid of
Xsrcfile instruction, as the whole code block can only come
from a single file, stuff the source file in slot[1] of the
code block instead.

Remove limitations for globber (path element limits)
and be more intelligent about handling globbing by
inserting Xglob instruction only when needed and not
run it over every Xsimple argument list.

Remove fragile ndot magic and make it explicit by adding
the -q flag to . builtin command.

Add -b flag for full compilation.

Make exitnext() smart, so we can speculate thru rcmain and
avoid the fork().

Get rid of all print(2) format functions and use io
instead.

Improve the io library, adding rstr() to handle tokenization,
which allows us to look ahead in the already read buffer
for the terminators, avoiding alot of string copies.

Auto indent pcmd(), to make line number reporting more usefull.

Implement here documents properly, so they can work everywhere.
2021-12-31 15:27:10 +00:00
Ori Bernstein facb0e757a git: revert c947bf808 -- it triggers a bug.
We seem to have a botch in the protocol negotiation, where
we leak some protocol packets into the packfile; this will
need to be fixed before we put this change in.
2021-12-22 00:48:09 +00:00
Ori Bernstein c947bf8087 git: fetch all branches by default.
when the remote side creates a new branch, it is
desirable to have it show up in the repo.
2021-12-20 15:16:29 +00:00
Igor Böhm 614f1d6268 rio: allow spaces in working directory path (-cd) when creating a new window via wctl
The initial working directory of a new window may be set by a
`-cd directory` option. However, the `-cd directory` option is
not capable of handling paths with spaces when used via wctl.

To enable paths with spaces the function
/sys/src/cmd/rio/wctl.c:/^parsewctl is extended to handle quoted
directory paths.

Before applying the patch the following will fail to open a new
window by writing to /dev/wctl:

<snip>
 % rio -i window
 % mkdir '/tmp/path with space'
 % echo new -cd '''/tmp/path with space''' window -x rc >> /dev/wctl
 % pwd
 /tmp/path with space
<snap>

The following invocation fails as well:

<snip>
 % window -cd '/tmp/path with space'
 % pwd
 /tmp/path with space
<snap>

After applying the patch the above sequences work as expected,
opening a window running rc with the working directory set to
'/tmp/path with space'.
2021-11-29 00:06:45 +00:00
amavect 0f58e47551 exportfs, oexportfs, iostats: make -d log to stderr
exportfs -d logs 9p traffic to /tmp/exportdb.
-f allows writing to a different file.
exportfs silently continues if it doesn't have
permissions to create or write to /tmp/exportdb.
These are poor behaviors.

A better default is to write to stderr, since it
is 9P debug info that is better immediately printed,
and not user info that is better handled by syslog().
As a result, -f is obsolete and thus removed.
Redirect responsibility is now on rc.
As a side effect, rc will fail if it doesn't
have permissions to write.

exportfs(4) is updated to reflect all changes
and with a better Synopsis.

oexportfs is changed to match exportfs.
oexportfs(4) is updated to reflect all changes.
The Synopsis is not changed due to the number of flags.

Removed -f from iostats.
iostats(4) is updated to reflect all changes.
---
2021-08-18 17:51:40 +00:00
unobe@cpan.org 8c228a123f mk for only supported archs
http://fqa.9front.org/fqa1.html#1.2 states the supported archs.
However, clean and nuke also remove build files for 0 (spim) and q
(power).  'mk all' using those archs fails; 'mk kernels' also tries to
build all the kernels, even those which are not supported.  For
example, I tried to build the power arch (qc, qa, ql) and without
surprise it failed (when building dtracy): ...
mk dtracy
qc -FTVw dtracy.c
yacc -v -d -D1 parse.y
qc -FTVw cgen.c
qc -FTVw act.c
qc -FTVw type.c
 == regfree ==
REGISTER R0 <11> STRUCT DTAct cgen.c:302
 == regfree ==

REGISTER R0 <11> STRUCT DTAct act.c:266

 == regfree ==
qc -FTVw agg.c
cgen.c:299 unknown type in regalloc: STRUCT DTAct
cgen.c:299 bad opcode in gmove INT -> STRUCT DTAct
cgen.c:302 unknown type in regalloc: STRUCT DTAct
cgen.c:302 bad opcode in gmove INT -> STRUCT DTAct
cgen.c:302 error in regfree: 0 [0]
REGISTERmk: qc -FTVw cgen.c  : exit status=rc 387386: qc 387392: error R0
 <11> STRUCT DTAct act.c:269

act.c:250 unknown type in regalloc: STRUCT DTAct
act.c:250 bad opcode in gmove INT -> STRUCT DTAct
act.c:266 unknown type in regalloc: STRUCT DTAct
act.c:266 bad opcode in gmove INT -> STRUCT DTAct
act.c:266 error in regfree: 0 [0]
act.c:269 unknown type in regalloc: STRUCT DTAct
act.c:269 bad opcode in gmove INT -> STRUCT DTAct
act.c:269 error in regfree: 0 [0]
act.c:274 unknown type in regalloc: STRUCT DTAct
act.c:274 bad opcode in gmove INT -> STRUCT DTAct
act.c:274 error in regfree: 0 [0]
too many errors
mk: for(i in cc ...  : exit status=rc 382748: rc 387379: mk 387381: error
mk: date for (i ...  : exit status=rc 373781: rc 382226: mk 382227: error
cpu%

The patch below skips over non-supported architectures.  Is that
something we want?  This way, 'mk kernels' should work without a
problem (tested on amd64).  Then if someone works on getting those
architectures supported again in the future, they can be added back
in.
2021-08-17 14:00:47 +00:00
Noam Preil 2eadf1fa17 venti: fix memory layers 2021-07-21 05:06:05 +00:00
Sigrid Solveig Haflínudóttir 82c7251dc3 mixfs: add reading (audio loopback) 2021-08-21 22:51:11 +00:00
cinap_lenrek 7fd9be0f08 snoopy: ... and fix the memory leak for new dns rr types 2021-08-18 19:37:44 +00:00
cinap_lenrek 97c6a1dd52 snoopy: fix dns nil pointer crashes when formating dns packets (thanks sl)
snoopy shares ndb/dns's dns parser code, but has its own
copy of rralloc() function, which is responsible to allocating
auxiolary data structures on an RR depending on the type.

ndb/dns gained some support for some new types, but snoopy's
copy of rralloc() was not updated, resulting the auxiolary
structures to be nil, and the shared parsing routines crashes
when trying to dereference them.

this just syncs the copies, we might consider moving rralloc()
into its own file so it can be completely shared.
2021-08-18 17:59:50 +00:00
Ori Bernstein b0ae37013c exportfs: revert e524e8d65a
It turns out that the '-f' flag was being used, and removing
it broke things.
2021-08-18 14:44:29 +00:00
Ori Bernstein cfebf83947 git: better handling of absolute paths, regex metachars
Git currently gets a bit confused if you try to
manipulate files by absolute path.  There were also a
number of places where user-controlled file paths ended
up getting passed to regex interpretation, which could
confuse things.

This change mainly does 2 things:

	- Adds a 'drop' function which drops
	  a non-regex prefix from a string, and uses
	  that to manipulate paths, simplifies 'subst',
	  and removes 'subst -g', which was only used
	  with fixed regexes; sed does this job fine.
	- When getting a path from a user, we
	  make it absolute and then strip out the head

Along the way it cleans up a couple of stupids:

	- 'for(f in $list) if(! ~ $#f 0) use $f:
	  $f can't be a nil list because of
	  list flattening.
	- removes a useless substitution here:

	 	all=`$nl{{git/query -c $1 $2; git/query -c $2 $3} | sed 's/^..//' | \
			gsubst '^('$ourbr'|'$basebr'|'$theirbr')/*' | sort | uniq}

	  where git/query -c doesn't produce
	  paths prefixed with the query.
2021-08-17 04:31:15 +00:00
amavect e524e8d65a exportfs: make -d log to stderr
exportfs -d logs 9p traffic to /tmp/exportdb.
-f allows writing to a different file.
exportfs silently continues if it doesn't have
permissions to create or write to /tmp/exportdb.
These are poor behaviors.

A better default is to write to stderr, since it
is 9P debug info that is better immediately printed,
and not user info that is better handled by syslog().
As a result, -f is obsolete and thus removed.
Redirect responsibility is now on rc.
As a side effect, rc will fail if it doesn't
have permissions to write.

exportfs(4) is updated to reflect all changes
and with a better Synopsis.
2021-08-14 19:50:23 +00:00