/mandos/trunk

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

« back to all changes in this revision

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

merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
        }
310
310
        gpgme_recipient_t recipient;
311
311
        recipient = result->recipients;
312
 
        if(recipient){
313
 
          while(recipient != NULL){
314
 
            fprintf(stderr, "Public key algorithm: %s\n",
315
 
                    gpgme_pubkey_algo_name(recipient->pubkey_algo));
316
 
            fprintf(stderr, "Key ID: %s\n", recipient->keyid);
317
 
            fprintf(stderr, "Secret key available: %s\n",
318
 
                    recipient->status == GPG_ERR_NO_SECKEY
319
 
                    ? "No" : "Yes");
320
 
            recipient = recipient->next;
321
 
          }
 
312
        while(recipient != NULL){
 
313
          fprintf(stderr, "Public key algorithm: %s\n",
 
314
                  gpgme_pubkey_algo_name(recipient->pubkey_algo));
 
315
          fprintf(stderr, "Key ID: %s\n", recipient->keyid);
 
316
          fprintf(stderr, "Secret key available: %s\n",
 
317
                  recipient->status == GPG_ERR_NO_SECKEY
 
318
                  ? "No" : "Yes");
 
319
          recipient = recipient->next;
322
320
        }
323
321
      }
324
322
    }
901
899
  int exitcode = EXIT_SUCCESS;
902
900
  const char *interface = "eth0";
903
901
  struct ifreq network;
904
 
  int sd;
 
902
  int sd = -1;
 
903
  bool interface_taken_up = false;
905
904
  uid_t uid;
906
905
  gid_t gid;
907
906
  char *connect_to = NULL;
1115
1114
#endif  /* __linux__ */
1116
1115
        goto end;
1117
1116
      }
 
1117
      interface_taken_up = true;
1118
1118
    }
1119
1119
    /* sleep checking until interface is running */
1120
1120
    for(int i=0; i < delay * 4; i++){
1130
1130
        perror("nanosleep");
1131
1131
      }
1132
1132
    }
1133
 
    ret = (int)TEMP_FAILURE_RETRY(close(sd));
1134
 
    if(ret == -1){
1135
 
      perror("close");
 
1133
    if(not interface_taken_up){
 
1134
      ret = (int)TEMP_FAILURE_RETRY(close(sd));
 
1135
      if(ret == -1){
 
1136
        perror("close");
 
1137
      }
1136
1138
    }
1137
1139
#ifdef __linux__
1138
1140
    if(restore_loglevel){
1299
1301
    gpgme_release(mc.ctx);
1300
1302
  }
1301
1303
  
 
1304
  /* Take down the network interface */
 
1305
  if(interface_taken_up){
 
1306
    ret = ioctl(sd, SIOCGIFFLAGS, &network);
 
1307
    if(ret == -1){
 
1308
      perror("ioctl SIOCGIFFLAGS");
 
1309
    } else if(network.ifr_flags & IFF_UP) {
 
1310
      network.ifr_flags &= ~IFF_UP; /* clear flag */
 
1311
      ret = ioctl(sd, SIOCSIFFLAGS, &network);
 
1312
      if(ret == -1){
 
1313
        perror("ioctl SIOCSIFFLAGS");
 
1314
      }
 
1315
    }
 
1316
    ret = (int)TEMP_FAILURE_RETRY(close(sd));
 
1317
    if(ret == -1){
 
1318
      perror("close");
 
1319
    }
 
1320
  }
 
1321
  
1302
1322
  /* Removes the temp directory used by GPGME */
1303
1323
  if(tempdir_created){
1304
1324
    DIR *d;