#endif /* PTY_CLONE_DEVICE */
-int _DtTermPrimGetPty(char **ptySlave, char **ptyMaster)
+static int GetPty(char **ptySlave, char **ptyMaster)
{
char *c;
int ptyFd;
return(-1);
}
+/* this is a public wrapper around the previous function that runs the
+ * previous function setuid root...
+ */
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
}
#endif /* USE_STREAMS_TTCOMPAT */
+#else /* linux */
+
+ chown(ptySlave, getuid(), getgid());
+ chmod(ptySlave, 0622);
#endif /* linux */
/* success... */
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
_DtTermPrimReleasePty(char *ptySlave)
{
#include "TermHeader.h"
#include <fcntl.h>
-#ifdef ALPHA_ARCHITECTURE
+#if defined(ALPHA_ARCHITECTURE) || defined(CSRG_ARCHITECTURE) || defined(LINUX_ARCHITECTURE)
/* For TIOCSTTY definitions */
#include <sys/ioctl.h>
#endif /* ALPHA_ARCHITECTURE */
/* child...
*/
_DtTermProcessUnlock();
-#ifdef ALPHA_ARCHITECTURE
+#if defined(ALPHA_ARCHITECTURE) || defined(CSRG_ARCHITECTURE) || defined(LINUX_ARCHITECTURE)
/* establish a new session for child */
setsid();
#else
(void) setpgrp();
#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... */
pty = open(ptyName, O_RDWR, 0);
(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 */
if (ioctl(pty, TIOCSCTTY, (char *)NULL) < 0) {
(void) close(pty);
_DtTermPrimPtyGetDefaultModes();
#endif /* ALPHA_ARCHITECTURE */
+#if !defined(LINUX_ARCHITECTURE)
/* set the ownership and mode of the pty... */
(void) _DtTermPrimSetupPty(ptyName, pty);
+#endif /* LINUX_ARCHITECTURE */
/* apply the ttyModes... */
_DtTermPrimPtyInit(pty, tw->term.ttyModes, tw->term.csWidth);