aboutsummaryrefslogtreecommitdiff
path: root/pass_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'pass_util.c')
-rw-r--r--pass_util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/pass_util.c b/pass_util.c
index 47e72f2..b302c55 100644
--- a/pass_util.c
+++ b/pass_util.c
@@ -4,6 +4,8 @@
#include <string.h>
#include <sys/stat.h>
#include <linux/limits.h>
+#include <termios.h>
+#include <stdio.h>
#include "pass_util.h"
#include "util.h"
@@ -113,3 +115,24 @@ const char *pass_cat(const char *path)
r = gpg_decrypt(fpr, pass_path, pass_out, sizeof(pass_out));
return r ? NULL : pass_out;
}
+
+size_t pass_getpass(char **lineptr, size_t *n, FILE *stream)
+{
+ int r;
+ struct termios new, old;
+
+ r = tcgetattr(fileno(stream), &old);
+ if (r)
+ return -1;
+
+ new = old;
+ new.c_lflag &= ~ECHO;
+ r = tcsetattr(fileno(stream), TCSAFLUSH, &new);
+ if (r)
+ return -1;
+
+ r = getline (lineptr, n, stream);
+ (void) tcsetattr (fileno (stream), TCSAFLUSH, &old);
+
+ return r;
+}