Added fallback on old-style pty's, if /dev/pts is not mounted.
git-svn-id: https://shellinabox.googlecode.com/svn/trunk@73 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
parent
86dc79030d
commit
b0341e1549
3 changed files with 47 additions and 18 deletions
|
@ -1,5 +1,7 @@
|
|||
2009-02-27 Markus Gutschke <markus@shellinabox.com>
|
||||
|
||||
* Added fallback on old-style pty's, if /dev/pts is not mounted.
|
||||
|
||||
* Work-around for systems that don't define a "nogroup" group.
|
||||
|
||||
* Remove the dependency on fdopendir, which does not exist
|
||||
|
|
2
config.h
2
config.h
|
@ -95,7 +95,7 @@
|
|||
#define STDC_HEADERS 1
|
||||
|
||||
/* Most recent revision number in the version control system */
|
||||
#define VCS_REVISION "72"
|
||||
#define VCS_REVISION "73"
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "2.4"
|
||||
|
|
|
@ -565,10 +565,37 @@ static int forkPty(int *pty, int useLogin, struct Utmp **utmp,
|
|||
if (*pty >= 0) {
|
||||
NOINTR(close(*pty));
|
||||
}
|
||||
|
||||
// Try old-style pty handling
|
||||
char fname[40] = "/dev/ptyXX";
|
||||
for (const char *ptr1 = "pqrstuvwxyzabcde"; *ptr1; ptr1++) {
|
||||
fname[8] = *ptr1;
|
||||
for (const char *ptr2 = "0123456789abcdef"; *ptr2; ptr2++) {
|
||||
fname[9] = *ptr2;
|
||||
if ((*pty = NOINTR(open(fname, O_RDWR, 0))) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
grantpt(*pty);
|
||||
unlockpt(*pty);
|
||||
if (ptsname_r(*pty, ptyPath, sizeof(ptyPath)) < 0) {
|
||||
strcpy(ptyPath, fname);
|
||||
ptyPath[5] = 't';
|
||||
}
|
||||
if ((slave = NOINTR(open(ptyPath, O_RDWR|O_NOCTTY))) >= 0) {
|
||||
debug("Opened old-style pty: %s", ptyPath);
|
||||
goto success;
|
||||
}
|
||||
NOINTR(close(*pty));
|
||||
}
|
||||
}
|
||||
failure:
|
||||
*pty = -1;
|
||||
*utmp = NULL;
|
||||
return -1;
|
||||
}
|
||||
success:
|
||||
|
||||
// Fill in utmp entry
|
||||
*utmp = newUtmp(useLogin, ptyPath, peerName);
|
||||
|
|
Loading…
Reference in a new issue