aboutsummaryrefslogtreecommitdiffstats
path: root/src/cerberus.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-11-18 18:29:22 +0100
committerMattias Andrée <maandree@operamail.com>2013-11-18 18:29:22 +0100
commit44716a78aa42f999ac618cec1dc04ddb0c2c42e0 (patch)
tree47fe1fe4a3bbfdad403308e6565aebccd8d5ba01 /src/cerberus.c
parentconfs (diff)
downloadlibpassphrase-44716a78aa42f999ac618cec1dc04ddb0c2c42e0.tar.gz
libpassphrase-44716a78aa42f999ac618cec1dc04ddb0c2c42e0.tar.bz2
libpassphrase-44716a78aa42f999ac618cec1dc04ddb0c2c42e0.tar.xz
use tty group
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/cerberus.c')
-rw-r--r--src/cerberus.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/cerberus.c b/src/cerberus.c
index 2199d7b..e3f3f95 100644
--- a/src/cerberus.c
+++ b/src/cerberus.c
@@ -19,6 +19,11 @@
#include "cerberus.h"
+#ifndef USE_TTY_GROUP
+#define tty_group 0
+#endif
+
+
/**
* Mane method
*
@@ -33,6 +38,10 @@ int main(int argc, char** argv)
char* passphrase = NULL;
char preserve_env = 0;
char skip_auth = 0;
+ #ifdef USE_TTY_GROUP
+ gid_t tty_group = 0;
+ struct group* group;
+ #endif
struct passwd* entry;
@@ -117,7 +126,11 @@ int main(int argc, char** argv)
/* Make sure nopony is spying */
- secure_tty();
+ #ifdef USE_TTY_GROUP
+ if ((group = getgrnam("tty")))
+ tty_group = group->gr_gid;
+ #endif
+ secure_tty(tty_group);
/* Set up clean quiting and time out */
@@ -170,7 +183,7 @@ int main(int argc, char** argv)
/* Reset terminal ownership and mode */
- chown_tty(0, -1, 0);
+ chown_tty(0, tty_group, 0);
return 0;
}