summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-04-01 19:04:13 +0200
committerSimon Rettberg2019-04-01 19:04:13 +0200
commitf54118cd68329e1482c59734b665e6e66852b60a (patch)
treecbda226e15137138d39c2c0f9567e2cd5063fa2d
parentMerge branch 'master' into openslx (diff)
downloadipxe-f54118cd68329e1482c59734b665e6e66852b60a.tar.gz
ipxe-f54118cd68329e1482c59734b665e6e66852b60a.tar.xz
ipxe-f54118cd68329e1482c59734b665e6e66852b60a.zip
[login] Add "--nouser" option to just ask for password
-rw-r--r--src/hci/commands/login_cmd.c13
-rw-r--r--src/hci/tui/login_ui.c22
-rw-r--r--src/include/ipxe/login_ui.h2
3 files changed, 26 insertions, 11 deletions
diff --git a/src/hci/commands/login_cmd.c b/src/hci/commands/login_cmd.c
index c9e196437..6ed76c6f2 100644
--- a/src/hci/commands/login_cmd.c
+++ b/src/hci/commands/login_cmd.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <stdio.h>
+#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/login_ui.h>
@@ -36,10 +37,16 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
/** "login" options */
-struct login_options {};
+struct login_options {
+ /** No Username */
+ int nouser;
+};
/** "login" option list */
-static struct option_descriptor login_opts[] = {};
+static struct option_descriptor login_opts[] = {
+ OPTION_DESC ( "nouser", 'n', no_argument,
+ struct login_options, nouser, parse_flag ),
+};
/** "login" command descriptor */
static struct command_descriptor login_cmd =
@@ -61,7 +68,7 @@ static int login_exec ( int argc, char **argv ) {
return rc;
/* Show login UI */
- if ( ( rc = login_ui() ) != 0 ) {
+ if ( ( rc = login_ui( opts.nouser ) ) != 0 ) {
printf ( "Could not set credentials: %s\n",
strerror ( rc ) );
return rc;
diff --git a/src/hci/tui/login_ui.c b/src/hci/tui/login_ui.c
index 3c55325d5..56fc2fa97 100644
--- a/src/hci/tui/login_ui.c
+++ b/src/hci/tui/login_ui.c
@@ -48,12 +48,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define EDITBOX_COL ( ( COLS / 2U ) - 10U )
#define EDITBOX_WIDTH 20U
-int login_ui ( void ) {
+int login_ui ( int nouser ) {
char username[64];
char password[64];
struct edit_box username_box;
struct edit_box password_box;
- struct edit_box *current_box = &username_box;
+ struct edit_box *current_box = nouser ? &password_box : &username_box;
int key;
int rc = -EINPROGRESS;
@@ -76,11 +76,15 @@ int login_ui ( void ) {
color_set ( CPAIR_NORMAL, NULL );
erase();
attron ( A_BOLD );
- mvprintw ( USERNAME_LABEL_ROW, LABEL_COL, "Username:" );
+ if ( ! nouser ) {
+ mvprintw ( USERNAME_LABEL_ROW, LABEL_COL, "Username:" );
+ }
mvprintw ( PASSWORD_LABEL_ROW, LABEL_COL, "Password:" );
attroff ( A_BOLD );
color_set ( CPAIR_EDIT, NULL );
- draw_editbox ( &username_box );
+ if ( ! nouser ) {
+ draw_editbox ( &username_box );
+ }
draw_editbox ( &password_box );
/* Main loop */
@@ -94,11 +98,15 @@ int login_ui ( void ) {
current_box = &password_box;
break;
case KEY_UP:
- current_box = &username_box;
+ if ( ! nouser ) {
+ current_box = &username_box;
+ }
break;
case TAB:
- current_box = ( ( current_box == &username_box ) ?
- &password_box : &username_box );
+ if ( ! nouser ) {
+ current_box = ( ( current_box == &username_box ) ?
+ &password_box : &username_box );
+ }
break;
case KEY_ENTER:
if ( current_box == &username_box ) {
diff --git a/src/include/ipxe/login_ui.h b/src/include/ipxe/login_ui.h
index 313e07349..07b1dd49e 100644
--- a/src/include/ipxe/login_ui.h
+++ b/src/include/ipxe/login_ui.h
@@ -9,6 +9,6 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
-extern int login_ui ( void );
+extern int login_ui ( int nouser );
#endif /* _IPXE_LOGIN_UI_H */