Bruce Dubbs wrote:
> Bruce Dubbs wrote:
>> script: race conditions ...script: openpty
>> failed: Operation not permitted
>> <...>
>>
>> It looks like this is due to the change in glibc because this passed
>> before I update to glibc-2.18.
>
> OK, I've confirmed that the test identified by
>
> script: race conditions
>
> fails with a non-root user and passes with a root user. We can change
> this test to be ignored with:
>
> sed -i -e "/^ts_init/a\
> ts_skip_nonroot" tests/ts/script/race
This seems odd; it used to be that pt_chown was only necessary when
/dev/pts was not mounted as a devpts filesystem, and if it was, then the
kernel would do the right thing automatically (that is, the grantpt()
call, while still a good idea, is not strictly necessary, and if called
would do nothing).
It's been way too long since I've done a chapter-6 build, but aren't we
using the host's devpts setup?
...
Yeah, looking at chapter06/kernfs.html from svn, we are. So I'd be
surprised if pt_chown was actually needed inside the chroot.
But maybe something else changed. What happens if you:
cat <<'EOF' >testpt.c
#define _XOPEN_SOURCE 600
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
int main() {
int masterfd;
char buf[1024];
masterfd = posix_openpt(O_RDWR | O_NOCTTY);
if (masterfd < 0) {
perror("posix_openpt");
return 1;
}
printf("posix_openpt succeeded\n");
if (grantpt(masterfd) < 0) {
perror("grantpt");
return 1;
}
printf("grantpt succeeded; stat the new file and hit enter\n");
fgets(buf, sizeof(buf), stdin);
return 0;
}
EOF
make testpts
ls /dev/pts
<note the files present>
./testpts
^Z
ls /dev/pts
stat /dev/pts/<new file>
fg
<enter>
rm testpts testpts.c
What are the permissions and ownership of the new slave pty file? On my
system, with /dev/pts mounted and pt_chown missing, I get:
File: `/dev/pts/6'
Size: 0 Blocks: 0 IO Block: 1024 character
special file
Device: ah/10d Inode: 9 Links: 1 Device type: 88,6
Access: (0620/crw--w----) Uid: ( 501/ <me>) Gid: ( 4/ tty)
Access: 2013-08-13 22:27:12.226312570 -0700
Modify: 2013-08-13 22:27:12.226312570 -0700
Change: 2013-08-13 22:27:12.226312570 -0700
But then, this is what I'd expect, as my user has permission to chgrp
the file to tty, but even without that, it starts out owned by <me>/tty
and 0620 before the grantpt() call happens. (Verified by comparing "ls
-l /dev/pts/" and "(ls -l /dev/pts/) </dev/ptmx". With the extra handle
open, the new file is definitely owned by me/tty, and 0620.)
This is also glibc 2.10.1 (I said it'd been too long... :-) ).