screen broken on Slackware-current?
[email protected] Fri, 7 Aug 2015 01:43:45 +0100 (BST)
| Newsgroups | gmane.linux.slackware |
|---|---|
| Message-ID | <[email protected]> |
Dear All,
I am running Slackware-current (32-bit) and have not been able to run
screen (the screen manager program) for some time now. It fails with
$ screen
Bad tty '/dev/pts/0'
Digging into the source, the problem is in CheckTtyname() in tty.c
which calls the realpath() function on the pty device name which
returns a NULL pointer result for the canonicalized pathname.
The problem is not related to the target being a device special file
as the following demo code (largely copied from CheckTtyname() in
tty.c) reproduces,
/tmp/screen-4.3.1$ cat tomdeb.c
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
int main(int argc, char **argv) {
char *tty;
{
char * real;
char resolved_path[PATH_MAX];
errno=0;
tty = argv[1];
printf ("argv[1]=\"%s\"\n", argv[1]);
printf ("PATH_MAX=%d\n", PATH_MAX);
real = realpath(tty,resolved_path);
perror ("call1");
printf ("tty=\"%s\" real=\"%s\" resolved_path=\"%s\"\n", tty, real, resolved_path);
real = realpath(tty, NULL);
perror ("call2");
printf ("tty=\"%s\" real=\"%s\"\n", tty, real);
if (!real) {
printf ("returning -1\n");
return -1;
}
free(real);
return 0;
}
}
/tmp/screen-4.3.1$ cc -Wall -o tomdeb tomdeb.c
/tmp/screen-4.3.1$ ./tomdeb $PWD/tomdeb.c
argv[1]="/tmp/screen-4.3.1/tomdeb.c"
PATH_MAX=4096
call1: Success
tty="/tmp/screen-4.3.1/tomdeb.c" real="/tmp/screen-4.3.1/tomdeb.c" resolved_path="/tmp/screen-4.3.1/tomdeb.c"
call2: Invalid argument
tty="/tmp/screen-4.3.1/tomdeb.c" real="(null)"
returning -1
The first call to realpath() returns the expected result but the
second call which is as used in CheckTtyname() in tty.c returns a NULL
pointer. According to the man page,
> char *realpath(const char *path, char *resolved_path);
>
> If resolved_path is specified as NULL, then realpath() uses malloc(3)
> to allocate a buffer of up to PATH_MAX bytes to hold the resolved
> pathname, and returns a pointer to this buffer.
The man page also reports,
> EINVAL path is NULL. (In glibc versions before 2.3, this error is
> also returned if resolved_path is NULL.)
Slackware-current is using glibc-2.21.
I also tried the demo code on an old Slackware 11.1 system which has
glibc-2.5 and it displays the same fault but screen works. Checking
the screen-4.0.3 source code (the version installed on my
Slackware-11.1 system) reveals it does not use realpath(). Finally I
tried the demo code on SLC5 & SLC6 (based on RHEL5 & RHEL6) systems
where both calls return the correct results.
Does anyone else have this problem with screen on their
Slackware-current systems? Googling the error did now show much of
interest...
I am running a 3.18.11 kernel.
Regards
Tom Crane
Ps. Also posted to alt.os.linux.slackware
--
Tom Crane, Dept. Physics, Royal Holloway, University of London, Egham Hill,
Egham, Surrey, TW20 0EX, England.
Email: T dot Crane at rhul dot ac dot uk
Fax: +44 (0) 1784 472794