mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
* command.c (scd_update_reader_status_file): Send a signal back to
the client. (option_handler): Parse the new event-signal option. * scdaemon.c (handle_signal): Do not use SIGUSR{1,2} anymore for changing the verbosity.
This commit is contained in:
parent
3d58329f67
commit
4624e9dfb3
@ -1,3 +1,12 @@
|
|||||||
|
2004-04-21 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* command.c (scd_update_reader_status_file): Send a signal back to
|
||||||
|
the client.
|
||||||
|
(option_handler): Parse the new event-signal option.
|
||||||
|
|
||||||
|
* scdaemon.c (handle_signal): Do not use SIGUSR{1,2} anymore for
|
||||||
|
changing the verbosity.
|
||||||
|
|
||||||
2004-04-20 Werner Koch <wk@gnupg.org>
|
2004-04-20 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* command.c (scd_update_reader_status_file): Write status files.
|
* command.c (scd_update_reader_status_file): Write status files.
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include <assuan.h>
|
#include <assuan.h>
|
||||||
|
|
||||||
@ -33,14 +34,21 @@
|
|||||||
#include "app-common.h"
|
#include "app-common.h"
|
||||||
#include "apdu.h" /* Required for apdu_*_reader (). */
|
#include "apdu.h" /* Required for apdu_*_reader (). */
|
||||||
|
|
||||||
/* maximum length aloowed as a PIN; used for INQUIRE NEEDPIN */
|
/* Maximum length allowed as a PIN; used for INQUIRE NEEDPIN */
|
||||||
#define MAXLEN_PIN 100
|
#define MAXLEN_PIN 100
|
||||||
|
|
||||||
|
|
||||||
|
/* We keep track of the primary client using scdaemon. This one will
|
||||||
|
for example receive signal on card change. */
|
||||||
|
static ctrl_t primary_connection;
|
||||||
|
|
||||||
|
|
||||||
#define set_error(e,t) assuan_set_error (ctx, ASSUAN_ ## e, (t))
|
#define set_error(e,t) assuan_set_error (ctx, ASSUAN_ ## e, (t))
|
||||||
|
|
||||||
/* Data used to associate an Assuan context with local server data */
|
/* Data used to associate an Assuan context with local server data */
|
||||||
struct server_local_s {
|
struct server_local_s {
|
||||||
ASSUAN_CONTEXT assuan_ctx;
|
ASSUAN_CONTEXT assuan_ctx;
|
||||||
|
int event_signal; /* Or 0 if not used. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +104,18 @@ reset_notify (ASSUAN_CONTEXT ctx)
|
|||||||
static int
|
static int
|
||||||
option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
|
option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
return 0;
|
ctrl_t ctrl = assuan_get_pointer (ctx);
|
||||||
|
|
||||||
|
if (!strcmp (key, "event-signal"))
|
||||||
|
{
|
||||||
|
/* A value of 0 is allowed to reset the event signal. */
|
||||||
|
int i = *value? atoi (value) : -1;
|
||||||
|
if (i < 0)
|
||||||
|
return ASSUAN_Parameter_Error;
|
||||||
|
ctrl->server_local->event_signal = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1096,6 +1115,10 @@ scd_command_handler (int listen_fd)
|
|||||||
if (DBG_ASSUAN)
|
if (DBG_ASSUAN)
|
||||||
assuan_set_log_stream (ctx, log_get_stream ());
|
assuan_set_log_stream (ctx, log_get_stream ());
|
||||||
|
|
||||||
|
/* Store the primary connection's assuan context. */
|
||||||
|
if (!primary_connection)
|
||||||
|
primary_connection = &ctrl;
|
||||||
|
|
||||||
/* We open the reader right at startup so that the ticker is able to
|
/* We open the reader right at startup so that the ticker is able to
|
||||||
update the status file. */
|
update the status file. */
|
||||||
if (ctrl.reader_slot == -1)
|
if (ctrl.reader_slot == -1)
|
||||||
@ -1122,6 +1145,12 @@ scd_command_handler (int listen_fd)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The next client will be the primary conenction if this one
|
||||||
|
terminates. */
|
||||||
|
if (primary_connection == &ctrl)
|
||||||
|
primary_connection = NULL;
|
||||||
|
|
||||||
do_reset (&ctrl, 1); /* Cleanup. */
|
do_reset (&ctrl, 1); /* Cleanup. */
|
||||||
|
|
||||||
assuan_deinit_server (ctx);
|
assuan_deinit_server (ctx);
|
||||||
@ -1221,6 +1250,19 @@ scd_update_reader_status_file (void)
|
|||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
xfree (fname);
|
xfree (fname);
|
||||||
|
|
||||||
|
/* Send a signal to the primary client, if any. */
|
||||||
|
if (primary_connection && primary_connection->server_local
|
||||||
|
&& primary_connection->server_local->assuan_ctx)
|
||||||
|
{
|
||||||
|
pid_t pid = assuan_get_pid (primary_connection
|
||||||
|
->server_local->assuan_ctx);
|
||||||
|
int signo = primary_connection->server_local->event_signal;
|
||||||
|
|
||||||
|
log_info ("client pid is %d, sending signal %d\n", pid, signo);
|
||||||
|
if (pid != (pid_t)(-1) && pid && signo > 0)
|
||||||
|
kill (pid, signo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,15 +839,11 @@ handle_signal (int signo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
if (opt.verbose < 5)
|
log_info ("SIGUSR1 received - no action defined\n");
|
||||||
opt.verbose++;
|
|
||||||
log_info ("SIGUSR1 received - verbosity set to %d\n", opt.verbose);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGUSR2:
|
case SIGUSR2:
|
||||||
if (opt.verbose)
|
log_info ("SIGUSR2 received - no action defined\n");
|
||||||
opt.verbose--;
|
|
||||||
log_info ("SIGUSR2 received - verbosity set to %d\n", opt.verbose );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user