Changeset 818 in openpam
- Timestamp:
- Oct 8, 2014, 11:02:44 AM (7 years ago)
- Location:
- trunk/bin/oathkey
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/oathkey/oathkey.1
r799 r818 29 29 .\" $Id$ 30 30 .\" 31 .Dd March 9, 201431 .Dd October 8, 2014 32 32 .Dt OATHKEY 1 33 33 .Os … … 72 72 If writeback mode is enabled, the user's key is set; otherwise, it is 73 73 printed to standard output. 74 .It Cm getkey 75 Print the user's key. 76 .It Cm geturi 77 Print the user's key in otpauth URI form. 74 78 .It Cm setkey Ar uri 75 79 Set the user's key to the given otpauth URI. 76 .It Cm uri77 Print the user's key in otpauth URI form.78 80 .It Cm verify Ar code 79 81 Verify that the given code is the correct current response for the … … 81 83 If writeback mode is enabled and the response matched, the user's 82 84 keyfile is updated to prevent reuse. 85 .It Cm uri 86 Deprecated synonym for 87 .Cm geturi . 83 88 .El 84 89 .Sh SEE ALSO -
trunk/bin/oathkey/oathkey.c
r817 r818 62 62 63 63 /* 64 * Print key in hexadecimal form 65 */ 66 static int 67 oathkey_print_hex(struct oath_key *key) 68 { 69 unsigned int i; 70 71 for (i = 0; i < key->keylen; ++i) 72 printf("%02x", key->key[i]); 73 printf("\n"); 74 return (RET_SUCCESS); 75 } 76 77 /* 64 78 * Print key in otpauth URI form 65 79 */ 66 80 static int 67 oathkey_print (struct oath_key *key)81 oathkey_print_uri(struct oath_key *key) 68 82 { 69 83 char *keyuri; … … 88 102 int fd, len, ret; 89 103 104 if (verbose) 105 warnx("saving key to %s", keyfile); 90 106 keyuri = NULL; 91 107 len = 0; … … 127 143 if ((key = oath_key_create(user, om_totp, oh_undef, NULL, 0)) == NULL) 128 144 return (RET_ERROR); 129 ret = writeback ? oathkey_save(key) : oathkey_print (key);145 ret = writeback ? oathkey_save(key) : oathkey_print_uri(key); 130 146 oath_key_free(key); 131 147 return (ret); … … 155 171 156 172 /* 157 * Print the otpauth URI for a key158 */ 159 static int 160 oathkey_ uri(int argc, char *argv[])173 * Print raw key in hexadecimal 174 */ 175 static int 176 oathkey_getkey(int argc, char *argv[]) 161 177 { 162 178 struct oath_key *key; … … 168 184 if (!isroot && !issameuser) 169 185 return (RET_UNAUTH); 186 if (verbose) 187 warnx("loading key from %s", keyfile); 170 188 if ((key = oath_key_from_file(keyfile)) == NULL) 171 189 return (RET_ERROR); 172 ret = oathkey_print(key); 190 ret = oathkey_print_hex(key); 191 oath_key_free(key); 192 return (ret); 193 } 194 195 /* 196 * Print the otpauth URI for a key 197 */ 198 static int 199 oathkey_geturi(int argc, char *argv[]) 200 { 201 struct oath_key *key; 202 int ret; 203 204 if (argc != 0) 205 return (RET_USAGE); 206 (void)argv; 207 if (!isroot && !issameuser) 208 return (RET_UNAUTH); 209 if (verbose) 210 warnx("loading key from %s", keyfile); 211 if ((key = oath_key_from_file(keyfile)) == NULL) 212 return (RET_ERROR); 213 ret = oathkey_print_uri(key); 173 214 oath_key_free(key); 174 215 return (ret); … … 188 229 if (argc < 1) 189 230 return (RET_USAGE); 231 if (verbose) 232 warnx("loading key from %s", keyfile); 190 233 if ((key = oath_key_from_file(keyfile)) == NULL) 191 234 return (RET_ERROR); … … 225 268 "Commands:\n" 226 269 " genkey Generate a new key\n" 270 " getkey Print the key in hexadecimal form\n" 271 " geturi Print the key in otpauth URI form\n" 227 272 " setkey Generate a new key\n" 228 " uri Print the key in otpauth URI form\n"229 273 " verify <response>\n" 230 274 " Verify a response\n"); … … 294 338 if (asprintf(&user, "%s", pw->pw_name) < 0) 295 339 err(1, "asprintf()"); 340 issameuser = 1; 296 341 } 297 342 … … 312 357 else if (strcmp(cmd, "genkey") == 0) 313 358 ret = oathkey_genkey(argc, argv); 359 else if (strcmp(cmd, "getkey") == 0) 360 ret = oathkey_getkey(argc, argv); 361 else if (strcmp(cmd, "geturi") == 0 || strcmp(cmd, "uri") == 0) 362 ret = oathkey_geturi(argc, argv); 314 363 else if (strcmp(cmd, "setkey") == 0) 315 364 ret = oathkey_setkey(argc, argv); 316 else if (strcmp(cmd, "uri") == 0)317 ret = oathkey_uri(argc, argv);318 365 else if (strcmp(cmd, "verify") == 0) 319 366 ret = oathkey_verify(argc, argv);
Note: See TracChangeset
for help on using the changeset viewer.