=== modified file 'plugin-runner.c' --- plugin-runner.c 2009-01-13 04:29:35 +0000 +++ plugin-runner.c 2009-01-13 04:35:19 +0000 @@ -99,15 +99,15 @@ or if none is found, creates a new one */ static plugin *getplugin(char *name){ /* Check for exiting plugin with that name */ - for (plugin *p = plugin_list; p != NULL; p = p->next){ - if ((p->name == name) - or (p->name and name and (strcmp(p->name, name) == 0))){ + for(plugin *p = plugin_list; p != NULL; p = p->next){ + if((p->name == name) + or (p->name and name and (strcmp(p->name, name) == 0))){ return p; } } /* Create a new plugin */ plugin *new_plugin = malloc(sizeof(plugin)); - if (new_plugin == NULL){ + if(new_plugin == NULL){ return NULL; } char *copy_name = NULL; @@ -124,7 +124,7 @@ .next = plugin_list }; new_plugin->argv = malloc(sizeof(char *) * 2); - if (new_plugin->argv == NULL){ + if(new_plugin->argv == NULL){ free(copy_name); free(new_plugin); return NULL; @@ -230,7 +230,7 @@ break; } if(pid == -1){ - if (errno != ECHILD){ + if(errno != ECHILD){ perror("waitpid"); } /* No child processes */ @@ -372,11 +372,11 @@ { .name = NULL } }; - error_t parse_opt (int key, char *arg, __attribute__((unused)) - struct argp_state *state) { - switch (key) { + error_t parse_opt(int key, char *arg, __attribute__((unused)) + struct argp_state *state) { + switch(key) { case 'g': /* --global-options */ - if (arg != NULL){ + if(arg != NULL){ char *p; while((p = strsep(&arg, ",")) != NULL){ if(p[0] == '\0'){ @@ -398,7 +398,7 @@ } break; case 'o': /* --options-for */ - if (arg != NULL){ + if(arg != NULL){ char *p_name = strsep(&arg, ":"); if(p_name[0] == '\0' or arg == NULL){ break; @@ -435,7 +435,7 @@ } break; case 'd': /* --disable */ - if (arg != NULL){ + if(arg != NULL){ plugin *p = getplugin(arg); if(p == NULL){ return ARGP_ERR_UNKNOWN; @@ -444,7 +444,7 @@ } break; case 'e': /* --enable */ - if (arg != NULL){ + if(arg != NULL){ plugin *p = getplugin(arg); if(p == NULL){ return ARGP_ERR_UNKNOWN; @@ -503,10 +503,10 @@ /* This option parser is the same as parse_opt() above, except it ignores everything but the --config-file option. */ - error_t parse_opt_config_file (int key, char *arg, - __attribute__((unused)) - struct argp_state *state) { - switch (key) { + error_t parse_opt_config_file(int key, char *arg, + __attribute__((unused)) + struct argp_state *state) { + switch(key) { case 'g': /* --global-options */ case 'G': /* --global-env */ case 'o': /* --options-for */ @@ -541,8 +541,8 @@ /* Parse using parse_opt_config_file() in order to get the custom config file location, if any. */ - ret = argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, NULL); - if (ret == ARGP_ERR_UNKNOWN){ + ret = argp_parse(&argp, argc, argv, ARGP_IN_ORDER, 0, NULL); + if(ret == ARGP_ERR_UNKNOWN){ fprintf(stderr, "Unknown error while parsing arguments\n"); exitstatus = EXIT_FAILURE; goto fallback; @@ -552,7 +552,7 @@ argp.parser = parse_opt; /* Open the configfile if available */ - if (argfile == NULL){ + if(argfile == NULL){ conffp = fopen(AFILE, "r"); } else { conffp = fopen(argfile, "r"); @@ -613,7 +613,7 @@ } else { /* Check for harmful errors and go to fallback. Other errors might not affect opening plugins */ - if (errno == EMFILE or errno == ENFILE or errno == ENOMEM){ + if(errno == EMFILE or errno == ENFILE or errno == ENOMEM){ perror("fopen"); exitstatus = EXIT_FAILURE; goto fallback; @@ -622,9 +622,9 @@ /* If there was any arguments from configuration file, pass them to parser as command arguments */ if(custom_argv != NULL){ - ret = argp_parse (&argp, custom_argc, custom_argv, ARGP_IN_ORDER, - 0, NULL); - if (ret == ARGP_ERR_UNKNOWN){ + ret = argp_parse(&argp, custom_argc, custom_argv, ARGP_IN_ORDER, + 0, NULL); + if(ret == ARGP_ERR_UNKNOWN){ fprintf(stderr, "Unknown error while parsing arguments\n"); exitstatus = EXIT_FAILURE; goto fallback; @@ -633,8 +633,8 @@ /* Parse actual command line arguments, to let them override the config file */ - ret = argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, NULL); - if (ret == ARGP_ERR_UNKNOWN){ + ret = argp_parse(&argp, argc, argv, ARGP_IN_ORDER, 0, NULL); + if(ret == ARGP_ERR_UNKNOWN){ fprintf(stderr, "Unknown error while parsing arguments\n"); exitstatus = EXIT_FAILURE; goto fallback; @@ -656,15 +656,15 @@ /* Strip permissions down to nobody */ ret = setuid(uid); - if (ret == -1){ + if(ret == -1){ perror("setuid"); } setgid(gid); - if (ret == -1){ + if(ret == -1){ perror("setgid"); } - if (plugindir == NULL){ + if(plugindir == NULL){ dir = opendir(PDIR); } else { dir = opendir(plugindir); @@ -697,7 +697,7 @@ /* All directory entries have been processed */ if(dirst == NULL){ - if (errno == EBADF){ + if(errno == EBADF){ perror("readdir"); exitstatus = EXIT_FAILURE; goto fallback; @@ -763,14 +763,14 @@ } ret = stat(filename, &st); - if (ret == -1){ + if(ret == -1){ perror("stat"); free(filename); continue; } /* Ignore non-executable files */ - if (not S_ISREG(st.st_mode) or (access(filename, X_OK) != 0)){ + if(not S_ISREG(st.st_mode) or (access(filename, X_OK) != 0)){ if(debug){ fprintf(stderr, "Ignoring plugin dir entry \"%s\"" " with bad type or mode\n", filename); @@ -823,7 +823,7 @@ int pipefd[2]; ret = pipe(pipefd); - if (ret == -1){ + if(ret == -1){ perror("pipe"); exitstatus = EXIT_FAILURE; goto fallback; @@ -842,7 +842,7 @@ goto fallback; } /* Block SIGCHLD until process is safely in process list */ - ret = sigprocmask (SIG_BLOCK, &sigchld_action.sa_mask, NULL); + ret = sigprocmask(SIG_BLOCK, &sigchld_action.sa_mask, NULL); if(ret < 0){ perror("sigprocmask"); exitstatus = EXIT_FAILURE; @@ -896,9 +896,9 @@ close(pipefd[1]); /* Close unused write end of pipe */ free(filename); plugin *new_plugin = getplugin(dirst->d_name); - if (new_plugin == NULL){ + if(new_plugin == NULL){ perror("getplugin"); - ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, NULL); + ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, NULL); if(ret < 0){ perror("sigprocmask"); } @@ -911,7 +911,7 @@ /* Unblock SIGCHLD so signal handler can be run if this process has already completed */ - ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, NULL); + ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, NULL); if(ret < 0){ perror("sigprocmask"); exitstatus = EXIT_FAILURE; @@ -920,7 +920,7 @@ FD_SET(new_plugin->fd, &rfds_all); - if (maxfd < new_plugin->fd){ + if(maxfd < new_plugin->fd){ maxfd = new_plugin->fd; } } @@ -943,7 +943,7 @@ while(plugin_list){ fd_set rfds = rfds_all; int select_ret = select(maxfd+1, &rfds, NULL, NULL, NULL); - if (select_ret == -1){ + if(select_ret == -1){ perror("select"); exitstatus = EXIT_FAILURE; goto fallback; @@ -989,8 +989,8 @@ proc = next_plugin; /* We are done modifying process list, so unblock signal */ - ret = sigprocmask (SIG_UNBLOCK, &sigchld_action.sa_mask, - NULL); + ret = sigprocmask(SIG_UNBLOCK, &sigchld_action.sa_mask, + NULL); if(ret < 0){ perror("sigprocmask"); exitstatus = EXIT_FAILURE; @@ -1025,7 +1025,7 @@ if(proc->buffer_length + BUFFER_SIZE > proc->buffer_size){ proc->buffer = realloc(proc->buffer, proc->buffer_size + (size_t) BUFFER_SIZE); - if (proc->buffer == NULL){ + if(proc->buffer == NULL){ perror("malloc"); exitstatus = EXIT_FAILURE; goto fallback; === modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-01-13 01:36:46 +0000 +++ plugins.d/mandos-client.c 2009-01-13 04:35:19 +0000 @@ -48,13 +48,15 @@ #include /* socket(), inet_pton(), sockaddr, sockaddr_in6, PF_INET6, SOCK_STREAM, INET6_ADDRSTRLEN, - uid_t, gid_t, open(), opendir(), DIR */ + uid_t, gid_t, open(), opendir(), + DIR */ #include /* open() */ #include /* socket(), struct sockaddr_in6, struct in6_addr, inet_pton(), connect() */ #include /* open() */ -#include /* opendir(), struct dirent, readdir() */ +#include /* opendir(), struct dirent, readdir() + */ #include /* PRIu16, SCNu16 */ #include /* assert() */ #include /* perror(), errno */ @@ -90,7 +92,8 @@ gnutls_* init_gnutls_session(), GNUTLS_* */ -#include /* gnutls_certificate_set_openpgp_key_file(), +#include + /* gnutls_certificate_set_openpgp_key_file(), GNUTLS_OPENPGP_FMT_BASE64 */ /* GPGME */ @@ -129,9 +132,9 @@ */ size_t adjustbuffer(char **buffer, size_t buffer_length, size_t buffer_capacity){ - if (buffer_length + BUFFER_SIZE > buffer_capacity){ + if(buffer_length + BUFFER_SIZE > buffer_capacity){ *buffer = realloc(*buffer, buffer_capacity + BUFFER_SIZE); - if (buffer == NULL){ + if(buffer == NULL){ return 0; } buffer_capacity += BUFFER_SIZE; @@ -163,14 +166,14 @@ } rc = gpgme_data_new_from_fd(&pgp_data, fd); - if (rc != GPG_ERR_NO_ERROR){ + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_data_new_from_fd: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); return false; } rc = gpgme_op_import(mc->ctx, pgp_data); - if (rc != GPG_ERR_NO_ERROR){ + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_op_import: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); return false; @@ -184,22 +187,22 @@ return true; } - if (debug){ + if(debug){ fprintf(stderr, "Initialize gpgme\n"); } /* Init GPGME */ gpgme_check_version(NULL); rc = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP); - if (rc != GPG_ERR_NO_ERROR){ + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_engine_check_version: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); return false; } /* Set GPGME home directory for the OpenPGP engine only */ - rc = gpgme_get_engine_info (&engine_info); - if (rc != GPG_ERR_NO_ERROR){ + rc = gpgme_get_engine_info(&engine_info); + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_get_engine_info: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); return false; @@ -219,13 +222,13 @@ /* Create new GPGME "context" */ rc = gpgme_new(&(mc->ctx)); - if (rc != GPG_ERR_NO_ERROR){ + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_new: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); return false; } - if (not import_key(pubkey) or not import_key(seckey)){ + if(not import_key(pubkey) or not import_key(seckey)){ return false; } @@ -236,24 +239,24 @@ * Decrypt OpenPGP data. * Returns -1 on error */ -static ssize_t pgp_packet_decrypt (const mandos_context *mc, - const char *cryptotext, - size_t crypto_size, - char **plaintext){ +static ssize_t pgp_packet_decrypt(const mandos_context *mc, + const char *cryptotext, + size_t crypto_size, + char **plaintext){ gpgme_data_t dh_crypto, dh_plain; gpgme_error_t rc; ssize_t ret; size_t plaintext_capacity = 0; ssize_t plaintext_length = 0; - if (debug){ + if(debug){ fprintf(stderr, "Trying to decrypt OpenPGP data\n"); } /* Create new GPGME data buffer from memory cryptotext */ rc = gpgme_data_new_from_mem(&dh_crypto, cryptotext, crypto_size, 0); - if (rc != GPG_ERR_NO_ERROR){ + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_data_new_from_mem: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); return -1; @@ -261,7 +264,7 @@ /* Create new empty GPGME data buffer for the plaintext */ rc = gpgme_data_new(&dh_plain); - if (rc != GPG_ERR_NO_ERROR){ + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_data_new: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); gpgme_data_release(dh_crypto); @@ -271,14 +274,14 @@ /* Decrypt data from the cryptotext data buffer to the plaintext data buffer */ rc = gpgme_op_decrypt(mc->ctx, dh_crypto, dh_plain); - if (rc != GPG_ERR_NO_ERROR){ + if(rc != GPG_ERR_NO_ERROR){ fprintf(stderr, "bad gpgme_op_decrypt: %s: %s\n", gpgme_strsource(rc), gpgme_strerror(rc)); plaintext_length = -1; - if (debug){ + if(debug){ gpgme_decrypt_result_t result; result = gpgme_op_decrypt_result(mc->ctx); - if (result == NULL){ + if(result == NULL){ fprintf(stderr, "gpgme_op_decrypt_result failed\n"); } else { fprintf(stderr, "Unsupported algorithm: %s\n", @@ -311,7 +314,7 @@ } /* Seek back to the beginning of the GPGME plaintext data buffer */ - if (gpgme_data_seek(dh_plain, (off_t) 0, SEEK_SET) == -1){ + if(gpgme_data_seek(dh_plain, (off_t)0, SEEK_SET) == -1){ perror("gpgme_data_seek"); plaintext_length = -1; goto decrypt_end; @@ -322,7 +325,7 @@ plaintext_capacity = adjustbuffer(plaintext, (size_t)plaintext_length, plaintext_capacity); - if (plaintext_capacity == 0){ + if(plaintext_capacity == 0){ perror("adjustbuffer"); plaintext_length = -1; goto decrypt_end; @@ -331,7 +334,7 @@ ret = gpgme_data_read(dh_plain, *plaintext + plaintext_length, BUFFER_SIZE); /* Print the data, if any */ - if (ret == 0){ + if(ret == 0){ /* EOF */ break; } @@ -361,9 +364,9 @@ return plaintext_length; } -static const char * safer_gnutls_strerror (int value) { - const char *ret = gnutls_strerror (value); /* Spurious warning */ - if (ret == NULL) +static const char * safer_gnutls_strerror(int value) { + const char *ret = gnutls_strerror(value); /* Spurious warning */ + if(ret == NULL) ret = "(unknown)"; return ret; } @@ -384,13 +387,13 @@ } ret = gnutls_global_init(); - if (ret != GNUTLS_E_SUCCESS) { - fprintf (stderr, "GnuTLS global_init: %s\n", - safer_gnutls_strerror(ret)); + if(ret != GNUTLS_E_SUCCESS) { + fprintf(stderr, "GnuTLS global_init: %s\n", + safer_gnutls_strerror(ret)); return -1; } - if (debug){ + if(debug){ /* "Use a log level over 10 to enable all debugging options." * - GnuTLS manual */ @@ -400,11 +403,11 @@ /* OpenPGP credentials */ gnutls_certificate_allocate_credentials(&mc->cred); - if (ret != GNUTLS_E_SUCCESS){ - fprintf (stderr, "GnuTLS memory error: %s\n", /* Spurious - warning */ - safer_gnutls_strerror(ret)); - gnutls_global_deinit (); + if(ret != GNUTLS_E_SUCCESS){ + fprintf(stderr, "GnuTLS memory error: %s\n", /* Spurious + warning */ + safer_gnutls_strerror(ret)); + gnutls_global_deinit(); return -1; } @@ -417,7 +420,7 @@ ret = gnutls_certificate_set_openpgp_key_file (mc->cred, pubkeyfilename, seckeyfilename, GNUTLS_OPENPGP_FMT_BASE64); - if (ret != GNUTLS_E_SUCCESS) { + if(ret != GNUTLS_E_SUCCESS) { fprintf(stderr, "Error[%d] while reading the OpenPGP key pair ('%s'," " '%s')\n", ret, pubkeyfilename, seckeyfilename); @@ -428,15 +431,15 @@ /* GnuTLS server initialization */ ret = gnutls_dh_params_init(&mc->dh_params); - if (ret != GNUTLS_E_SUCCESS) { - fprintf (stderr, "Error in GnuTLS DH parameter initialization:" - " %s\n", safer_gnutls_strerror(ret)); + if(ret != GNUTLS_E_SUCCESS) { + fprintf(stderr, "Error in GnuTLS DH parameter initialization:" + " %s\n", safer_gnutls_strerror(ret)); goto globalfail; } ret = gnutls_dh_params_generate2(mc->dh_params, mc->dh_bits); - if (ret != GNUTLS_E_SUCCESS) { - fprintf (stderr, "Error in GnuTLS prime generation: %s\n", - safer_gnutls_strerror(ret)); + if(ret != GNUTLS_E_SUCCESS) { + fprintf(stderr, "Error in GnuTLS prime generation: %s\n", + safer_gnutls_strerror(ret)); goto globalfail; } @@ -457,7 +460,7 @@ int ret; /* GnuTLS session creation */ ret = gnutls_init(session, GNUTLS_SERVER); - if (ret != GNUTLS_E_SUCCESS){ + if(ret != GNUTLS_E_SUCCESS){ fprintf(stderr, "Error in GnuTLS session initialization: %s\n", safer_gnutls_strerror(ret)); } @@ -465,29 +468,29 @@ { const char *err; ret = gnutls_priority_set_direct(*session, mc->priority, &err); - if (ret != GNUTLS_E_SUCCESS) { + if(ret != GNUTLS_E_SUCCESS) { fprintf(stderr, "Syntax error at: %s\n", err); fprintf(stderr, "GnuTLS error: %s\n", safer_gnutls_strerror(ret)); - gnutls_deinit (*session); + gnutls_deinit(*session); return -1; } } ret = gnutls_credentials_set(*session, GNUTLS_CRD_CERTIFICATE, mc->cred); - if (ret != GNUTLS_E_SUCCESS) { + if(ret != GNUTLS_E_SUCCESS) { fprintf(stderr, "Error setting GnuTLS credentials: %s\n", safer_gnutls_strerror(ret)); - gnutls_deinit (*session); + gnutls_deinit(*session); return -1; } /* ignore client certificate if any. */ - gnutls_certificate_server_set_request (*session, - GNUTLS_CERT_IGNORE); + gnutls_certificate_server_set_request(*session, + GNUTLS_CERT_IGNORE); - gnutls_dh_set_prime_bits (*session, mc->dh_bits); + gnutls_dh_set_prime_bits(*session, mc->dh_bits); return 0; } @@ -513,8 +516,8 @@ char interface[IF_NAMESIZE]; gnutls_session_t session; - ret = init_gnutls_session (mc, &session); - if (ret != 0){ + ret = init_gnutls_session(mc, &session); + if(ret != 0){ return -1; } @@ -542,7 +545,7 @@ /* It would be nice to have a way to detect if we were passed an IPv4 address here. Now we assume an IPv6 address. */ ret = inet_pton(AF_INET6, ip, &to.in6.sin6_addr); - if (ret < 0 ){ + if(ret < 0 ){ perror("inet_pton"); return -1; } @@ -569,18 +572,18 @@ } ret = connect(tcp_sd, &to.in, sizeof(to)); - if (ret < 0){ + if(ret < 0){ perror("connect"); return -1; } const char *out = mandos_protocol_version; written = 0; - while (true){ + while(true){ size_t out_size = strlen(out); ret = (int)TEMP_FAILURE_RETRY(write(tcp_sd, out + written, out_size - written)); - if (ret == -1){ + if(ret == -1){ perror("write"); retval = -1; goto mandos_end; @@ -589,7 +592,7 @@ if(written < out_size){ continue; } else { - if (out == mandos_protocol_version){ + if(out == mandos_protocol_version){ written = 0; out = "\r\n"; } else { @@ -602,16 +605,16 @@ fprintf(stderr, "Establishing TLS session with %s\n", ip); } - gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) tcp_sd); + gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t) tcp_sd); do{ - ret = gnutls_handshake (session); + ret = gnutls_handshake(session); } while(ret == GNUTLS_E_AGAIN or ret == GNUTLS_E_INTERRUPTED); - if (ret != GNUTLS_E_SUCCESS){ + if(ret != GNUTLS_E_SUCCESS){ if(debug){ fprintf(stderr, "*** GnuTLS Handshake failed ***\n"); - gnutls_perror (ret); + gnutls_perror(ret); } retval = -1; goto mandos_end; @@ -627,7 +630,7 @@ while(true){ buffer_capacity = adjustbuffer(&buffer, buffer_length, buffer_capacity); - if (buffer_capacity == 0){ + if(buffer_capacity == 0){ perror("adjustbuffer"); retval = -1; goto mandos_end; @@ -635,21 +638,21 @@ sret = gnutls_record_recv(session, buffer+buffer_length, BUFFER_SIZE); - if (sret == 0){ + if(sret == 0){ break; } - if (sret < 0){ + if(sret < 0){ switch(sret){ case GNUTLS_E_INTERRUPTED: case GNUTLS_E_AGAIN: break; case GNUTLS_E_REHANDSHAKE: do{ - ret = gnutls_handshake (session); + ret = gnutls_handshake(session); } while(ret == GNUTLS_E_AGAIN or ret == GNUTLS_E_INTERRUPTED); - if (ret < 0){ + if(ret < 0){ fprintf(stderr, "*** GnuTLS Re-handshake failed ***\n"); - gnutls_perror (ret); + gnutls_perror(ret); retval = -1; goto mandos_end; } @@ -658,7 +661,7 @@ fprintf(stderr, "Unknown error while reading data from" " encrypted session with Mandos server\n"); retval = -1; - gnutls_bye (session, GNUTLS_SHUT_RDWR); + gnutls_bye(session, GNUTLS_SHUT_RDWR); goto mandos_end; } } else { @@ -670,18 +673,18 @@ fprintf(stderr, "Closing TLS session\n"); } - gnutls_bye (session, GNUTLS_SHUT_RDWR); + gnutls_bye(session, GNUTLS_SHUT_RDWR); - if (buffer_length > 0){ + if(buffer_length > 0){ decrypted_buffer_size = pgp_packet_decrypt(mc, buffer, buffer_length, &decrypted_buffer); - if (decrypted_buffer_size >= 0){ + if(decrypted_buffer_size >= 0){ written = 0; while(written < (size_t) decrypted_buffer_size){ - ret = (int)fwrite (decrypted_buffer + written, 1, - (size_t)decrypted_buffer_size - written, - stdout); + ret = (int)fwrite(decrypted_buffer + written, 1, + (size_t)decrypted_buffer_size - written, + stdout); if(ret == 0 and ferror(stdout)){ if(debug){ fprintf(stderr, "Error writing encrypted data: %s\n", @@ -708,7 +711,7 @@ if(ret == -1){ perror("close"); } - gnutls_deinit (session); + gnutls_deinit(session); return retval; } @@ -732,7 +735,7 @@ /* Called whenever a service has been resolved successfully or timed out */ - switch (event) { + switch(event) { default: case AVAHI_RESOLVER_FAILURE: fprintf(stderr, "(Avahi Resolver) Failed to resolve service '%s'" @@ -750,7 +753,7 @@ interface, port); } int ret = start_mandos_communication(ip, port, interface, mc); - if (ret == 0){ + if(ret == 0){ avahi_simple_poll_quit(mc->simple_poll); } } @@ -774,7 +777,7 @@ /* Called whenever a new services becomes available on the LAN or is removed from the LAN */ - switch (event) { + switch(event) { default: case AVAHI_BROWSER_FAILURE: @@ -789,7 +792,7 @@ the callback function is called the Avahi server will free the resolver for us. */ - if (!(avahi_s_service_resolver_new(mc->server, interface, + if(!(avahi_s_service_resolver_new(mc->server, interface, protocol, name, type, domain, AVAHI_PROTO_INET6, 0, resolve_callback, mc))) @@ -864,9 +867,9 @@ { .name = NULL } }; - error_t parse_opt (int key, char *arg, - struct argp_state *state) { - switch (key) { + error_t parse_opt(int key, char *arg, + struct argp_state *state) { + switch(key) { case 128: /* --debug */ debug = true; break; @@ -893,7 +896,7 @@ mc.priority = arg; break; case ARGP_KEY_ARG: - argp_usage (state); + argp_usage(state); case ARGP_KEY_END: break; default: @@ -906,8 +909,8 @@ .args_doc = "", .doc = "Mandos client -- Get and decrypt" " passwords from a Mandos server" }; - ret = argp_parse (&argp, argc, argv, 0, 0, NULL); - if (ret == ARGP_ERR_UNKNOWN){ + ret = argp_parse(&argp, argc, argv, 0, 0, NULL); + if(ret == ARGP_ERR_UNKNOWN){ fprintf(stderr, "Unknown error while parsing arguments\n"); exitcode = EXIT_FAILURE; goto end; @@ -948,17 +951,17 @@ gid = getgid(); ret = setuid(uid); - if (ret == -1){ + if(ret == -1){ perror("setuid"); } setgid(gid); - if (ret == -1){ + if(ret == -1){ perror("setgid"); } ret = init_gnutls_global(&mc, pubkey, seckey); - if (ret == -1){ + if(ret == -1){ fprintf(stderr, "init_gnutls_global failed\n"); exitcode = EXIT_FAILURE; goto end; @@ -1013,7 +1016,7 @@ goto end; } - if (not debug){ + if(not debug){ avahi_set_log_function(empty_log); } @@ -1022,7 +1025,7 @@ /* Allocate main Avahi loop object */ mc.simple_poll = avahi_simple_poll_new(); - if (mc.simple_poll == NULL) { + if(mc.simple_poll == NULL) { fprintf(stderr, "Avahi: Failed to create simple poll" " object.\n"); exitcode = EXIT_FAILURE; @@ -1048,7 +1051,7 @@ } /* Check if creating the Avahi server object succeeded */ - if (mc.server == NULL) { + if(mc.server == NULL) { fprintf(stderr, "Failed to create Avahi server: %s\n", avahi_strerror(error)); exitcode = EXIT_FAILURE; @@ -1060,7 +1063,7 @@ AVAHI_PROTO_INET6, "_mandos._tcp", NULL, 0, browse_callback, &mc); - if (sb == NULL) { + if(sb == NULL) { fprintf(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_server_errno(mc.server))); exitcode = EXIT_FAILURE; @@ -1069,7 +1072,7 @@ /* Run the main loop */ - if (debug){ + if(debug){ fprintf(stderr, "Starting Avahi loop search\n"); } @@ -1077,23 +1080,23 @@ end: - if (debug){ + if(debug){ fprintf(stderr, "%s exiting\n", argv[0]); } /* Cleanup things */ - if (sb != NULL) + if(sb != NULL) avahi_s_service_browser_free(sb); - if (mc.server != NULL) + if(mc.server != NULL) avahi_server_free(mc.server); - if (mc.simple_poll != NULL) + if(mc.simple_poll != NULL) avahi_simple_poll_free(mc.simple_poll); - if (gnutls_initalized){ + if(gnutls_initalized){ gnutls_certificate_free_credentials(mc.cred); - gnutls_global_deinit (); + gnutls_global_deinit(); gnutls_dh_params_deinit(mc.dh_params); } @@ -1116,7 +1119,7 @@ if(direntry == NULL){ break; } - if (direntry->d_type == DT_REG){ + if(direntry->d_type == DT_REG){ char *fullname = NULL; ret = asprintf(&fullname, "%s/%s", tempdir, direntry->d_name); === modified file 'plugins.d/password-prompt.c' --- plugins.d/password-prompt.c 2009-01-13 04:29:35 +0000 +++ plugins.d/password-prompt.c 2009-01-13 04:35:19 +0000 @@ -89,7 +89,7 @@ debug = true; break; case ARGP_KEY_ARG: - argp_usage (state); + argp_usage(state); break; case ARGP_KEY_END: break; @@ -103,21 +103,21 @@ .args_doc = "", .doc = "Mandos password-prompt -- Read and" " output a password" }; - ret = argp_parse (&argp, argc, argv, 0, 0, NULL); - if (ret == ARGP_ERR_UNKNOWN){ + ret = argp_parse(&argp, argc, argv, 0, 0, NULL); + if(ret == ARGP_ERR_UNKNOWN){ fprintf(stderr, "Unknown error while parsing arguments\n"); return EXIT_FAILURE; } } - if (debug){ + if(debug){ fprintf(stderr, "Starting %s\n", argv[0]); } - if (debug){ + if(debug){ fprintf(stderr, "Storing current terminal attributes\n"); } - if (tcgetattr(STDIN_FILENO, &t_old) != 0){ + if(tcgetattr(STDIN_FILENO, &t_old) != 0){ perror("tcgetattr"); return EXIT_FAILURE; } @@ -131,7 +131,7 @@ perror("sigaction"); return EXIT_FAILURE; } - if (old_action.sa_handler != SIG_IGN){ + if(old_action.sa_handler != SIG_IGN){ ret = sigaction(SIGINT, &new_action, NULL); if(ret == -1){ perror("sigaction"); @@ -143,7 +143,7 @@ perror("sigaction"); return EXIT_FAILURE; } - if (old_action.sa_handler != SIG_IGN){ + if(old_action.sa_handler != SIG_IGN){ ret = sigaction(SIGHUP, &new_action, NULL); if(ret == -1){ perror("sigaction"); @@ -155,7 +155,7 @@ perror("sigaction"); return EXIT_FAILURE; } - if (old_action.sa_handler != SIG_IGN){ + if(old_action.sa_handler != SIG_IGN){ ret = sigaction(SIGTERM, &new_action, NULL); if(ret == -1){ perror("sigaction"); @@ -164,22 +164,22 @@ } - if (debug){ + if(debug){ fprintf(stderr, "Removing echo flag from terminal attributes\n"); } t_new = t_old; t_new.c_lflag &= ~ECHO; - if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_new) != 0){ + if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_new) != 0){ perror("tcsetattr-echo"); return EXIT_FAILURE; } - if (debug){ + if(debug){ fprintf(stderr, "Waiting for input from stdin \n"); } while(true){ - if (quit_now){ + if(quit_now){ if(debug){ fprintf(stderr, "Interrupted by signal, exiting.\n"); } @@ -211,7 +211,7 @@ } } ret = getline(&buffer, &n, stdin); - if (ret > 0){ + if(ret > 0){ status = EXIT_SUCCESS; /* Make n = data size instead of allocated buffer size */ n = (size_t)ret; @@ -232,8 +232,8 @@ } break; } - if (ret < 0){ - if (errno != EINTR and not feof(stdin)){ + if(ret < 0){ + if(errno != EINTR and not feof(stdin)){ perror("getline"); status = EXIT_FAILURE; break; @@ -251,14 +251,14 @@ free(buffer); - if (debug){ + if(debug){ fprintf(stderr, "Restoring terminal attributes\n"); } - if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_old) != 0){ + if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_old) != 0){ perror("tcsetattr+echo"); } - if (debug){ + if(debug){ fprintf(stderr, "%s is exiting with status %d\n", argv[0], status); }