mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dtterm: fixes so job control will work.
This commit is contained in:
parent
62b669a6af
commit
91f7988cf3
2 changed files with 48 additions and 5 deletions
|
@ -67,7 +67,7 @@ static char rcs_id[] = "$XConsortium: TermPrimGetPty-svr4.c /main/1 1996/04/21 1
|
||||||
#endif /* PTY_CLONE_DEVICE */
|
#endif /* PTY_CLONE_DEVICE */
|
||||||
|
|
||||||
|
|
||||||
int _DtTermPrimGetPty(char **ptySlave, char **ptyMaster)
|
static int GetPty(char **ptySlave, char **ptyMaster)
|
||||||
{
|
{
|
||||||
char *c;
|
char *c;
|
||||||
int ptyFd;
|
int ptyFd;
|
||||||
|
@ -233,8 +233,26 @@ ok:
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* this is a public wrapper around the previous function that runs the
|
||||||
|
* previous function setuid root...
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
_DtTermPrimSetupPty(char *ptySlave, int ptyFd)
|
_DtTermPrimGetPty(char **ptySlave, char **ptyMaster)
|
||||||
|
{
|
||||||
|
int retValue;
|
||||||
|
|
||||||
|
/* this function needs to be suid root... */
|
||||||
|
(void) _DtTermPrimToggleSuidRoot(True);
|
||||||
|
retValue = GetPty(ptySlave, ptyMaster);
|
||||||
|
/* we now need to turn off setuid root... */
|
||||||
|
(void) _DtTermPrimToggleSuidRoot(False);
|
||||||
|
|
||||||
|
return(retValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
SetupPty(char *ptySlave, int ptyFd)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The following "pushes" were done at GetPty time, but
|
* The following "pushes" were done at GetPty time, but
|
||||||
|
@ -262,12 +280,30 @@ _DtTermPrimSetupPty(char *ptySlave, int ptyFd)
|
||||||
}
|
}
|
||||||
#endif /* USE_STREAMS_TTCOMPAT */
|
#endif /* USE_STREAMS_TTCOMPAT */
|
||||||
|
|
||||||
|
#else /* linux */
|
||||||
|
|
||||||
|
chown(ptySlave, getuid(), getgid());
|
||||||
|
chmod(ptySlave, 0622);
|
||||||
#endif /* linux */
|
#endif /* linux */
|
||||||
|
|
||||||
/* success... */
|
/* success... */
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_DtTermPrimSetupPty(char *ptySlave, int ptyFd)
|
||||||
|
{
|
||||||
|
int retValue;
|
||||||
|
|
||||||
|
/* this function needs to be suid root... */
|
||||||
|
(void) _DtTermPrimToggleSuidRoot(True);
|
||||||
|
retValue = SetupPty(ptySlave, ptyFd);
|
||||||
|
/* we now need to turn off setuid root... */
|
||||||
|
(void) _DtTermPrimToggleSuidRoot(False);
|
||||||
|
|
||||||
|
return(retValue);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_DtTermPrimReleasePty(char *ptySlave)
|
_DtTermPrimReleasePty(char *ptySlave)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ static char rcs_id[] = "$TOG: TermPrimSubproc.c /main/11 1998/04/20 12:45:57 mgr
|
||||||
|
|
||||||
#include "TermHeader.h"
|
#include "TermHeader.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifdef ALPHA_ARCHITECTURE
|
#if defined(ALPHA_ARCHITECTURE) || defined(CSRG_ARCHITECTURE) || defined(LINUX_ARCHITECTURE)
|
||||||
/* For TIOCSTTY definitions */
|
/* For TIOCSTTY definitions */
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif /* ALPHA_ARCHITECTURE */
|
#endif /* ALPHA_ARCHITECTURE */
|
||||||
|
@ -461,7 +461,7 @@ _DtTermPrimSubprocExec(Widget w,
|
||||||
/* child...
|
/* child...
|
||||||
*/
|
*/
|
||||||
_DtTermProcessUnlock();
|
_DtTermProcessUnlock();
|
||||||
#ifdef ALPHA_ARCHITECTURE
|
#if defined(ALPHA_ARCHITECTURE) || defined(CSRG_ARCHITECTURE) || defined(LINUX_ARCHITECTURE)
|
||||||
/* establish a new session for child */
|
/* establish a new session for child */
|
||||||
setsid();
|
setsid();
|
||||||
#else
|
#else
|
||||||
|
@ -469,6 +469,11 @@ _DtTermPrimSubprocExec(Widget w,
|
||||||
(void) setpgrp();
|
(void) setpgrp();
|
||||||
#endif /* ALPHA_ARCHITECTURE */
|
#endif /* ALPHA_ARCHITECTURE */
|
||||||
|
|
||||||
|
#if defined(LINUX_ARCHITECTURE)
|
||||||
|
/* set the ownership and mode of the pty... */
|
||||||
|
(void) _DtTermPrimSetupPty(ptyName, pty);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* open the pty slave as our controlling terminal... */
|
/* open the pty slave as our controlling terminal... */
|
||||||
pty = open(ptyName, O_RDWR, 0);
|
pty = open(ptyName, O_RDWR, 0);
|
||||||
|
|
||||||
|
@ -477,7 +482,7 @@ _DtTermPrimSubprocExec(Widget w,
|
||||||
(void) _exit(1);
|
(void) _exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ALPHA_ARCHITECTURE
|
#if defined(ALPHA_ARCHITECTURE) || defined(CSRG_ARCHITECTURE) || defined(LINUX_ARCHITECTURE)
|
||||||
/* BSD needs to do this to acquire pty as controlling terminal */
|
/* BSD needs to do this to acquire pty as controlling terminal */
|
||||||
if (ioctl(pty, TIOCSCTTY, (char *)NULL) < 0) {
|
if (ioctl(pty, TIOCSCTTY, (char *)NULL) < 0) {
|
||||||
(void) close(pty);
|
(void) close(pty);
|
||||||
|
@ -490,8 +495,10 @@ _DtTermPrimSubprocExec(Widget w,
|
||||||
_DtTermPrimPtyGetDefaultModes();
|
_DtTermPrimPtyGetDefaultModes();
|
||||||
#endif /* ALPHA_ARCHITECTURE */
|
#endif /* ALPHA_ARCHITECTURE */
|
||||||
|
|
||||||
|
#if !defined(LINUX_ARCHITECTURE)
|
||||||
/* set the ownership and mode of the pty... */
|
/* set the ownership and mode of the pty... */
|
||||||
(void) _DtTermPrimSetupPty(ptyName, pty);
|
(void) _DtTermPrimSetupPty(ptyName, pty);
|
||||||
|
#endif /* LINUX_ARCHITECTURE */
|
||||||
|
|
||||||
/* apply the ttyModes... */
|
/* apply the ttyModes... */
|
||||||
_DtTermPrimPtyInit(pty, tw->term.ttyModes, tw->term.csWidth);
|
_DtTermPrimPtyInit(pty, tw->term.ttyModes, tw->term.csWidth);
|
||||||
|
|
Loading…
Reference in a new issue