summaryrefslogtreecommitdiffstats
path: root/usr.bin/tip
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2008-05-03 02:29:02 +0000
committerbms <bms@FreeBSD.org>2008-05-03 02:29:02 +0000
commitb1c66371110ecbd60db024a5eb831c018c9ba79b (patch)
tree373309d6103a82792e12534680fa8ae9adf54c39 /usr.bin/tip
parentc683ca0c36a3440680ddb588be16a225b68b96b4 (diff)
downloadFreeBSD-src-b1c66371110ecbd60db024a5eb831c018c9ba79b.zip
FreeBSD-src-b1c66371110ecbd60db024a5eb831c018c9ba79b.tar.gz
Relinquish exclusive TTY access when tip(1) or cu(1) exit.
Previously they would have left TIOCEXCL enabled, requiring either a reboot or use of tip/cu as the root user. Observed when running QEMU with character devices redirected to pty instances. MFC after: 2 weeks
Diffstat (limited to 'usr.bin/tip')
-rw-r--r--usr.bin/tip/tip/cmds.c1
-rw-r--r--usr.bin/tip/tip/tip.c9
-rw-r--r--usr.bin/tip/tip/tip.h1
-rw-r--r--usr.bin/tip/tip/uucplock.c1
4 files changed, 12 insertions, 0 deletions
diff --git a/usr.bin/tip/tip/cmds.c b/usr.bin/tip/tip/cmds.c
index f6badcb..50cedc4 100644
--- a/usr.bin/tip/tip/cmds.c
+++ b/usr.bin/tip/tip/cmds.c
@@ -666,6 +666,7 @@ tipabort(char *msg)
daemon_uid();
(void)uu_unlock(uucplock);
unraw();
+ unexcl();
exit(0);
}
diff --git a/usr.bin/tip/tip/tip.c b/usr.bin/tip/tip/tip.c
index 22b362c..058a99b 100644
--- a/usr.bin/tip/tip/tip.c
+++ b/usr.bin/tip/tip/tip.c
@@ -325,6 +325,15 @@ unraw(void)
tcsetattr(0, TCSADRAIN, &defterm);
}
+/*
+ * give up exclusive tty access
+ */
+void
+unexcl()
+{
+ ioctl(FD, TIOCNXCL, 0);
+}
+
static jmp_buf promptbuf;
/*
diff --git a/usr.bin/tip/tip/tip.h b/usr.bin/tip/tip/tip.h
index 5e9a37e..cd679ed 100644
--- a/usr.bin/tip/tip/tip.h
+++ b/usr.bin/tip/tip/tip.h
@@ -341,6 +341,7 @@ void timeout(int);
void tipabort(char *);
void tipout(void);
void user_uid(void);
+void unexcl(void);
void unraw(void);
void v3451_abort(void);
void v3451_disconnect(void);
diff --git a/usr.bin/tip/tip/uucplock.c b/usr.bin/tip/tip/uucplock.c
index 81e463e..c82ea78 100644
--- a/usr.bin/tip/tip/uucplock.c
+++ b/usr.bin/tip/tip/uucplock.c
@@ -126,5 +126,6 @@ uu_unlock(char *ttyname)
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
(void)snprintf(tbuf, sizeof tbuf, _PATH_LOCKDIRNAME, ttyname);
+ unexcl();
return(unlink(tbuf));
}
OpenPOWER on IntegriCloud