summarylogtreecommitdiffstats
path: root/getpasswd.c
diff options
context:
space:
mode:
authorMauro Santos2015-11-10 00:55:42 +0000
committerMauro Santos2015-11-10 00:55:42 +0000
commit2a9958aed5c09a50e6080d672fcd3469d82201ad (patch)
tree298cef4a881fe9113deb02fc2e56d4d9926fa9c8 /getpasswd.c
parent16cd45fae2ab67ee94ca3e362b74f32e6e459b3d (diff)
downloadaur-2a9958aed5c09a50e6080d672fcd3469d82201ad.tar.gz
Add custom PBA script to support keyfile, yubikey and password.
Diffstat (limited to 'getpasswd.c')
-rw-r--r--getpasswd.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/getpasswd.c b/getpasswd.c
new file mode 100644
index 000000000000..8cda21159b11
--- /dev/null
+++ b/getpasswd.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <termios.h>
+
+int main(){
+
+ struct termios termold, termnew;
+ tcgetattr(fileno(stdin), &termold);
+ termnew = termold;
+ termnew.c_lflag &= ~ECHO;
+ termnew.c_cc[VINTR] = '\0';
+ termnew.c_cc[VEOF] = '\0';
+ termnew.c_cc[VKILL] = '\0';
+ termnew.c_cc[VLNEXT] = '\0';
+ termnew.c_cc[VQUIT] = '\0';
+ termnew.c_cc[VSTART] = '\0';
+ termnew.c_cc[VSTOP] = '\0';
+ termnew.c_cc[VSUSP] = '\0';
+ termnew.c_cc[VWERASE] = '\0';
+ tcsetattr(fileno(stdin), TCSANOW, &termnew);
+
+ char *line = NULL;
+ size_t len = 0;
+ size_t read;
+ read = getline(&line, &len, stdin);
+
+ tcsetattr(fileno(stdin), TCSANOW, &termold);
+
+ printf("%.*s",(int)read-1,line);
+
+ free(line);
+
+ return 0;
+
+}
+
+/* Using getpass() - deprecated
+ *
+ * #include <stdio.h>
+ * #include <unistd.h>
+ *
+ * int main(){
+ * char *passwd = getpass("");
+ * printf("%s",passwd);
+ * }
+ *
+ */