/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

  • Committer: Teddy Hogeborn
  • Date: 2009-01-17 09:46:54 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090117094654-ydvanis7caqoxxn7
* mandos-keygen (password): Remove bashism "${PIPESTATUS}".

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define _GNU_SOURCE             /* TEMP_FAILURE_RETRY(), asprintf() */
37
37
 
38
38
#include <stdio.h>              /* fprintf(), stderr, fwrite(),
39
 
                                   stdout, ferror(), sscanf(),
40
 
                                   remove() */
 
39
                                   stdout, ferror(), sscanf */
41
40
#include <stdint.h>             /* uint16_t, uint32_t */
42
41
#include <stddef.h>             /* NULL, size_t, ssize_t */
43
42
#include <stdlib.h>             /* free(), EXIT_SUCCESS, EXIT_FAILURE,
839
838
    mandos_context mc = { .simple_poll = NULL, .server = NULL,
840
839
                          .dh_bits = 1024, .priority = "SECURE256"
841
840
                          ":!CTYPE-X.509:+CTYPE-OPENPGP" };
842
 
    bool gnutls_initialized = false;
843
 
    bool gpgme_initialized = false;
 
841
    bool gnutls_initalized = false;
 
842
    bool gpgme_initalized = false;
844
843
    
845
844
    {
846
845
      struct argp_option options[] = {
976
975
      exitcode = EXIT_FAILURE;
977
976
      goto end;
978
977
    } else {
979
 
      gnutls_initialized = true;
 
978
      gnutls_initalized = true;
980
979
    }
981
980
    
982
981
    if(mkdtemp(tempdir) == NULL){
986
985
    }
987
986
    
988
987
    if(not init_gpgme(&mc, pubkey, seckey, tempdir)){
989
 
      fprintf(stderr, "init_gpgme failed\n");
 
988
      fprintf(stderr, "gpgme_initalized failed\n");
990
989
      exitcode = EXIT_FAILURE;
991
990
      goto end;
992
991
    } else {
993
 
      gpgme_initialized = true;
 
992
      gpgme_initalized = true;
994
993
    }
995
994
    
996
995
    if_index = (AvahiIfIndex) if_nametoindex(interface);
1106
1105
    if(mc.simple_poll != NULL)
1107
1106
        avahi_simple_poll_free(mc.simple_poll);
1108
1107
    
1109
 
    if(gnutls_initialized){
 
1108
    if(gnutls_initalized){
1110
1109
      gnutls_certificate_free_credentials(mc.cred);
1111
1110
      gnutls_global_deinit();
1112
1111
      gnutls_dh_params_deinit(mc.dh_params);
1113
1112
    }
1114
1113
    
1115
 
    if(gpgme_initialized){
 
1114
    if(gpgme_initalized){
1116
1115
      gpgme_release(mc.ctx);
1117
1116
    }
1118
1117
    
1131
1130
          if(direntry == NULL){
1132
1131
            break;
1133
1132
          }
1134
 
          /* Skip "." and ".." */
1135
 
          if(direntry->d_name[0] == '.'
1136
 
             and (direntry->d_name[1] == '\0'
1137
 
                  or (direntry->d_name[1] == '.'
1138
 
                      and direntry->d_name[2] == '\0'))){
1139
 
            continue;
1140
 
          }
1141
 
          char *fullname = NULL;
1142
 
          ret = asprintf(&fullname, "%s/%s", tempdir,
1143
 
                         direntry->d_name);
1144
 
          if(ret < 0){
1145
 
            perror("asprintf");
1146
 
            continue;
1147
 
          }
1148
 
          ret = remove(fullname);
1149
 
          if(ret == -1){
1150
 
            fprintf(stderr, "remove(\"%s\"): %s\n", fullname,
1151
 
                    strerror(errno));
1152
 
          }
1153
 
          free(fullname);
 
1133
          if(direntry->d_type == DT_REG){
 
1134
            char *fullname = NULL;
 
1135
            ret = asprintf(&fullname, "%s/%s", tempdir,
 
1136
                           direntry->d_name);
 
1137
            if(ret < 0){
 
1138
              perror("asprintf");
 
1139
              continue;
 
1140
            }
 
1141
            ret = unlink(fullname);
 
1142
            if(ret == -1){
 
1143
              fprintf(stderr, "unlink(\"%s\"): %s",
 
1144
                      fullname, strerror(errno));
 
1145
            }
 
1146
            free(fullname);
 
1147
          }
1154
1148
        }
1155
1149
        closedir(d);
1156
1150
      }
1159
1153
        perror("rmdir");
1160
1154
      }
1161
1155
    }
1162
 
    
 
1156
          
1163
1157
    return exitcode;
1164
1158
}