aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cerberus.c12
-rw-r--r--src/cerberus.h1
-rw-r--r--src/security.c4
3 files changed, 15 insertions, 2 deletions
diff --git a/src/cerberus.c b/src/cerberus.c
index f20e600..e52a48f 100644
--- a/src/cerberus.c
+++ b/src/cerberus.c
@@ -53,6 +53,8 @@ char* passphrase = NULL;
*/
int main(int argc, char** argv)
{
+ char* tty_device = ttyname(STDIN_FILENO);
+
do_login(argc, argv);
/* Ignore signals */
@@ -63,6 +65,16 @@ int main(int argc, char** argv)
while ((wait(NULL) == -1) && (errno == EINTR))
;
+ /* Regain access to the terminal */
+ if (tty_device)
+ {
+ int fd = open(tty_device, O_RDWR | O_NONBLOCK);
+ if (fd)
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ }
+
/* Reset terminal ownership and mode */
chown_tty(0, tty_group, 0);
diff --git a/src/cerberus.h b/src/cerberus.h
index 5851524..69df492 100644
--- a/src/cerberus.h
+++ b/src/cerberus.h
@@ -28,6 +28,7 @@
#include <errno.h>
#include <stropts.h>
#include <termios.h>
+#include <fcntl.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/types.h>
diff --git a/src/security.c b/src/security.c
index 3abd7b4..eb4bd3c 100644
--- a/src/security.c
+++ b/src/security.c
@@ -132,8 +132,8 @@ void chown_tty(uid_t owner, gid_t group, char with_fail)
vcs -= VCS_LEN;
vcsa -= VCSA_LEN;
- strcpy(vcs, VCS);
- strcpy(vcsa, VCSA);
+ strncpy(vcs, VCS, VCS_LEN);
+ strncpy(vcsa, VCSA, VCSA_LEN);
#ifdef OWN_VCS
if (chown(vcs, owner, group) && with_fail) fail("chown");