All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Cryptomount keyfile support
@ 2022-05-20 19:32 Glenn Washburn
  2022-05-20 19:32 ` [PATCH v3 1/5] cryptodisk: luks: Unify grub_cryptodisk_dev function names Glenn Washburn
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Glenn Washburn @ 2022-05-20 19:32 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper
  Cc: Denis 'GNUtoo' Carikli, Patrick Steinhardt, John Lane,
	Glenn Washburn

Uupdates from v2:
 * Use one error message for all string to interger conversion errors,
   suggested by Daniel
 * Move placement of keyfile_size == 0 check

Updates from v1:
 * Make some changes suggested by Daniel
 * Improve error message for grub_strtoull() failures
 * Add patch to use enum constants to index parsed option array

Glenn

Denis 'GNUtoo' Carikli (2):
  cryptodisk: luks: Unify grub_cryptodisk_dev function names
  cryptodisk: geli: Unify grub_cryptodisk_dev function names

Glenn Washburn (2):
  cryptodisk: Use enum constants as indexes into cryptomount option
    array
  docs: Add documentation on keyfile option to cryptomount

John Lane (1):
  cryptodisk: Add options to cryptomount to support keyfiles

 docs/grub.texi              |  14 +++--
 grub-core/disk/cryptodisk.c | 110 ++++++++++++++++++++++++++++++++----
 grub-core/disk/geli.c       |   8 +--
 grub-core/disk/luks.c       |   4 +-
 include/grub/cryptodisk.h   |   2 +
 include/grub/file.h         |   2 +
 6 files changed, 119 insertions(+), 21 deletions(-)

Interdiff against v2:
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
index ecbda7ce9..e2b8636e4 100644
--- a/grub-core/disk/cryptodisk.c
+++ b/grub-core/disk/cryptodisk.c
@@ -1188,7 +1188,6 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)
 
   if (state[OPTION_KEYFILE].set) /* keyfile */
     {
-      char tmp_errmsg[GRUB_MAX_ERRMSG];
       const char *p = NULL;
       grub_file_t keyfile;
       unsigned long long keyfile_offset = 0, keyfile_size = 0;
@@ -1199,20 +1198,9 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)
 	  keyfile_offset = grub_strtoull (state[OPTION_KEYFILE_OFFSET].arg, &p, 0);
 
 	  if (state[OPTION_KEYFILE_OFFSET].arg[0] == '\0' || *p != '\0')
-	    {
-	      if (grub_errno != GRUB_ERR_NONE)
-		{
-		  grub_strncpy (tmp_errmsg, grub_errmsg, GRUB_MAX_ERRMSG);
-		  return grub_error (grub_errno,
-				     N_("non-numeric or invalid keyfile offset `%s': %s"),
-				     state[OPTION_KEYFILE_OFFSET].arg, tmp_errmsg);
-		}
-	      else
-		return grub_error (GRUB_ERR_BAD_ARGUMENT,
-				   N_("invalid keyfile offset `%s': non-numeric"
-				      " characters at end of number"),
-				   state[OPTION_KEYFILE_OFFSET].arg);
-	    }
+	    return grub_error (grub_errno,
+			       N_("non-numeric or invalid keyfile offset `%s'"),
+			       state[OPTION_KEYFILE_OFFSET].arg);
 	}
 
       if (state[OPTION_KEYFILE_SIZE].set) /* keyfile-size */
@@ -1221,28 +1209,17 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)
 	  keyfile_size = grub_strtoull (state[OPTION_KEYFILE_SIZE].arg, &p, 0);
 
 	  if (state[OPTION_KEYFILE_SIZE].arg[0] == '\0' || *p != '\0')
-	    {
-	      if (grub_errno != GRUB_ERR_NONE)
-		{
-		  grub_strncpy (tmp_errmsg, grub_errmsg, GRUB_MAX_ERRMSG);
-		  return grub_error (grub_errno,
-				     N_("non-numeric or invalid keyfile offset `%s': %s"),
-				     state[OPTION_KEYFILE_SIZE].arg, tmp_errmsg);
-		}
-	      else
-		return grub_error (GRUB_ERR_BAD_ARGUMENT,
-				   N_("invalid keyfile offset `%s': non-numeric"
-				      " characters at end of number"),
-				   state[OPTION_KEYFILE_SIZE].arg);
-	    }
+	    return grub_error (grub_errno,
+			       N_("non-numeric or invalid keyfile size `%s'"),
+			       state[OPTION_KEYFILE_SIZE].arg);
+
+	  if (keyfile_size == 0)
+	    return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("key file size is 0"));
 
 	  if (keyfile_size > GRUB_CRYPTODISK_MAX_KEYFILE_SIZE)
 	    return grub_error (GRUB_ERR_OUT_OF_RANGE,
 			       N_("key file size exceeds maximum (%d)"),
 			       GRUB_CRYPTODISK_MAX_KEYFILE_SIZE);
-
-	  if (keyfile_size == 0)
-	    return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("key file size is 0"));
 	}
 
       keyfile = grub_file_open (state[OPTION_KEYFILE].arg,
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-26 18:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-20 19:32 [PATCH v3 0/5] Cryptomount keyfile support Glenn Washburn
2022-05-20 19:32 ` [PATCH v3 1/5] cryptodisk: luks: Unify grub_cryptodisk_dev function names Glenn Washburn
2022-05-20 19:32 ` [PATCH v3 2/5] cryptodisk: geli: " Glenn Washburn
2022-05-20 19:32 ` [PATCH v3 3/5] cryptodisk: Add options to cryptomount to support keyfiles Glenn Washburn
2022-05-26 14:24   ` Daniel Kiper
2022-05-26 18:57     ` Glenn Washburn
2022-05-20 19:32 ` [PATCH v3 4/5] cryptodisk: Use enum constants as indexes into cryptomount option array Glenn Washburn
2022-05-20 19:32 ` [PATCH v3 5/5] docs: Add documentation on keyfile option to cryptomount Glenn Washburn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.