summaryrefslogtreecommitdiffstats
path: root/src/splash-plugins/text/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/splash-plugins/text/text.c')
-rw-r--r--src/splash-plugins/text/text.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/splash-plugins/text/text.c b/src/splash-plugins/text/text.c
index fc76817..d2f9b99 100644
--- a/src/splash-plugins/text/text.c
+++ b/src/splash-plugins/text/text.c
@@ -35,8 +35,9 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <values.h>
+#include <termios.h>
#include <unistd.h>
+#include <values.h>
#include "ply-boot-splash-plugin.h"
#include "ply-event-loop.h"
@@ -157,6 +158,34 @@ attach_to_event_loop (ply_boot_splash_plugin_t *plugin,
plugin);
}
+char *
+ask_for_password (ply_boot_splash_plugin_t *plugin)
+{
+ char answer[1024];
+ struct termios initial_term_attributes;
+ struct termios noecho_term_attributes;
+
+ tcgetattr (STDIN_FILENO, &initial_term_attributes);
+ noecho_term_attributes = initial_term_attributes;
+ noecho_term_attributes.c_lflag &= ~ECHO;
+
+ printf ("Password: ");
+
+ if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &noecho_term_attributes) != 0) {
+ fprintf (stderr, "Could not set terminal attributes\n");
+ return NULL;
+ }
+
+ fgets (answer, sizeof (answer), stdin);
+ answer[strlen (answer) - 1] = '\0';
+
+ tcsetattr (STDIN_FILENO, TCSANOW, &initial_term_attributes);
+
+ printf ("\n");
+
+ return strdup (answer);
+}
+
ply_boot_splash_plugin_interface_t *
ply_boot_splash_plugin_get_interface (void)
{
@@ -167,7 +196,8 @@ ply_boot_splash_plugin_get_interface (void)
.show_splash_screen = show_splash_screen,
.update_status = update_status,
.hide_splash_screen = hide_splash_screen,
- .attach_to_event_loop = attach_to_event_loop
+ .attach_to_event_loop = attach_to_event_loop,
+ .ask_for_password = ask_for_password,
};
return &plugin_interface;