diff options
| author | Ray Strode <rstrode@redhat.com> | 2008-05-15 15:48:59 -0400 |
|---|---|---|
| committer | Ray Strode <rstrode@redhat.com> | 2008-05-15 15:50:37 -0400 |
| commit | 262e8b5f75c7a9897446703e5815b06e47f0fcfb (patch) | |
| tree | 5f6133d7dec339dba54eb640266a3d032bea04d4 /src/splash-plugins | |
| parent | 3b86388c3bdffe32663ec0ea2237bfaa7ba630b0 (diff) | |
| download | plymouth-262e8b5f75c7a9897446703e5815b06e47f0fcfb.tar.gz plymouth-262e8b5f75c7a9897446703e5815b06e47f0fcfb.tar.xz plymouth-262e8b5f75c7a9897446703e5815b06e47f0fcfb.zip | |
add preliminary support for asking for password during boot sequence
(Only in text plugin so far)
Diffstat (limited to 'src/splash-plugins')
| -rw-r--r-- | src/splash-plugins/text/text.c | 34 |
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; |
