nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0101-grub-core-commands-verify.c-Mark-messages-for-transl.patch

f96e0b
From 4ae6c0a73dc061e5cd6510af7fc57c8e87748841 Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Sat, 12 Jan 2013 16:31:17 +0100
f96e0b
Subject: [PATCH 101/482] 	* grub-core/commands/verify.c: Mark messages
f96e0b
 for translating.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                   |  4 ++
f96e0b
 grub-core/commands/verify.c | 93 +++++++++++++++++++++++----------------------
f96e0b
 2 files changed, 52 insertions(+), 45 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 4ac0aa6..b527f7a 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,9 @@
f96e0b
 2013-01-12  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
+	* grub-core/commands/verify.c: Mark messages for translating.
f96e0b
+
f96e0b
+2013-01-12  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
 	* grub-core/lib/libgcrypt_wrap/mem.c (gcry_x*alloc): Make out of memory
f96e0b
 	fatal.
f96e0b
 
f96e0b
diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c
f96e0b
index 415e4bf..66a027f 100644
f96e0b
--- a/grub-core/commands/verify.c
f96e0b
+++ b/grub-core/commands/verify.c
f96e0b
@@ -53,7 +53,8 @@ read_packet_header (grub_file_t sig, grub_uint8_t *out_type, grub_size_t *len)
f96e0b
     default:
f96e0b
       if (grub_errno)
f96e0b
 	return grub_errno;
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+      /* TRANSLATORS: it's about GNUPG signatures.  */
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
     }
f96e0b
 
f96e0b
   if (type == 0)
f96e0b
@@ -63,12 +64,12 @@ read_packet_header (grub_file_t sig, grub_uint8_t *out_type, grub_size_t *len)
f96e0b
     }
f96e0b
 
f96e0b
   if (!(type & 0x80))
f96e0b
-    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
   if (type & 0x40)
f96e0b
     {
f96e0b
       *out_type = (type & 0x3f);
f96e0b
       if (grub_file_read (sig, &l, sizeof (l)) != 1)
f96e0b
-	return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
       if (l < 192)
f96e0b
 	{
f96e0b
 	  *len = l;
f96e0b
@@ -78,39 +79,39 @@ read_packet_header (grub_file_t sig, grub_uint8_t *out_type, grub_size_t *len)
f96e0b
 	{
f96e0b
 	  *len = (l - 192) << 8;
f96e0b
 	  if (grub_file_read (sig, &l, sizeof (l)) != 1)
f96e0b
-	    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	  *len |= l;
f96e0b
 	  return 0;
f96e0b
 	}
f96e0b
       if (l == 255)
f96e0b
 	{
f96e0b
 	  if (grub_file_read (sig, &l32, sizeof (l32)) != sizeof (l32))
f96e0b
-	    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	  *len = grub_be_to_cpu32 (l32);
f96e0b
 	  return 0;
f96e0b
 	}
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
     }
f96e0b
   *out_type = ((type >> 2) & 0xf);
f96e0b
   switch (type & 0x3)
f96e0b
     {
f96e0b
     case 0:
f96e0b
       if (grub_file_read (sig, &l, sizeof (l)) != sizeof (l))
f96e0b
-	return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
       *len = l;
f96e0b
       return 0;
f96e0b
     case 1:
f96e0b
       if (grub_file_read (sig, &l16, sizeof (l16)) != sizeof (l16))
f96e0b
-	return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
       *len = grub_be_to_cpu16 (l16);
f96e0b
       return 0;
f96e0b
     case 2:
f96e0b
       if (grub_file_read (sig, &l32, sizeof (l32)) != sizeof (l32))
f96e0b
-	return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
       *len = grub_be_to_cpu32 (l32);
f96e0b
       return 0;
f96e0b
     }
f96e0b
-  return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+  return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 }
f96e0b
 
f96e0b
 struct signature_v4_header
f96e0b
@@ -210,7 +211,7 @@ grub_load_public_key (grub_file_t f)
f96e0b
 
f96e0b
       if (grub_file_read (f, &v, sizeof (v)) != sizeof (v))
f96e0b
 	{
f96e0b
-	  grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	  goto fail;
f96e0b
 	}
f96e0b
 
f96e0b
@@ -218,12 +219,12 @@ grub_load_public_key (grub_file_t f)
f96e0b
 
f96e0b
       if (v != 4)
f96e0b
 	{
f96e0b
-	  grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	  goto fail;
f96e0b
 	}
f96e0b
       if (grub_file_read (f, &creation_time, sizeof (creation_time)) != sizeof (creation_time))
f96e0b
 	{
f96e0b
-	  grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	  goto fail;
f96e0b
 	}
f96e0b
 
f96e0b
@@ -231,7 +232,7 @@ grub_load_public_key (grub_file_t f)
f96e0b
 
f96e0b
       if (grub_file_read (f, &pk, sizeof (pk)) != sizeof (pk))
f96e0b
 	{
f96e0b
-	  grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	  goto fail;
f96e0b
 	}
f96e0b
 
f96e0b
@@ -263,19 +264,19 @@ grub_load_public_key (grub_file_t f)
f96e0b
 	  grub_uint8_t buffer[4096];
f96e0b
 	  if (grub_file_read (f, &l, sizeof (l)) != sizeof (l))
f96e0b
 	    {
f96e0b
-	      grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	      grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	      goto fail;
f96e0b
 	    }
f96e0b
 	  
f96e0b
 	  lb = (grub_be_to_cpu16 (l) + 7) / 8;
f96e0b
 	  if (lb > sizeof (buffer) - sizeof (grub_uint16_t))
f96e0b
 	    {
f96e0b
-	      grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	      grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	      goto fail;
f96e0b
 	    }
f96e0b
 	  if (grub_file_read (f, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
f96e0b
 	    {
f96e0b
-	      grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	      grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	      goto fail;
f96e0b
 	    }
f96e0b
 	  grub_memcpy (buffer, &l, sizeof (l));
f96e0b
@@ -285,7 +286,7 @@ grub_load_public_key (grub_file_t f)
f96e0b
 	  if (gcry_mpi_scan (&sk->mpis[i], GCRYMPI_FMT_PGP,
f96e0b
 			     buffer, lb + sizeof (grub_uint16_t), 0))
f96e0b
 	    {
f96e0b
-	      grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	      grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	      goto fail;
f96e0b
 	    }
f96e0b
 	}
f96e0b
@@ -357,29 +358,29 @@ grub_verify_signature (grub_file_t f, grub_file_t sig,
f96e0b
     return err;
f96e0b
 
f96e0b
   if (type != 0x2)
f96e0b
-    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 
f96e0b
   if (grub_file_read (sig, &v, sizeof (v)) != sizeof (v))
f96e0b
-    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 
f96e0b
   if (v != 4)
f96e0b
-    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 
f96e0b
   if (grub_file_read (sig, &v4, sizeof (v4)) != sizeof (v4))
f96e0b
-    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 
f96e0b
   h = v4.hash;
f96e0b
   t = v4.type;
f96e0b
   pk = v4.pkeyalgo;
f96e0b
   
f96e0b
   if (t != 0)
f96e0b
-    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 
f96e0b
   if (h >= ARRAY_SIZE (hashes) || hashes[h] == NULL)
f96e0b
     return grub_error (GRUB_ERR_BAD_SIGNATURE, "unknown hash");
f96e0b
 
f96e0b
   if (pk >= ARRAY_SIZE (pkalgos) || pkalgos[pk].name == NULL)
f96e0b
-    return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+    return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 
f96e0b
   hash = grub_crypto_lookup_md_by_name (hashes[h]);
f96e0b
   if (!hash)
f96e0b
@@ -420,7 +421,7 @@ grub_verify_signature (grub_file_t f, grub_file_t sig,
f96e0b
 	grub_uint8_t readbuf[4096];
f96e0b
 	r = grub_file_read (sig, readbuf, rem < (grub_ssize_t) sizeof (readbuf) ? rem : (grub_ssize_t) sizeof (readbuf));
f96e0b
 	if (r < 0)
f96e0b
-	  return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	if (r == 0)
f96e0b
 	  break;
f96e0b
 	hash->write (context, readbuf, r);
f96e0b
@@ -432,17 +433,17 @@ grub_verify_signature (grub_file_t f, grub_file_t sig,
f96e0b
     hash->write (context, &headlen, sizeof (headlen));
f96e0b
     r = grub_file_read (sig, &unhashed_sub, sizeof (unhashed_sub));
f96e0b
     if (r != sizeof (unhashed_sub))
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
     {
f96e0b
       grub_uint8_t readbuf[4096];
f96e0b
       grub_uint8_t *ptr;
f96e0b
       grub_uint32_t l;
f96e0b
       rem = grub_be_to_cpu16 (unhashed_sub);
f96e0b
       if (rem > (int) sizeof (readbuf))
f96e0b
-	return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
       r = grub_file_read (sig, readbuf, rem);
f96e0b
       if (r != rem)
f96e0b
-	return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
       for (ptr = readbuf; ptr < readbuf + rem; ptr += l)
f96e0b
 	{
f96e0b
 	  if (*ptr < 192)
f96e0b
@@ -473,9 +474,9 @@ grub_verify_signature (grub_file_t f, grub_file_t sig,
f96e0b
     hval = hash->read (context);
f96e0b
 
f96e0b
     if (grub_file_read (sig, hash_start, sizeof (hash_start)) != sizeof (hash_start))
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
     if (grub_memcmp (hval, hash_start, sizeof (hash_start)) != 0)
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 
f96e0b
     grub_dprintf ("crypt", "@ %x\n", (int)grub_file_tell (sig));
f96e0b
 
f96e0b
@@ -486,22 +487,22 @@ grub_verify_signature (grub_file_t f, grub_file_t sig,
f96e0b
 	grub_uint8_t buffer[4096];
f96e0b
 	grub_dprintf ("crypt", "alive\n");
f96e0b
 	if (grub_file_read (sig, &l, sizeof (l)) != sizeof (l))
f96e0b
-	  return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	grub_dprintf ("crypt", "alive\n");
f96e0b
 	lb = (grub_be_to_cpu16 (l) + 7) / 8;
f96e0b
 	grub_dprintf ("crypt", "l = 0x%04x\n", grub_be_to_cpu16 (l));
f96e0b
 	if (lb > sizeof (buffer) - sizeof (grub_uint16_t))
f96e0b
-	  return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	grub_dprintf ("crypt", "alive\n");
f96e0b
 	if (grub_file_read (sig, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
f96e0b
-	  return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	grub_dprintf ("crypt", "alive\n");
f96e0b
 	grub_memcpy (buffer, &l, sizeof (l));
f96e0b
 	grub_dprintf ("crypt", "alive\n");
f96e0b
 
f96e0b
 	if (gcry_mpi_scan (&mpis[i], GCRYMPI_FMT_PGP,
f96e0b
 			   buffer, lb + sizeof (grub_uint16_t), 0))
f96e0b
-	  return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+	  return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
 	grub_dprintf ("crypt", "alive\n");
f96e0b
       }
f96e0b
 
f96e0b
@@ -510,17 +511,18 @@ grub_verify_signature (grub_file_t f, grub_file_t sig,
f96e0b
     else
f96e0b
       sk = grub_crypto_pk_locate_subkey_in_trustdb (keyid);
f96e0b
     if (!sk)
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "key not found");
f96e0b
+      /* TRANSLATORS: %08x is 32-bit key id.  */
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), keyid);
f96e0b
 
f96e0b
     int nbits = gcry_mpi_get_nbits (sk->mpis[1]);
f96e0b
     grub_dprintf ("crypt", "must be %d bits got %d bits\n", (int)nbits, (int)(8 * hash->mdlen));
f96e0b
 
f96e0b
     if (gcry_mpi_scan (&hmpi, GCRYMPI_FMT_USG, hval, nbits / 8 < (int) hash->mdlen ? nbits / 8 : (int) hash->mdlen, 0))
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
     if (!grub_crypto_pk_dsa)
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "DSA module is not loaded");
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("module `%s' isn't loaded"), "gcry_dsa");
f96e0b
     if (grub_crypto_pk_dsa->verify (0, hmpi, mpis, sk->mpis, 0, 0))
f96e0b
-      return grub_error (GRUB_ERR_BAD_SIGNATURE, "bad signature");
f96e0b
+      return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
f96e0b
   }
f96e0b
 
f96e0b
   return GRUB_ERR_NONE;
f96e0b
@@ -534,7 +536,7 @@ grub_cmd_trust (grub_command_t cmd  __attribute__ ((unused)),
f96e0b
   struct grub_public_key *pk = NULL;
f96e0b
 
f96e0b
   if (argc < 1)
f96e0b
-    return grub_error (GRUB_ERR_BAD_ARGUMENT, "one argument required");
f96e0b
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
f96e0b
 
f96e0b
   grub_file_filter_disable_all ();
f96e0b
   pkf = grub_file_open (args[0]);
f96e0b
@@ -563,7 +565,7 @@ grub_cmd_distrust (grub_command_t cmd  __attribute__ ((unused)),
f96e0b
   struct grub_public_subkey *sk;
f96e0b
 
f96e0b
   if (argc < 1)
f96e0b
-    return grub_error (GRUB_ERR_BAD_ARGUMENT, "one argument required");
f96e0b
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
f96e0b
   keyid = grub_strtoull (args[0], 0, 16);
f96e0b
   if (grub_errno)
f96e0b
     return grub_errno;
f96e0b
@@ -582,7 +584,8 @@ grub_cmd_distrust (grub_command_t cmd  __attribute__ ((unused)),
f96e0b
       *pkey = next;
f96e0b
       return GRUB_ERR_NONE;
f96e0b
     }
f96e0b
-  return grub_error (GRUB_ERR_BAD_ARGUMENT, "key %08x not found", keyid);
f96e0b
+  /* TRANSLATORS: %08x is 32-bit key id.  */
f96e0b
+  return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("public key %08x not found"), keyid);
f96e0b
 }
f96e0b
 
f96e0b
 static grub_err_t
f96e0b
@@ -596,7 +599,7 @@ grub_cmd_verify_signature (grub_command_t cmd  __attribute__ ((unused)),
f96e0b
   grub_dprintf ("crypt", "alive\n");
f96e0b
 
f96e0b
   if (argc < 2)
f96e0b
-    return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments required");
f96e0b
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
f96e0b
 
f96e0b
   grub_dprintf ("crypt", "alive\n");
f96e0b
 
f96e0b
@@ -744,13 +747,13 @@ GRUB_MOD_INIT(verify)
f96e0b
     grub_env_set ("check_signatures", grub_pk_trusted ? "enforce" : "no");
f96e0b
 
f96e0b
   cmd = grub_register_command ("verify_detached", grub_cmd_verify_signature,
f96e0b
-			       "FILE SIGFILE [PKFILE]",
f96e0b
+			       N_("FILE SIGNATURE_FILE [PUBKEY_FILE]"),
f96e0b
 			       N_("Verify detached signature."));
f96e0b
   cmd_trust = grub_register_command ("trust", grub_cmd_trust,
f96e0b
-				     "PKFILE",
f96e0b
+				     N_("PUBKEY_FILE"),
f96e0b
 				     N_("Add PKFILE to trusted keys."));
f96e0b
   cmd_distrust = grub_register_command ("distrust", grub_cmd_distrust,
f96e0b
-					"KEYID",
f96e0b
+					N_("PUBKEY_ID"),
f96e0b
 					N_("Remove KEYID from trusted keys."));
f96e0b
 }
f96e0b
 
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b