16
16
* You should have received a copy of the GNU General Public License
17
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21
22
#include <config.h>
37
38
#include "keyserver-internal.h"
38
39
#if GNUPG_MAJOR_VERSION == 1
40
#ifdef HAVE_LIBREADLINE
42
#include <readline/readline.h>
43
#endif /*HAVE_LIBREADLINE*/
39
44
#include "cardglue.h"
45
#else /*GNUPG_MAJOR_VERSION!=1*/
41
46
#include "call-agent.h"
47
#endif /*GNUPG_MAJOR_VERSION!=1*/
44
49
#define CONTROL_D ('D' - 'A' + 1)
359
367
info.chvretry[0], info.chvretry[1], info.chvretry[2]);
360
368
fprintf (fp, "sigcount:%lu:::\n", info.sig_counter);
370
for (i=0; i < 4; i++)
372
if (info.private_do[i])
374
fprintf (fp, "private_do:%d:", i+1);
375
print_string (fp, info.private_do[i],
376
strlen (info.private_do[i]), ':');
362
381
fputs ("cafpr:", fp);
363
382
print_sha1_fpr_colon (fp, info.cafpr1valid? info.cafpr1:NULL);
364
383
print_sha1_fpr_colon (fp, info.cafpr2valid? info.cafpr2:NULL);
1275
/* Menu to edit all user changeable values on an OpenPGP card. Only
1276
Key creation is not handled here. */
1278
card_edit (STRLIST commands)
1297
/* Data used by the command parser. This needs to be outside of the
1298
function scope to allow readline based command completion. */
1282
cmdQUIT, cmdADMIN, cmdHELP, cmdLIST, cmdDEBUG,
1302
cmdQUIT, cmdADMIN, cmdHELP, cmdLIST, cmdDEBUG, cmdVERIFY,
1283
1303
cmdNAME, cmdURL, cmdFETCH, cmdLOGIN, cmdLANG, cmdSEX, cmdCAFPR,
1284
1304
cmdFORCESIG, cmdGENERATE, cmdPASSWD, cmdPRIVATEDO,
1294
1316
{ "quit" , cmdQUIT , 0, N_("quit this menu")},
1295
1317
{ "q" , cmdQUIT , 0, NULL },
1296
1318
{ "admin" , cmdADMIN , 0, N_("show admin commands")},
1309
1331
{ "forcesig", cmdFORCESIG, 1, N_("toggle the signature force PIN flag")},
1310
1332
{ "generate", cmdGENERATE, 1, N_("generate new keys")},
1311
1333
{ "passwd" , cmdPASSWD, 0, N_("menu to change or unblock the PIN")},
1334
{ "verify" , cmdVERIFY, 0, N_("verify the PIN and list all data")},
1312
1335
/* Note, that we do not announce this command yet. */
1313
1336
{ "privatedo", cmdPRIVATEDO, 0, NULL },
1314
1337
{ NULL, cmdINVCMD, 0, NULL }
1341
#if GNUPG_MAJOR_VERSION == 1 && defined (HAVE_LIBREADLINE)
1343
/* These two functions are used by readline for command completion. */
1346
command_generator(const char *text,int state)
1348
static int list_index,len;
1351
/* If this is a new word to complete, initialize now. This includes
1352
saving the length of TEXT for efficiency, and initializing the
1353
index variable to 0. */
1360
/* Return the next partial match */
1361
while((name=cmds[list_index].name))
1363
/* Only complete commands that have help text */
1364
if(cmds[list_index++].desc && strncmp(name,text,len)==0)
1365
return strdup(name);
1372
card_edit_completion(const char *text, int start, int end)
1374
/* If we are at the start of a line, we try and command-complete.
1375
If not, just do nothing for now. */
1378
return rl_completion_matches(text,command_generator);
1380
rl_attempted_completion_over=1;
1384
#endif /* GNUPG_MAJOR_VERSION == 1 && HAVE_LIBREADLINE */
1386
/* Menu to edit all user changeable values on an OpenPGP card. Only
1387
Key creation is not handled here. */
1389
card_edit (STRLIST commands)
1317
1391
enum cmdids cmd = cmdNOP;
1318
1392
int have_commands = !!commands;
1319
1393
int redisplay = 1;
1426
allow_admin=!allow_admin;
1506
if ( !strcmp (arg_string, "on") )
1508
else if ( !strcmp (arg_string, "off") )
1510
else if ( !strcmp (arg_string, "verify") )
1512
/* Force verification of the Admin Command. However,
1513
this is only done if the retry counter is at initial
1515
char *tmp = xmalloc (strlen (serialnobuf) + 6 + 1);
1516
strcpy (stpcpy (tmp, serialnobuf), "[CHV3]");
1517
allow_admin = !agent_scd_checkpin (tmp);
1521
allow_admin=!allow_admin;
1427
1522
if(allow_admin)
1428
1523
tty_printf(_("Admin commands are allowed\n"));
1430
1525
tty_printf(_("Admin commands are not allowed\n"));
1529
agent_scd_checkpin (serialnobuf);