switch diagnostic output to stderr

This commit is contained in:
Klas Lindfors
2014-12-17 09:53:24 +01:00
parent 2204dd8ac6
commit 7ef2015f38
+11 -11
View File
@@ -83,7 +83,7 @@ static void print_version(ykpiv_state *state) {
if(ykpiv_get_version(state, version, sizeof(version)) == YKPIV_OK) { if(ykpiv_get_version(state, version, sizeof(version)) == YKPIV_OK) {
printf("Applet version %s found.\n", version); printf("Applet version %s found.\n", version);
} else { } else {
printf("Failed to retreive apple version.\n"); fprintf(stderr, "Failed to retreive apple version.\n");
} }
} }
@@ -983,7 +983,7 @@ static bool delete_certificate(ykpiv_state *state, enum enum_slot slot) {
fprintf(stderr, "Failed deleting object.\n"); fprintf(stderr, "Failed deleting object.\n");
return false; return false;
} else { } else {
fprintf(stdout, "Certificate deleted.\n"); fprintf(stderr, "Certificate deleted.\n");
return true; return true;
} }
} }
@@ -1222,7 +1222,7 @@ int main(int argc, char *argv[]) {
} else if(ykpiv_set_mgmkey(state, new_key) != YKPIV_OK) { } else if(ykpiv_set_mgmkey(state, new_key) != YKPIV_OK) {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} else { } else {
printf("Successfully set new management key.\n"); fprintf(stderr, "Successfully set new management key.\n");
} }
} else { } else {
fprintf(stderr, "The new management key has to be exactly %d character.\n", KEY_LEN * 2); fprintf(stderr, "The new management key has to be exactly %d character.\n", KEY_LEN * 2);
@@ -1238,7 +1238,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Reset failed, are pincodes blocked?\n"); fprintf(stderr, "Reset failed, are pincodes blocked?\n");
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} else { } else {
printf("Successfully reset the applet.\n"); fprintf(stderr, "Successfully reset the applet.\n");
} }
break; break;
case action_arg_pinMINUS_retries: case action_arg_pinMINUS_retries:
@@ -1246,7 +1246,7 @@ int main(int argc, char *argv[]) {
if(set_pin_retries(state, args_info.pin_retries_arg, args_info.puk_retries_arg, verbosity) == false) { if(set_pin_retries(state, args_info.pin_retries_arg, args_info.puk_retries_arg, verbosity) == false) {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} else { } else {
printf("Successfully changed pin retries to %d and puk retries to %d, both codes have been reset to default now.\n", fprintf(stderr, "Successfully changed pin retries to %d and puk retries to %d, both codes have been reset to default now.\n",
args_info.pin_retries_arg, args_info.puk_retries_arg); args_info.pin_retries_arg, args_info.puk_retries_arg);
} }
} else { } else {
@@ -1259,7 +1259,7 @@ int main(int argc, char *argv[]) {
if(import_key(state, args_info.key_format_arg, args_info.input_arg, args_info.slot_orig, args_info.password_arg) == false) { if(import_key(state, args_info.key_format_arg, args_info.input_arg, args_info.slot_orig, args_info.password_arg) == false) {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} else { } else {
printf("Successfully imported a new private key.\n"); fprintf(stderr, "Successfully imported a new private key.\n");
} }
} else { } else {
fprintf(stderr, "The import action needs a slot (-s) to operate on.\n"); fprintf(stderr, "The import action needs a slot (-s) to operate on.\n");
@@ -1271,7 +1271,7 @@ int main(int argc, char *argv[]) {
if(import_cert(state, args_info.key_format_arg, args_info.input_arg, args_info.slot_arg, args_info.password_arg) == false) { if(import_cert(state, args_info.key_format_arg, args_info.input_arg, args_info.slot_arg, args_info.password_arg) == false) {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} else { } else {
printf("Successfully imported a new certificate.\n"); fprintf(stderr, "Successfully imported a new certificate.\n");
} }
} else { } else {
fprintf(stderr, "The import action needs a slot (-s) to operate on.\n"); fprintf(stderr, "The import action needs a slot (-s) to operate on.\n");
@@ -1282,7 +1282,7 @@ int main(int argc, char *argv[]) {
if(set_chuid(state, verbosity) == false) { if(set_chuid(state, verbosity) == false) {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} else { } else {
printf("Successfully set new CHUID.\n"); fprintf(stderr, "Successfully set new CHUID.\n");
} }
break; break;
case action_arg_requestMINUS_certificate: case action_arg_requestMINUS_certificate:
@@ -1303,7 +1303,7 @@ int main(int argc, char *argv[]) {
case action_arg_verifyMINUS_pin: case action_arg_verifyMINUS_pin:
if(args_info.pin_arg) { if(args_info.pin_arg) {
if(verify_pin(state, args_info.pin_arg)) { if(verify_pin(state, args_info.pin_arg)) {
printf("Successfully verified PIN.\n"); fprintf(stderr, "Successfully verified PIN.\n");
} else { } else {
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
} }
@@ -1318,9 +1318,9 @@ int main(int argc, char *argv[]) {
if(args_info.pin_arg && args_info.new_pin_arg) { if(args_info.pin_arg && args_info.new_pin_arg) {
if(change_pin(state, action, args_info.pin_arg, args_info.new_pin_arg)) { if(change_pin(state, action, args_info.pin_arg, args_info.new_pin_arg)) {
if(action == action_arg_unblockMINUS_pin) { if(action == action_arg_unblockMINUS_pin) {
printf("Successfully unblocked the pin code.\n"); fprintf(stderr, "Successfully unblocked the pin code.\n");
} else { } else {
printf("Successfully changed the %s code.\n", fprintf(stderr, "Successfully changed the %s code.\n",
action == action_arg_changeMINUS_pin ? "pin" : "puk"); action == action_arg_changeMINUS_pin ? "pin" : "puk");
} }
} else { } else {