Skip to content

Commit

Permalink
fix optionality issue of switch -T of sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
XakerTwo committed Dec 9, 2024
1 parent 8257b46 commit 30565c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions gencat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# Server_v100_ARM64_24H2 - arm 64-bit Windows Server 2025 (not tested + officially the first ARM64 Server)

function usage_and_exit() {
echo Usage: "$0 -o <output-file> [-h <hardware-ids>] [-O OS string] [-A OS attribute string] [-T generation-time] file1 [ file2 ... ]"
echo Usage: "$0 -o <output-file> [-h <hardware-ids>] [-O OS string] [-A OS attribute string] [-T <generation-time>] file1 [ file2 ... ]"
echo See comment inside this .sh file for list of OS string and OS attributes
exit 1
}
Expand All @@ -68,7 +68,7 @@ OUTPUT_CAT_FILE=-
HARDWARE_ID=windrbd
OS_STRING=7X64,8X64,_v100_X64
OS_ATTR=2:6.1,2:6.2,2:10.0
GEN_TIME=230823140713Z
GEN_TIME="-T 230823140713Z"
DRY_RUN=0

args=$( getopt do:h:O:A:T: $* )
Expand Down Expand Up @@ -108,7 +108,7 @@ do
shift
;;
-T)
GEN_TIME=$2
GEN_TIME="-T $2"
shift
shift
;;
Expand Down Expand Up @@ -147,13 +147,13 @@ unset IFS

if [ $DRY_RUN -eq 1 ]
then
echo $EXEC_DIR/generate-cat-file -T $GEN_TIME -A $OS_ATTR -O $OS_STRING -h $HARDWARE_IDS ${sorted_images[*]}
echo $EXEC_DIR/generate-cat-file "$GEN_TIME" -A $OS_ATTR -O $OS_STRING -h $HARDWARE_IDS ${sorted_images[*]}
exit 0
fi

if [ $OUTPUT_CAT_FILE == '-' ]
then
$EXEC_DIR/generate-cat-file -T $GEN_TIME -A $OS_ATTR -O $OS_STRING -h $HARDWARE_IDS ${sorted_images[*]}
$EXEC_DIR/generate-cat-file "$GEN_TIME" -A $OS_ATTR -O $OS_STRING -h $HARDWARE_IDS ${sorted_images[*]}
else
$EXEC_DIR/generate-cat-file -T $GEN_TIME -A $OS_ATTR -O $OS_STRING -h $HARDWARE_IDS ${sorted_images[*]} > $OUTPUT_CAT_FILE
$EXEC_DIR/generate-cat-file "$GEN_TIME" -A $OS_ATTR -O $OS_STRING -h $HARDWARE_IDS ${sorted_images[*]} > $OUTPUT_CAT_FILE
fi
2 changes: 1 addition & 1 deletion generate-cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ void create_binary_tree(struct pkcs7_toplevel *sdat)

void __attribute((noreturn)) usage_and_exit(void)
{
fprintf(stderr, "Usage: generate_cat_file -h <hardware-ids> [-O OS string] [-A OS attribute string] [-T generation-time] file-with-hash1 [ file-with-hash2 ... ]\n");
fprintf(stderr, "Usage: generate_cat_file -h <hardware-ids> [-O OS string] [-A OS attribute string] [-T <generation-time>] file-with-hash1 [ file-with-hash2 ... ]\n");
fprintf(stderr, "Generates a Microsoft Security Catalog (\".cat\") file.\n");
fprintf(stderr, "hardware-ids is comma separated list\n");
fprintf(stderr, "generation-time has the format YYmmddHHMMSSZ, Z is constant, means 0 timezone\n");
Expand Down

0 comments on commit 30565c4

Please sign in to comment.