]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[dynui] Add concept of a secret user interface item
authorMichael Brown <mcb30@ipxe.org>
Thu, 20 Jun 2024 23:21:28 +0000 (16:21 -0700)
committerMichael Brown <mcb30@ipxe.org>
Thu, 20 Jun 2024 23:24:38 +0000 (16:24 -0700)
For interactive forms, the concept of a secret value becomes
meaningful (e.g. for password fields).

Add a flag to indicate that an item represents a secret value, and
allow this flag to be set via the "--secret" option of the "item"
command.

This flag has no meaning for menu items, but is silently accepted
anyway to keep the code size minimal.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/hci/commands/dynui_cmd.c
src/include/ipxe/dynui.h

index 557c5db5d691e295a261c49afcf3104c10fb658f..5aed3d0341d24d8457eed0f12d825bb4d9c3d9b8 100644 (file)
@@ -116,6 +116,8 @@ struct item_options {
        unsigned int key;
        /** Use as default */
        int is_default;
+       /** Value is a secret */
+       int is_secret;
        /** Use as a separator */
        int is_gap;
 };
@@ -128,6 +130,8 @@ static struct option_descriptor item_opts[] = {
                      struct item_options, key, parse_key ),
        OPTION_DESC ( "default", 'd', no_argument,
                      struct item_options, is_default, parse_flag ),
+       OPTION_DESC ( "secret", 's', no_argument,
+                     struct item_options, is_secret, parse_flag ),
        OPTION_DESC ( "gap", 'g', no_argument,
                      struct item_options, is_gap, parse_flag ),
 };
@@ -177,6 +181,8 @@ static int item_exec ( int argc, char **argv ) {
        /* Add dynamic user interface item */
        if ( opts.is_default )
                flags |= DYNUI_DEFAULT;
+       if ( opts.is_secret )
+               flags |= DYNUI_SECRET;
        item = add_dynui_item ( dynui, name, ( text ? text : "" ), flags,
                                opts.key );
        if ( ! item ) {
index 5ba007032f5b639f9e1700b2edc921d3ff563984..5029e5850511e55e284aabb63d3d69c37d272bc2 100644 (file)
@@ -44,6 +44,9 @@ struct dynamic_item {
 /** Dynamic user interface item is default selection */
 #define DYNUI_DEFAULT 0x0001
 
+/** Dynamic user interface item represents a secret */
+#define DYNUI_SECRET 0x0002
+
 extern struct dynamic_ui * create_dynui ( const char *name, const char *title );
 extern struct dynamic_item * add_dynui_item ( struct dynamic_ui *dynui,
                                              const char *name,