Blob Blame History Raw
From b9db39d4e0906dab143a42d41a027c24687c755d Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Mon, 10 Feb 2014 11:00:09 +0100
Subject: [PATCH] actions/part_set_gpt_type: set type of "guid" parameter as
 "GUID" (RHBZ#1008417).

Switch the type of the "guid" parameter from "String" to "GUID"; this
adds the validation of the GUID as such, rejecting straight away invalid
GUIDs which otherwise could be handled badly by low-level tools (such as
sgdisk).

Add a couple of easy tests (taken from RHBZ#1008417) to
part_set_gpt_type about this.

(cherry picked from commit a948389ce9c76bf7e8997bb27f3daac06cb20c50)
---
 generator/actions.ml | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/generator/actions.ml b/generator/actions.ml
index 24f4468..379e63e 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -11158,9 +11158,18 @@ group with GUID C<diskgroup>." };
 
   { defaults with
     name = "part_set_gpt_type";
-    style = RErr, [Device "device"; Int "partnum"; String "guid"], [];
+    style = RErr, [Device "device"; Int "partnum"; GUID "guid"], [];
     proc_nr = Some 392;
     optional = Some "gdisk";
+    tests = [
+      InitGPT, Always, TestLastFail (
+        [["part_set_gpt_type"; "/dev/sda"; "1"; "f"]]), [];
+      InitGPT, Always, TestResultString (
+        [["part_set_gpt_type"; "/dev/sda"; "1";
+          "01234567-89AB-CDEF-0123-456789ABCDEF"];
+         ["part_get_gpt_type"; "/dev/sda"; "1"]],
+        "01234567-89AB-CDEF-0123-456789ABCDEF"), [];
+    ];
     shortdesc = "set the type GUID of a GPT partition";
     longdesc = "\
 Set the type GUID of numbered GPT partition C<partnum> to C<guid>. Return an
-- 
1.8.3.1