When `p9dial` is given a non-nil "local" address to bind to,
the dial string was mistakening parsed into the _remote_ address
structure, and not the structure representing the local address.
It should, of course, parse into the local address structure.
This was flagged by a warning about passing a const pointer to
an uninitialized variable to `bind(2)`.
Signed-off-by: Dan Cross <cross@gajendra.net>
Modern OpenSSH servers reject ssh-rsa (SHA-1) signatures.
Import SHA-2 support to libsec from Plan 9, teach factotum
to sign with SHA256 and SHA512, and handle the
SSH_AGENT_RSA_SHA2_256/512 flags in ssh-agent.
Strip role and hash from factotum RSA key lookups so a
single key can serve both sign and decrypt operations.
Increase _attrfmt buffer from 1024 to 8192 so large RSA
key attributes are not truncated during factotum ctl reads.
The following files were imported from Plan 9 :
- src/libsec/port/sha2block64.c
- src/libsec/port/sha2block128.c
- src/libsec/port/sha2_64.c
- src/libsec/port/sha2_128.c
On a few occasions, I've found my acme.dump file overwritten
with zero-length content. I suspect it happens when the machine
is going down or under severe memory pressure, ending
with the file created but not written to.
Instead of opening and writing the file in place, create a temporary
file alongside the destination, write to that, then rename it over
the original. We take care to preserve the original permissions,
although ownership might change (that's probably not an issue in
practice). The underlying `mkstemp` call creates the temporary
file without any access rights for group or other, so there
shouldn't be any window of opportunity for an attacker to open it
before the permissions are changed.
Change-Id: Id0bc0e76c0acf5671c94b1b454cf23632b675586
When physical button 1 is remapped to button 2 (Ctrl) or 3 (Alt) on
ButtonPress, the ButtonRelease event still reports the physical button 1.
This caused the release to clear the wrong bit, leaving the simulated
button permanently stuck.
Fix by recording the button mapping on press and applying it on release.
Written mostly by Claude, but I've reviewed the code and it
seems like the right kind of fix, and it works for me.
Fixes#714.
Change-Id: I9f465e1dcbe766531a37088e0fc9df2570e1c01d
The snarf code silently dropped text larger than SnarfSize (64KB),
causing paste to produce nothing. Replace the static clip buffer
with a dynamically allocated one, remove all the size checks, and
read the actual X11 property size instead of capping at SnarfSize.
On Solaris, the child of fork does not have access to the stacks
of other threads that existed at the time of the fork, as demonstrated
by the C program below (fails on Solaris, works everywhere else).
Work around this by making a copy of everything the child needs
in malloc'ed memory, which is inherited properly.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
int *p;
pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t ready = PTHREAD_COND_INITIALIZER;
pthread_cond_t never = PTHREAD_COND_INITIALIZER;
void*
thread1(void *v)
{
int local = 42;
pthread_mutex_lock(&mu);
p = &local;
pthread_cond_signal(&ready);
pthread_cond_wait(&never, &mu);
return 0;
}
void*
thread2(void *v)
{
pthread_mutex_lock(&mu);
while(p == 0)
pthread_cond_wait(&ready, &mu);
pthread_mutex_unlock(&mu);
printf("parent: *p = %d\n", *p);
int pid = fork();
if (pid == 0) {
printf("child: *p = %d\n", *p);
exit(0);
}
printf("parent: pid = %d\n", pid);
int status;
waitpid(pid, &status, 0);
if(WIFEXITED(status))
printf("child exit %d\n", WEXITSTATUS(status));
else if(WIFSIGNALED(status))
printf("child signal %d\n", WTERMSIG(status));
else
printf("unexpected child status %d\n", status);
return 0;
}
int
main(void)
{
pthread_t t1, t2;
pthread_create(&t1, 0, thread1, 0);
pthread_create(&t2, 0, thread2, 0);
void *v;
pthread_join(t2, &v);
return 0;
}
Acme adds a space after Look at the end of window tags. Therefore, the
space before Send is not needed. The space after Send is for consistency
and convenience.
The created window in xattach is missing the StructureNotifyMask,
if the WM does resize the window before mapping (like tiling WMs
do), the client will not get notified (and XGetWindowAttributes
in the same function will not get updated values)
Reproducible by starting acme in e.g. dwm.
I uncovered this problem while writing unit tests for GNU troff's
delimited expression handling. Plan 9 troff's numeric expression
evaluator handles division by zero but not modulus by zero.
Fixes:
$ echo '.if %0%0% .tm true' | 9 troff
Floating point exception (core dumped)
$ echo '.if 1%0 .tm true' | 9 troff
Floating point exception (core dumped)
After this patch:
$ echo '.if %0%0% .tm true' | 9 troff
x T utf
x res 720 1 1
x init
troff: modulus by zero.; stdin:1
troff: modulus by zero.; stdin:1
x trailer
V0
x stop
$ echo '.if 1%0 .tm true' | 9 troff
x T utf
x res 720 1 1
x init
troff: modulus by zero.; stdin:1
x trailer
V0
x stop
x11-screen.c accepts selection targets with the MIME type
"text/plain;charset-UTF8", but it should do so case insensitively. The
current code draws an error when working with xfce4-terminal 1.0.4,
which sends lower case. To reproduce, run acme, snarf some text, then
paste in the terminal. acme will report:
acme: cannot handle selection request for 'text/plain;charset=utf-8' (590)
...when rendering some man pages, such as those of ncurses.
I did not manage (nor seriously attempt) to identify the root cause of
this bug. ncurses's use of `SH` and `SS` man(7) macros is
unremarkable.[1] I cannot account for why the less(1) man page renders
fine and ncurses pages like insstr(3) do not. But render badly they do,
emitting *roff logic as formatted output.
```
$ 9 nroff -man $(man -w insstr) | grep -F .ss | cat -v
"'''if^GNAME^GSYNOPSIS^G .ss 18 NAME
"'''if^GSYNOPSIS^GSYNOPSIS^G .ss 18 SYNOPSIS
"'''if^GDESCRIPTION^GSYNOPSIS^G .ss 18 DESCRIPTION
"'''if^GRETURN^GSYNOPSIS^G .ss 18 RETURN VALUE
"'''if^GNOTES^GSYNOPSIS^G .ss 18 NOTES
"'''if^GEXTENSIONS^GSYNOPSIS^G .ss 18 EXTENSIONS
"'''if^GPORTABILITY^GSYNOPSIS^G .ss 18 PORTABILITY
"'''if^GHISTORY^GSYNOPSIS^G .ss 18 HISTORY
"'''if^GSEE^GSYNOPSIS^G .ss 18 SEE ALSO
```
With this patch:
```
$ 9 nroff -man $(man -w insstr) | grep -F .ss | cat -v | grep . || echo NO OUTPUT
NO OUTPUT
```
I do observe that the problem seems to correspond to the only use in the
package of the old-fashioned `'''` commenting convention _within a macro
definition_. I have a notion of how GNU troff works, but little about
AT&T troff. That said, if I were to try to get to the bottom of this
problem, I'd look into if and how the no-break command character is
handled differently in copy mode. I see nothing in CSTR #54 to suggest
that the command characters have different meanings in copy mode and its
complement.[2]
My solution is to use idiomatic comment syntax inside macro definitions.
[1] d5dc8a4a7c/man/curs_insstr.3x (L47)
[2] unnamed in AT&T documentation but which I term "interpretation mode"
in groff
Because of a dangling else, after adding a name to an image with 'N',
it was immediately deleted, resulting in Enoname in response to 'n'.
This went mostly unnoticed, since plan9port itself does not use named
images, but it can break external applications like truedraw[1].
[1]: https://git.sr.ht/~arusekk/truedraw
Fixes: c66b52501b ("new draw server")
groff 1.23.0 added .MR to its -man macro package. The NEWS file states
that the inclusion of the macro "was prompted by its introduction to
Plan 9 from User Space's troff in August 2020." From d32deab it seems
that the name for Plan 9 from User Space's implementation was suggested
by groff maintainer G. Brandon Robinson.
Not sure if the intention was to make these definitions compatible, but
it would be nice if they were.
Currently, Plan 9 from User Space's .MR expects its second argument to
be parenthesized. groff's .MR does not. This results in extra
parentheses appearing in manual references when viewing Plan 9 from User
Space's manual pages on a system using groff.
Dependabot automatically maintains GitHub Actions workflows by sending
Pull Requests to project when action updates are released. Dependabot
labels the pull requests 'ci: bump actions/checkout from v3 to v4'.
Dependabot opens a maximum of five Pull Requests at a time and reviews
the need for PRs once a week.
Give `-Wformat=0` on illumos/Solaris so that the build does not
complain about `execlp` not having a sentinel (it's nil). Also
fix an integer size issue when casting to a void pointer.
libthread had code in `_pthreadinit` to test for LinuxThreads,
and error if it was in use. This hasn't been relevant since
Linux 2.6, and I can't imagine there are many people trying to
build (recent) plan9port on systems that old.
Unfortunately, this code violated aliasing rules, and compilers
were complaining about it. But, since it likely hasn't had much
relevance in 20ish years, we can probably just remove it.
Use `extern` where appropriate so that we can remove `-fcommon`
on macOS and others. On macOS, `-fcommon` generates a number of
linker warnings.
I've tested building on macOS, Linux, FreeBSD, NetBSD, OpenBSD
and illumos. I am not in a position to test on AIX or other
more esoteric platforms, however.
Misleading indentation warnings are actually useful, as they
will occasionally reveal actual bugs (cf the apple `goto fail`
security bug from a few years ago). Newer versions of clang
(at least) are more aggressive about warnings in this regard,
which has exposed a few warnings that are annoying. However,
they are easy to address.
Set defaults for `awk` and `egrep`, instead of
setting things multiple times when specializing on
OS, and using a default in a `case` statement.
This is cleaner and less error-prone.
Mostly turning the crank on fixing simple warnings: arrays, for
instance, can never be nil. A couple of pointers should have been
initialized to `nil` before being tested.
Some logic in `troff` was simplified: basically, an `if` statement had
a condition that must have always been true if that section of code
were being executed at all.
Introduce a new variable set in $PLAN9/config:
$egrep, which is conditionally set to either
`egrep` or `grep -E`, based on platform, and use
this when we want to invoke `egrep`.
This works around the endless warnings from GNU
grep stating that `egrep` is deprecated in favor
of `grep -E`, when run on e.g. Linux.
This bug is an intermittent annoyance and does not seem likely to be
fixed soon. It means that every so often my acme becomes unusable
because it behaves as if a mouse button is permanently set.
Avoid that issue by keeping track of mouse button state directly.
While we're about it, fix another annoying issue: under Linux the
FocusOut event reset the kstate field but not the kbuttons field,
meaning that the buttons state could inappropriately persist. This
happened occasionally by accident, but was easy to reproduce: with the
mouse button held down, drag outside the window and click Alt-Tab to
switch away from the window. We see a KeyDown event followed by FocusOut
but no KeyUp event.
Change-Id: I3708316478c80c41806d7157ae9929c6cd84b662
According to web.archive.org this link is dead since 2012/2013. According to
original issue (http://codereview.appspot.com/4251044) that translation could be
a machine translation.