/*--------------------------------MISC----------------------------------*/
/*
- * Disable to reset tty device to pre-incovation state
- */
-#define RESET_TTY_TO_COMMON_DEFAULTS
-
-/*
* Only log in wtmp and lastlog files when we're a login shell (-ls option)
*/
#define LOG_ONLY_ON_LOGIN
static inline int
get_pty_streams (int *fd_tty, char **ttydev)
{
-#ifdef NO_SETOWNER_TTYDEV
+#if defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT)
+# if defined(PTYS_ARE_GETPT) || defined(PTYS_ARE_POSIX) || defined(PTYS_ARE_PTMX)
int pfd;
# if defined(PTYS_ARE_GETPT)
close (pfd);
}
+# endif
#endif
return -1;
#endif
}
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef NO_SETOWNER_TTYDEV
static struct ttyconf {
gid_t gid;
mode_t mode;
}
} ttyconf;
-/////////////////////////////////////////////////////////////////////////////
-
-void
-rxvt_ptytty_unix::privileges (rxvt_privaction action)
-{
- if (!name || !*name)
- return;
-
- if (action == SAVE)
- {
- chown (name, getuid (), ttyconf.gid); /* fail silently */
- chmod (name, ttyconf.mode);
-# ifdef HAVE_REVOKE
- revoke (name);
-# endif
- }
- else
- { /* action == RESTORE */
- chmod (name, RESTORE_TTY_MODE);
- chown (name, 0, ttyconf.gid);
- }
-}
-#endif
-
rxvt_ptytty_unix::rxvt_ptytty_unix ()
{
pty = tty = -1;
void
rxvt_ptytty_unix::put ()
{
-#ifndef NO_SETOWNER_TTYDEV
- privileges (RESTORE);
-#endif
+ chmod (name, RESTORE_TTY_MODE);
+ chown (name, 0, ttyconf.gid);
if (pty >= 0) close (pty);
close_tty ();
if (tty < 0)
{
#ifndef NO_SETOWNER_TTYDEV
- privileges (SAVE);
+ chown (name, getuid (), ttyconf.gid); /* fail silently */
+ chmod (name, ttyconf.mode);
+# ifdef HAVE_REVOKE
+ revoke (name);
+# endif
#endif
if ((tty = get_tty (name)) < 0)
# define NO_SETOWNER_TTYDEV 1
# endif
#endif
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(PTYS_ARE_OPENPTY)
# define NO_SETOWNER_TTYDEV 1
#endif
#if UTMP_SUPPORT
-# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX)
+# if !defined(RXVT_UTMPX_FILE) || !defined(HAVE_STRUCT_UTMPX) || defined(__GLIBC__)
# undef HAVE_UTMPX_H
# undef HAVE_STRUCT_UTMPX
# endif
{
char *name;
-#ifndef RESET_TTY_TO_COMMON_DEFAULTS
- struct stat savestat; /* original status of our tty */
-#endif
-#ifndef NO_SETOWNER_TTYDEV
- void privileges (rxvt_privaction action);
- bool saved;
-#endif
public:
rxvt_ptytty_unix ();