From: Klas Lindfors Date: Tue, 16 Oct 2012 06:53:06 +0000 (+0200) Subject: add -p switch for programming sequence X-Git-Tag: v1.8.1~1 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6587e01d94360b1f2b4c4e81732f3f8850792a23;p=yubikey-personalization add -p switch for programming sequence --- diff --git a/ykinfo.1 b/ykinfo.1 index 26ce5ef..fbeb59d 100644 --- a/ykinfo.1 +++ b/ykinfo.1 @@ -35,7 +35,7 @@ ykinfo - Get basic information from a YubiKey .SH SYNOPSIS .B ykinfo -[\fI-s\fR] [\fI-m\fR] [\fI-H\fR] [\fI-v\fR] [\fI-t\fR] [\fI-q\fR] [\fI-h\fR] +[\fI-s\fR] [\fI-m\fR] [\fI-H\fR] [\fI-v\fR] [\fI-t\fR] [\fI-p\fR] [\fI-q\fR] [\fI-h\fR] .SH DESCRIPTION .PP Get basic information from a YubiKey. Can get serial number, version and current @@ -58,6 +58,9 @@ get the version and output it. \fB\-t\fR get the touch level and output it. .TP +\fB\-p\fR +get the programming sequence and output it. +.TP \fB\-q\fR modifier, only show the relevant data from the YubiKey, no extra information. .TP @@ -66,12 +69,13 @@ modifier, only show the relevant data from the YubiKey, no extra information. Output of all information from a YubiKey .nf -$ \fBykinfo \-s \-m \-H \-v \-t\fR +$ \fBykinfo \-s \-m \-H \-v \-t \-p\fR serial: 1077254 serial_hex: 107006 serial_modhex: bcicch version: 2.2.3 touch_level: 1793 +programming_sequence: 1 $ .fi diff --git a/ykinfo.c b/ykinfo.c index 1d4e6aa..4f6d415 100644 --- a/ykinfo.c +++ b/ykinfo.c @@ -48,6 +48,7 @@ const char *usage = "\t-H Get serial in hex from YubiKey\n" "\t-v Get version from YubiKey\n" "\t-t Get touchlevel from YubiKey\n" + "\t-p Get programming sequence from YubiKey\n" "\n" "\t-q Only output information from YubiKey\n" "\n" @@ -55,7 +56,7 @@ const char *usage = "\n" "\n" ; -const char *optstring = "smHvtqh"; +const char *optstring = "smHvtpqh"; static void report_yk_error(void) { @@ -72,7 +73,7 @@ static void report_yk_error(void) static int parse_args(int argc, char **argv, bool *serial_dec, bool *serial_modhex, bool *serial_hex, - bool *version, bool *touch_level, bool *quiet, + bool *version, bool *touch_level, bool *pgm_seq, bool *quiet, int *exit_code) { int c; @@ -94,6 +95,9 @@ static int parse_args(int argc, char **argv, case 't': *touch_level = true; break; + case 'p': + *pgm_seq = true; + break; case 'q': *quiet = true; break; @@ -106,7 +110,7 @@ static int parse_args(int argc, char **argv, } if (!*serial_dec && !*serial_modhex && !*serial_hex && - !*version && !*touch_level) { + !*version && !*touch_level && !*pgm_seq) { /* no options at all */ fputs("You must give at least one option.\n", stderr); fputs(usage, stderr); @@ -129,6 +133,7 @@ int main(int argc, char **argv) bool serial_hex = false; bool version = false; bool touch_level = false; + bool pgm_seq = false; bool quiet = false; @@ -136,7 +141,7 @@ int main(int argc, char **argv) if (! parse_args(argc, argv, &serial_dec, &serial_modhex, &serial_hex, - &version, &touch_level, &quiet, + &version, &touch_level, &pgm_seq, &quiet, &exit_code)) exit(exit_code); @@ -180,7 +185,7 @@ int main(int argc, char **argv) printf("%s\n", modhex_serial); } } - if(version || touch_level) { + if(version || touch_level || pgm_seq) { YK_STATUS *st = ykds_alloc(); if(!yk_get_status(yk, st)) { ykds_free(st); @@ -198,6 +203,11 @@ int main(int argc, char **argv) printf("touch_level: "); printf("%d\n", ykds_touch_level(st)); } + if(pgm_seq) { + if(!quiet) + printf("programming_sequence: "); + printf("%d\n", ykds_pgm_seq(st)); + } ykds_free(st); }