zsh is nearing a release and since OpenBSD is too, I thought I'd get
some early testing in. (Though at this point the timing won't work out.)
A pty test has been failing for a while, but a newly added test is now
hanging on [1]
ret = read(master, &syncch, 1);
I believe the root cause basically boils down to opening /dev/ptyxx for
some xx and then opening the corresponding /dev/ttyxx fails for _pbuild
but not as my user. The below code runs for me, but fails when run under
_pbuild.
Normally I'd try to dig further, but I don't know if I'll have time
before it's too late for the release.
1: https://github.com/zsh-users/zsh/blob/29f97c1f9447335c8f088f1cf809d90004e78053/Src/Modules/zpty.c#L473
% ./a.out
3: /dev/ptyp5
4: /dev/ttyp5
% doas -u _pbuild ./a.out
3: /dev/ptyp5
a.out: open: Permission denied
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static int
get_pty(char *path) {
const char char1[] = "pqrstuvwxyzPQRST";
const char char2[] = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *p1, *p2;
int fd;
strcpy(path, "/dev/ptyxx");
for (p1 = char1; *p1; p1++) {
path[8] = *p1;
for (p2 = char2; *p2; p2++) {
path[9] = *p2;
if ((fd = open(path, O_RDWR|O_NOCTTY)) >= 0) {
return fd;
}
}
}
return -1;
}
int
main() {
char path[11];
int ptyfd, ttyfd;
if ((ptyfd = get_pty(path)) == -1) {
err(1, "get_pty");
}
printf("%d: %s\n", ptyfd, path);
path[5] = 't';
if ((ttyfd = open(path, O_RDWR|O_NOCTTY)) == -1) {
err(1, "open");
}
printf("%d: %s\n", ttyfd, path);
}
No comments:
Post a Comment