The recent code treats -h as unknown options and throws an error.

Signed-off-by: Dan Horák <[email protected]>
---
 man/man1/pkcsconf.1.in           |    4 +++-
 usr/sbin/pkcsconf/pkcsconf.c     |    8 ++++++--
 usr/sbin/pkcsconf/pkcsconf.msg   |    3 ++-
 usr/sbin/pkcsconf/pkcsconf_msg.h |    1 +
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/man/man1/pkcsconf.1.in b/man/man1/pkcsconf.1.in
index a620882..6f5540a 100644
--- a/man/man1/pkcsconf.1.in
+++ b/man/man1/pkcsconf.1.in
@@ -4,7 +4,7 @@ pkcsconf
 
 .SH SYNOPSIS
 \fBpkcsconf\fP
-[\fB-itsmMIupP\fP]
+[\fB-itsmMIupPh\fP]
 [\fB-c\fP \fIslotnumber\fP \fB-U\fP \fIuserPIN\fP
 \fB-S\fP \fISOPin\fP \fB-n\fP \fInewpin\fP]
 
@@ -40,6 +40,8 @@ the current Security Officer (SO) pin (for use when changing 
the SO pin;
 .IP "\fB-n\fP \fINEWPIN\fP" 10
 the new pin (for use when changing either the user pin or the SO pin; -u, -p
 and -P options); if not specified, user will be prompted
+.IP "\fB-h\fP" 10
+show usage information
 
 .SH SEE ALSO
 .PD 0
diff --git a/usr/sbin/pkcsconf/pkcsconf.c b/usr/sbin/pkcsconf/pkcsconf.c
index 30a143a..768f1ec 100755
--- a/usr/sbin/pkcsconf/pkcsconf.c
+++ b/usr/sbin/pkcsconf/pkcsconf.c
@@ -375,7 +375,7 @@ main(int argc, char *argv[]){
    catd = catopen(MF_PKCSCONF,0);
 
    /* Parse the command line parameters */
-   while ((c = getopt (argc, argv, "itsmMIc:S:U:upPn:l")) != (-1)){
+   while ((c = getopt (argc, argv, "itsmMIc:S:U:upPn:lh")) != (-1)){
       switch (c){
          case 'c':  /* a specific card (slot) is specified */
             flags |= CFG_SLOT;
@@ -429,6 +429,9 @@ main(int argc, char *argv[]){
          case 'l':  /* display slot description */
             flags |= CFG_LIST_SLOT;
             break;
+         case 'h':  /* display command line options */
+           usage(argv[0]);
+            break;
          default:   /* if something else was passed in it is an error */
             errflag++;
             break;
@@ -1295,7 +1298,7 @@ usage(char *progname){
 
    /* If we get here the user needs help, so give it to them */
    printf(PKCSINIT_MSG(USAGE,
-           "usage:\t%s [-itsmMIupP] [-c slotnumber -U userPIN -S SOPin -n 
newpin]\n"),
+           "usage:\t%s [-itsmMIupPh] [-c slotnumber -U userPIN -S SOPin -n 
newpin]\n"),
            progname);
    printf(PKCSINIT_MSG(USAGE1, "\t-i display PKCS11 info\n"));
    printf(PKCSINIT_MSG(USAGE2, "\t-t display token info\n"));
@@ -1305,6 +1308,7 @@ usage(char *progname){
    printf(PKCSINIT_MSG(USAGE7, "\t-u initialize user PIN\n"));
    printf(PKCSINIT_MSG(USAGE8, "\t-p set the user PIN\n"));
    printf(PKCSINIT_MSG(USAGE9, "\t-P set the SO PIN\n"));
+   printf(PKCSINIT_MSG(USAGE10, "\t-h show this help\n"));
 
    exit(-1);
 }
diff --git a/usr/sbin/pkcsconf/pkcsconf.msg b/usr/sbin/pkcsconf/pkcsconf.msg
index 4b5fdf9..bce440b 100755
--- a/usr/sbin/pkcsconf/pkcsconf.msg
+++ b/usr/sbin/pkcsconf/pkcsconf.msg
@@ -373,7 +373,7 @@ LIBERROR    "Error initializing the PKCS11 library: 0x%X\n"
 SLOTMGRERROR   "Error communicating with slot manager: 0x%X\n"
 INVALIDCARD    "Invalid card: %s\n"
 
-USAGE          "usage:\t%s [-iImMpPstu] [-c slotnumber -U userPIN -S SOPin -n 
newPIN]\n"
+USAGE          "usage:\t%s [-iImMpPstuh] [-c slotnumber -U userPIN -S SOPin -n 
newPIN]\n"
 USAGE1         "\t-i display PKCS11 info\n"
 USAGE2         "\t-t display token info\n"
 USAGE3         "\t-s display slot info\n"
@@ -383,3 +383,4 @@ USAGE6              "\t-I initialize token\n"
 USAGE7         "\t-u initialize user PIN\n"
 USAGE8         "\t-p set the user PIN\n"
 USAGE9         "\t-P set the SO PIN\n"
+USAGE10                "\t-h show this help\n"
diff --git a/usr/sbin/pkcsconf/pkcsconf_msg.h b/usr/sbin/pkcsconf/pkcsconf_msg.h
index 1ca9c04..f500dbc 100755
--- a/usr/sbin/pkcsconf/pkcsconf_msg.h
+++ b/usr/sbin/pkcsconf/pkcsconf_msg.h
@@ -378,4 +378,5 @@
 #define USAGE7 68
 #define USAGE8 69
 #define USAGE9 70
+#define USAGE10 71
 #endif 
-- 
1.6.6.1


------------------------------------------------------------------------------

_______________________________________________
Opencryptoki-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech

Reply via email to