/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2012-06-16 22:38:54 UTC
  • mto: (301.1.1 release) (237.7.272 trunk)
  • mto: This revision was merged to the branch mainline in revision 302.
  • Revision ID: teddy@recompile.se-20120616223854-mfxkg6fgqr56sma5
* plugins.d/mandos-client (mandos_context): Removed "simple_poll"
                                            member.
  (simple_poll): New global variable.  All users changed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
 
155
155
/* Used for passing in values through the Avahi callback functions */
156
156
typedef struct {
157
 
  AvahiSimplePoll *simple_poll;
158
157
  AvahiServer *server;
159
158
  gnutls_certificate_credentials_t cred;
160
159
  unsigned int dh_bits;
164
163
  server *current_server;
165
164
} mandos_context;
166
165
 
167
 
/* global context so signal handler can reach it*/
168
 
mandos_context mc = { .simple_poll = NULL, .server = NULL,
169
 
                      .dh_bits = 1024, .priority = "SECURE256"
170
 
                      ":!CTYPE-X.509:+CTYPE-OPENPGP",
171
 
                      .current_server = NULL };
 
166
/* global so signal handler can reach it*/
 
167
AvahiSimplePoll *simple_poll;
 
168
mandos_context mc = { .server = NULL, .dh_bits = 1024,
 
169
                      .priority = "SECURE256:!CTYPE-X.509:"
 
170
                      "+CTYPE-OPENPGP", .current_server = NULL };
172
171
 
173
172
sig_atomic_t quit_now = 0;
174
173
int signal_received = 0;
254
253
  gpgme_error_t rc;
255
254
  gpgme_engine_info_t engine_info;
256
255
  
257
 
  
258
256
  /*
259
257
   * Helper function to insert pub and seckey to the engine keyring.
260
258
   */
1038
1036
                                           interface,
1039
1037
                                           avahi_proto_to_af(proto));
1040
1038
      if(ret == 0){
1041
 
        avahi_simple_poll_quit(mc.simple_poll);
 
1039
        avahi_simple_poll_quit(simple_poll);
1042
1040
      } else {
1043
1041
        if(not add_server(ip, (in_port_t)port, interface,
1044
1042
                          avahi_proto_to_af(proto))){
1078
1076
    
1079
1077
    fprintf_plus(stderr, "(Avahi browser) %s\n",
1080
1078
                 avahi_strerror(avahi_server_errno(mc.server)));
1081
 
    avahi_simple_poll_quit(mc.simple_poll);
 
1079
    avahi_simple_poll_quit(simple_poll);
1082
1080
    return;
1083
1081
    
1084
1082
  case AVAHI_BROWSER_NEW:
1117
1115
  signal_received = sig;
1118
1116
  int old_errno = errno;
1119
1117
  /* set main loop to exit */
1120
 
  if(mc.simple_poll != NULL){
1121
 
    avahi_simple_poll_quit(mc.simple_poll);
 
1118
  if(simple_poll != NULL){
 
1119
    avahi_simple_poll_quit(simple_poll);
1122
1120
  }
1123
1121
  errno = old_errno;
1124
1122
}
1366
1364
                                         mc.current_server->if_index,
1367
1365
                                         mc.current_server->af);
1368
1366
        if(ret == 0){
1369
 
          avahi_simple_poll_quit(mc.simple_poll);
 
1367
          avahi_simple_poll_quit(simple_poll);
1370
1368
          return 0;
1371
1369
        }
1372
1370
        ret = clock_gettime(CLOCK_MONOTONIC,
2047
2045
     from the signal handler */
2048
2046
  /* Initialize the pseudo-RNG for Avahi */
2049
2047
  srand((unsigned int) time(NULL));
2050
 
  mc.simple_poll = avahi_simple_poll_new();
2051
 
  if(mc.simple_poll == NULL){
 
2048
  simple_poll = avahi_simple_poll_new();
 
2049
  if(simple_poll == NULL){
2052
2050
    fprintf_plus(stderr,
2053
2051
                 "Avahi: Failed to create simple poll object.\n");
2054
2052
    exitcode = EX_UNAVAILABLE;
2305
2303
    config.publish_domain = 0;
2306
2304
    
2307
2305
    /* Allocate a new server */
2308
 
    mc.server = avahi_server_new(avahi_simple_poll_get
2309
 
                                 (mc.simple_poll), &config, NULL,
2310
 
                                 NULL, &ret_errno);
 
2306
    mc.server = avahi_server_new(avahi_simple_poll_get(simple_poll),
 
2307
                                 &config, NULL, NULL, &ret_errno);
2311
2308
    
2312
2309
    /* Free the Avahi configuration data */
2313
2310
    avahi_server_config_free(&config);
2346
2343
    fprintf_plus(stderr, "Starting Avahi loop search\n");
2347
2344
  }
2348
2345
 
2349
 
  ret = avahi_loop_with_timeout(mc.simple_poll,
 
2346
  ret = avahi_loop_with_timeout(simple_poll,
2350
2347
                                (int)(retry_interval * 1000));
2351
2348
  if(debug){
2352
2349
    fprintf_plus(stderr, "avahi_loop_with_timeout exited %s\n",
2366
2363
  if(mc.server != NULL)
2367
2364
    avahi_server_free(mc.server);
2368
2365
  
2369
 
  if(mc.simple_poll != NULL)
2370
 
    avahi_simple_poll_free(mc.simple_poll);
 
2366
  if(simple_poll != NULL)
 
2367
    avahi_simple_poll_free(simple_poll);
2371
2368
  
2372
2369
  if(gnutls_initialized){
2373
2370
    gnutls_certificate_free_credentials(mc.cred);