diff options
Diffstat (limited to 'g13')
-rw-r--r-- | g13/ChangeLog | 1 | ||||
-rw-r--r-- | g13/Makefile.am | 7 | ||||
-rw-r--r-- | g13/backend.c | 18 | ||||
-rw-r--r-- | g13/backend.h | 7 | ||||
-rw-r--r-- | g13/be-encfs.c | 20 | ||||
-rw-r--r-- | g13/be-encfs.h | 5 | ||||
-rw-r--r-- | g13/be-truecrypt.c | 2 | ||||
-rw-r--r-- | g13/be-truecrypt.h | 1 | ||||
-rw-r--r-- | g13/call-gpg.c | 32 | ||||
-rw-r--r-- | g13/create.c | 14 | ||||
-rw-r--r-- | g13/g13.c | 89 | ||||
-rw-r--r-- | g13/g13.h | 10 | ||||
-rw-r--r-- | g13/keyblob.h | 6 | ||||
-rw-r--r-- | g13/mount.c | 26 | ||||
-rw-r--r-- | g13/mount.h | 3 | ||||
-rw-r--r-- | g13/mountinfo.c | 7 | ||||
-rw-r--r-- | g13/mountinfo.h | 1 | ||||
-rw-r--r-- | g13/runner.c | 40 | ||||
-rw-r--r-- | g13/runner.h | 9 | ||||
-rw-r--r-- | g13/server.c | 42 | ||||
-rw-r--r-- | g13/server.h | 1 | ||||
-rw-r--r-- | g13/utils.c | 5 | ||||
-rw-r--r-- | g13/utils.h | 7 |
23 files changed, 166 insertions, 187 deletions
diff --git a/g13/ChangeLog b/g13/ChangeLog index cc51472cc..ecd72226b 100644 --- a/g13/ChangeLog +++ b/g13/ChangeLog @@ -1,4 +1,3 @@ 2009-11-04 Werner Koch <[email protected]> Under initial development - no need for a ChangeLog. - diff --git a/g13/Makefile.am b/g13/Makefile.am index 362f060de..56fd13b88 100644 --- a/g13/Makefile.am +++ b/g13/Makefile.am @@ -7,18 +7,18 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # GnuPG is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. ## Process this file with automake to produce Makefile.in -bin_PROGRAMS = g13 +bin_PROGRAMS = g13 AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common @@ -43,4 +43,3 @@ g13_SOURCES = \ g13_LDADD = $(libcommonpth) ../gl/libgnu.a \ $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \ $(GPG_ERROR_LIBS) $(LIBINTL) - diff --git a/g13/backend.c b/g13/backend.c index 531e745ed..7b08cd52a 100644 --- a/g13/backend.c +++ b/g13/backend.c @@ -42,7 +42,7 @@ no_such_backend (int conttype) /* Return true if CONTTYPE is supported by us. */ -int +int be_is_supported_conttype (int conttype) { switch (conttype) @@ -50,7 +50,7 @@ be_is_supported_conttype (int conttype) case CONTTYPE_ENCFS: return 1; - default: + default: return 0; } } @@ -72,7 +72,7 @@ be_get_detached_name (int conttype, const char *fname, *r_isdir = 0; switch (conttype) { - case CONTTYPE_ENCFS: + case CONTTYPE_ENCFS: return be_encfs_get_detached_name (fname, r_name, r_isdir); default: @@ -86,10 +86,10 @@ be_create_new_keys (int conttype, membuf_t *mb) { switch (conttype) { - case CONTTYPE_ENCFS: + case CONTTYPE_ENCFS: return be_encfs_create_new_keys (mb); - case CONTTYPE_TRUECRYPT: + case CONTTYPE_TRUECRYPT: return be_truecrypt_create_new_keys (mb); default: @@ -100,7 +100,7 @@ be_create_new_keys (int conttype, membuf_t *mb) /* Dispatcher to the backend's create function. */ gpg_error_t -be_create_container (ctrl_t ctrl, int conttype, +be_create_container (ctrl_t ctrl, int conttype, const char *fname, int fd, tupledesc_t tuples, unsigned int *r_id) { @@ -108,7 +108,7 @@ be_create_container (ctrl_t ctrl, int conttype, switch (conttype) { - case CONTTYPE_ENCFS: + case CONTTYPE_ENCFS: return be_encfs_create_container (ctrl, fname, tuples, r_id); default: @@ -119,13 +119,13 @@ be_create_container (ctrl_t ctrl, int conttype, /* Dispatcher to the backend's mount function. */ gpg_error_t -be_mount_container (ctrl_t ctrl, int conttype, +be_mount_container (ctrl_t ctrl, int conttype, const char *fname, const char *mountpoint, tupledesc_t tuples, unsigned int *r_id) { switch (conttype) { - case CONTTYPE_ENCFS: + case CONTTYPE_ENCFS: return be_encfs_mount_container (ctrl, fname, mountpoint, tuples, r_id); default: diff --git a/g13/backend.h b/g13/backend.h index 2048697dc..20d296606 100644 --- a/g13/backend.h +++ b/g13/backend.h @@ -24,19 +24,18 @@ #include "utils.h" /* For tupledesc_t */ int be_is_supported_conttype (int conttype); -gpg_error_t be_get_detached_name (int conttype, const char *fname, +gpg_error_t be_get_detached_name (int conttype, const char *fname, char **r_name, int *r_isdir); gpg_error_t be_create_new_keys (int conttype, membuf_t *mb); -gpg_error_t be_create_container (ctrl_t ctrl, int conttype, +gpg_error_t be_create_container (ctrl_t ctrl, int conttype, const char *fname, int fd, tupledesc_t tuples, unsigned int *r_id); -gpg_error_t be_mount_container (ctrl_t ctrl, int conttype, +gpg_error_t be_mount_container (ctrl_t ctrl, int conttype, const char *fname, const char *mountpoint, tupledesc_t tuples, unsigned int *r_id); #endif /*G13_BACKEND_H*/ - diff --git a/g13/be-encfs.c b/g13/be-encfs.c index dd8e53657..ae0ec1cf9 100644 --- a/g13/be-encfs.c +++ b/g13/be-encfs.c @@ -53,14 +53,14 @@ struct encfs_parm_s typedef struct encfs_parm_s *encfs_parm_t; -static gpg_error_t +static gpg_error_t send_cmd_bin (runner_t runner, const void *data, size_t datalen) { return runner_send_line (runner, data, datalen); } -static gpg_error_t +static gpg_error_t send_cmd (runner_t runner, const char *string) { log_debug ("sending command -->%s<--\n", string); @@ -75,7 +75,7 @@ run_umount_helper (const char *mountpoint) gpg_error_t err; const char pgmname[] = FUSERMOUNT; const char *args[3]; - + args[0] = "-u"; args[1] = mountpoint; args[2] = NULL; @@ -126,13 +126,13 @@ handle_status_line (runner_t runner, const char *line, { size_t n; const void *value; - + value = find_tuple (tuples, KEYBLOB_TAG_ENCKEY, &n); if (!value) err = gpg_error (GPG_ERR_INV_SESSION_KEY); else if ((err = send_cmd_bin (runner, value, n))) { - if (gpg_err_code (err) == GPG_ERR_BUG + if (gpg_err_code (err) == GPG_ERR_BUG && gpg_err_source (err) == GPG_ERR_SOURCE_DEFAULT) err = gpg_error (GPG_ERR_INV_SESSION_KEY); } @@ -337,7 +337,7 @@ be_encfs_get_detached_name (const char *fname, char **r_name, int *r_isdir) /* Create a new session key and append it as a tuple to the memory - buffer MB. + buffer MB. The EncFS daemon takes a passphrase from stdin and internally mangles it by means of some KDF from OpenSSL. We want to store a @@ -365,7 +365,7 @@ be_encfs_create_new_keys (membuf_t *mb) good compromise between security and performance. The anticipated usage of this tool is the quite often creation of new containers and thus this should not deplete the system's entropy - tool too much. */ + tool too much. */ gcry_randomize (buffer, 32+8, GCRY_STRONG_RANDOM); for (i=j=0; i < 32; i++) { @@ -425,7 +425,7 @@ be_encfs_create_container (ctrl_t ctrl, const char *fname, tupledesc_t tuples, err = run_encfs_tool (ctrl, ENCFS_CMD_CREATE, containername, mountpoint, tuples, r_id); - + /* In any case remove the temporary mount point. */ if (rmdir (mountpoint)) log_error ("error removing temporary mount point `%s': %s\n", @@ -442,7 +442,7 @@ be_encfs_create_container (ctrl_t ctrl, const char *fname, tupledesc_t tuples, /* Mount the container described by the filename FNAME and the keyblob information in TUPLES. On success the runner id is stored at R_ID. */ gpg_error_t -be_encfs_mount_container (ctrl_t ctrl, +be_encfs_mount_container (ctrl_t ctrl, const char *fname, const char *mountpoint, tupledesc_t tuples, unsigned int *r_id) { @@ -463,7 +463,7 @@ be_encfs_mount_container (ctrl_t ctrl, err = run_encfs_tool (ctrl, ENCFS_CMD_MOUNT, containername, mountpoint, tuples, r_id); - + leave: xfree (containername); return err; diff --git a/g13/be-encfs.h b/g13/be-encfs.h index 8ac35f947..744c16aee 100644 --- a/g13/be-encfs.h +++ b/g13/be-encfs.h @@ -26,17 +26,16 @@ gpg_error_t be_encfs_get_detached_name (const char *fname, char **r_name, int *r_isdir); gpg_error_t be_encfs_create_new_keys (membuf_t *mb); -gpg_error_t be_encfs_create_container (ctrl_t ctrl, +gpg_error_t be_encfs_create_container (ctrl_t ctrl, const char *fname, tupledesc_t tuples, unsigned int *r_id); gpg_error_t be_encfs_mount_container (ctrl_t ctrl, - const char *fname, + const char *fname, const char *mountpoint, tupledesc_t tuples, unsigned int *r_id); #endif /*G13_BE_ENCFS_H*/ - diff --git a/g13/be-truecrypt.c b/g13/be-truecrypt.c index 6f51321f4..9d75bdfda 100644 --- a/g13/be-truecrypt.c +++ b/g13/be-truecrypt.c @@ -35,5 +35,3 @@ be_truecrypt_create_new_keys (membuf_t *mb) (void)mb; return gpg_error (GPG_ERR_NOT_IMPLEMENTED); } - - diff --git a/g13/be-truecrypt.h b/g13/be-truecrypt.h index ef2c5675b..e98c989e9 100644 --- a/g13/be-truecrypt.h +++ b/g13/be-truecrypt.h @@ -26,4 +26,3 @@ gpg_error_t be_truecrypt_create_new_keys (membuf_t *mb); #endif /*G13_BE_TRUECRYPT_H*/ - diff --git a/g13/call-gpg.c b/g13/call-gpg.c index 5db284f03..c2b1e0c41 100644 --- a/g13/call-gpg.c +++ b/g13/call-gpg.c @@ -65,7 +65,7 @@ start_gpg (ctrl_t ctrl, int input_fd, int output_fd, assuan_context_t *r_ctx) if (opt.verbose) log_info (_("no running gpg - starting `%s'\n"), opt.gpg_program); - + /* Compute argv[0]. */ if ( !(pgmname = strrchr (opt.gpg_program, '/'))) pgmname = opt.gpg_program; @@ -89,7 +89,7 @@ start_gpg (ctrl_t ctrl, int input_fd, int output_fd, assuan_context_t *r_ctx) argv[i++] = "--trust-model"; argv[i++] = "always"; argv[i++] = NULL; - + i = 0; if (log_get_fd () != -1) no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ()); @@ -135,7 +135,7 @@ start_gpg (ctrl_t ctrl, int input_fd, int output_fd, assuan_context_t *r_ctx) } *r_ctx = ctx; - + if (DBG_ASSUAN) log_debug ("connection to GPG established\n"); return 0; @@ -151,7 +151,7 @@ release_gpg (assuan_context_t ctx) -/* The data passed to the writer_thread. */ +/* The data passed to the writer_thread. */ struct writer_thread_parms { int fd; @@ -198,7 +198,7 @@ writer_thread (void *arg) variable to receive a possible write error after the thread has finished. */ static gpg_error_t -start_writer (int fd, const void *data, size_t datalen, +start_writer (int fd, const void *data, size_t datalen, pth_t *r_tid, gpg_error_t *err_addr) { gpg_error_t err; @@ -240,7 +240,7 @@ start_writer (int fd, const void *data, size_t datalen, -/* The data passed to the reader_thread. */ +/* The data passed to the reader_thread. */ struct reader_thread_parms { int fd; @@ -266,7 +266,7 @@ reader_thread (void *arg) *parm->err_addr = gpg_error_from_syserror (); break; /* Read error. */ } - + put_membuf (parm->mb, buffer, nread); } @@ -323,7 +323,7 @@ start_reader (int fd, membuf_t *mb, pth_t *r_tid, gpg_error_t *err_addr) -/* Call GPG to encrypt a block of data. +/* Call GPG to encrypt a block of data. */ @@ -364,9 +364,9 @@ gpg_encrypt_blob (ctrl_t ctrl, const void *plain, size_t plainlen, goto leave; close (outbound_fds[0]); outbound_fds[0] = -1; close (inbound_fds[1]); inbound_fds[1] = -1; - + /* Start a writer thread to feed the INPUT command of the server. */ - err = start_writer (outbound_fds[1], plain, plainlen, + err = start_writer (outbound_fds[1], plain, plainlen, &writer_tid, &writer_err); if (err) return err; @@ -374,7 +374,7 @@ gpg_encrypt_blob (ctrl_t ctrl, const void *plain, size_t plainlen, /* Start a reader thread to eat from the OUTPUT command of the server. */ - err = start_reader (inbound_fds[0], &reader_mb, + err = start_reader (inbound_fds[0], &reader_mb, &reader_tid, &reader_err); if (err) return err; @@ -467,7 +467,7 @@ gpg_encrypt_blob (ctrl_t ctrl, const void *plain, size_t plainlen, -/* Call GPG to decrypt a block of data. +/* Call GPG to decrypt a block of data. */ @@ -506,9 +506,9 @@ gpg_decrypt_blob (ctrl_t ctrl, const void *ciph, size_t ciphlen, goto leave; close (outbound_fds[0]); outbound_fds[0] = -1; close (inbound_fds[1]); inbound_fds[1] = -1; - + /* Start a writer thread to feed the INPUT command of the server. */ - err = start_writer (outbound_fds[1], ciph, ciphlen, + err = start_writer (outbound_fds[1], ciph, ciphlen, &writer_tid, &writer_err); if (err) return err; @@ -516,7 +516,7 @@ gpg_decrypt_blob (ctrl_t ctrl, const void *ciph, size_t ciphlen, /* Start a reader thread to eat from the OUTPUT command of the server. */ - err = start_reader (inbound_fds[0], &reader_mb, + err = start_reader (inbound_fds[0], &reader_mb, &reader_tid, &reader_err); if (err) return err; @@ -594,5 +594,3 @@ gpg_decrypt_blob (ctrl_t ctrl, const void *ciph, size_t ciphlen, xfree (get_membuf (&reader_mb, NULL)); return err; } - - diff --git a/g13/create.c b/g13/create.c index bde67579e..2b998e2b2 100644 --- a/g13/create.c +++ b/g13/create.c @@ -40,7 +40,7 @@ information which are to be stored encrypted in the crypto container header. On success the malloced blob is stored at R_BLOB and its length at R_BLOBLEN. On error an error code is returned - and (R_BLOB,R_BLOBLEN) are set to (NULL,0). + and (R_BLOB,R_BLOBLEN) are set to (NULL,0). The format of this blob is a sequence of tag-length-value tuples. All tuples have this format: @@ -123,7 +123,7 @@ encrypt_keyblob (ctrl_t ctrl, void *keyblob, size_t keybloblen, appropriate header. This fucntion is called with a lock file in place and after checking that the filename does not exists. */ static gpg_error_t -write_keyblob (const char *filename, +write_keyblob (const char *filename, const void *keyblob, size_t keybloblen) { gpg_error_t err; @@ -135,7 +135,7 @@ write_keyblob (const char *filename, if (!fp) { err = gpg_error_from_syserror (); - log_error ("error creating new container `%s': %s\n", + log_error ("error creating new container `%s': %s\n", filename, gpg_strerror (err)); return err; } @@ -197,18 +197,18 @@ write_keyblob (const char *filename, if (es_fclose (fp)) { err = gpg_error_from_syserror (); - log_error ("error closing `%s': %s\n", + log_error ("error closing `%s': %s\n", filename, gpg_strerror (err)); remove (filename); return err; } return 0; - + writeerr: err = gpg_error_from_syserror (); - log_error ("error writing header to `%s': %s\n", + log_error ("error writing header to `%s': %s\n", filename, gpg_strerror (err)); es_fclose (fp); remove (filename); @@ -301,7 +301,7 @@ g13_create_container (ctrl_t ctrl, const char *filename, strlist_t keys) keyblob = NULL; /* if (opt.verbose) */ /* dump_keyblob (tuples); */ - + /* Write out the header, the encrypted keyblob and some padding. */ err = write_keyblob (filename, enckeyblob, enckeybloblen); if (err) @@ -148,10 +148,10 @@ static ARGPARSE_OPTS opts[] = { /* Hidden options. */ ARGPARSE_s_n (oNoVerbose, "no-verbose", "@"), - ARGPARSE_s_n (oNoSecmemWarn, "no-secmem-warning", "@"), + ARGPARSE_s_n (oNoSecmemWarn, "no-secmem-warning", "@"), ARGPARSE_s_n (oNoGreeting, "no-greeting", "@"), ARGPARSE_s_n (oNoOptions, "no-options", "@"), - ARGPARSE_s_s (oHomedir, "homedir", "@"), + ARGPARSE_s_s (oHomedir, "homedir", "@"), ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), ARGPARSE_s_s (oGpgProgram, "gpg-program", "@"), ARGPARSE_s_s (oDisplay, "display", "@"), @@ -235,7 +235,7 @@ my_strusage( int level ) case 31: p = "\nHome: "; break; case 32: p = opt.homedir; break; - + default: p = NULL; break; } return p; @@ -297,13 +297,13 @@ set_debug (void) if (opt.debug) log_info ("enabled debug flags:%s%s%s%s%s\n", - (opt.debug & DBG_MOUNT_VALUE )? " mount":"", - (opt.debug & DBG_CRYPTO_VALUE )? " crypto":"", - (opt.debug & DBG_MEMORY_VALUE )? " memory":"", - (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"", + (opt.debug & DBG_MOUNT_VALUE )? " mount":"", + (opt.debug & DBG_CRYPTO_VALUE )? " crypto":"", + (opt.debug & DBG_MEMORY_VALUE )? " memory":"", + (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"", (opt.debug & DBG_ASSUAN_VALUE )? " assuan":""); } - + static void @@ -313,7 +313,7 @@ set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd) if (!cmd || cmd == new_cmd) cmd = new_cmd; - else + else { log_error (_("conflicting commands\n")); g13_exit (2); @@ -373,16 +373,16 @@ main ( int argc, char **argv) /* Check that the Libgcrypt is suitable. */ if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) ) - log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt", + log_fatal (_("%s is too old (need %s, have %s)\n"), "libgcrypt", NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) ); /* Take extra care of the random pool. */ gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); may_coredump = disable_core_dumps (); - + gnupg_init_signals (0, emergency_cleanup); - + create_dotlock (NULL); /* Register locking cleanup. */ opt.session_env = session_env_new (); @@ -418,8 +418,8 @@ main ( int argc, char **argv) gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); maybe_setuid = 0; - /* - Now we are now working under our real uid + /* + Now we are now working under our real uid */ /* Setup malloc hooks. */ @@ -431,7 +431,7 @@ main ( int argc, char **argv) malloc_hooks.free = gcry_free; assuan_set_malloc_hooks (&malloc_hooks); } - + /* Prepare libassuan. */ assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); assuan_set_system_hooks (ASSUAN_SYSTEM_PTH); @@ -446,7 +446,7 @@ main ( int argc, char **argv) /* Set the default option file */ if (default_config ) configname = make_filename (opt.homedir, "g13.conf", NULL); - + argc = orig_argc; argv = orig_argv; pargs.argc = &argc; @@ -465,9 +465,9 @@ main ( int argc, char **argv) if (parse_debug) log_info (_("NOTE: no default option file `%s'\n"), configname); } - else + else { - log_error (_("option file `%s': %s\n"), + log_error (_("option file `%s': %s\n"), configname, strerror(errno)); g13_exit(2); } @@ -478,14 +478,14 @@ main ( int argc, char **argv) log_info (_("reading options from `%s'\n"), configname); default_config = 0; } - - while (!no_more_options + + while (!no_more_options && optfile_parse (configfp, configname, &configlineno, &pargs, opts)) { switch (pargs.r_opt) { - case aGPGConfList: - case aGPGConfTest: + case aGPGConfList: + case aGPGConfTest: set_cmd (&cmd, pargs.r_opt); nogreeting = 1; nokeysetup = 1; @@ -517,7 +517,7 @@ main ( int argc, char **argv) break; case oLogFile: logfile = pargs.r.ret_str; break; - case oNoLogFile: logfile = NULL; break; + case oNoLogFile: logfile = NULL; break; case oNoDetach: nodetach = 1; break; @@ -554,10 +554,10 @@ main ( int argc, char **argv) case oLCctype: opt.lc_ctype = xstrdup (pargs.r.ret_str); break; case oLCmessages: opt.lc_messages = xstrdup (pargs.r.ret_str); break; case oXauthority: opt.xauthority = xstrdup (pargs.r.ret_str); break; - + case oFakedSystemTime: { - time_t faked_time = isotime2epoch (pargs.r.ret_str); + time_t faked_time = isotime2epoch (pargs.r.ret_str); if (faked_time == (time_t)(-1)) faked_time = (time_t)strtoul (pargs.r.ret_str, NULL, 10); gnupg_set_time (faked_time, 0); @@ -573,8 +573,8 @@ main ( int argc, char **argv) break; - default: - pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; + default: + pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; break; } } @@ -603,7 +603,7 @@ main ( int argc, char **argv) if (nogreeting) greeting = 0; - + if (greeting) { fprintf (stderr, "%s %s; %s\n", @@ -647,38 +647,38 @@ main ( int argc, char **argv) /* Terminate if we found any error until now. */ if (log_get_errorcount(0)) g13_exit (2); - + /* Set the standard GnuPG random seed file. */ - if (use_random_seed) + if (use_random_seed) { char *p = make_filename (opt.homedir, "random_seed", NULL); gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p); xfree(p); } - + /* Store given filename into FNAME. */ fname = argc? *argv : NULL; /* Parse all given encryption keys. This does a lookup of the keys and stops if any of the given keys was not found. */ -#if 0 /* Currently not implemented. */ +#if 0 /* Currently not implemented. */ if (!nokeysetup) { strlist_t sl; int failed = 0; - + for (sl = recipients; sl; sl = sl->next) if (check_encryption_key ()) failed = 1; if (failed) g13_exit (1); } -#endif /*0*/ - +#endif /*0*/ + /* Dispatch command. */ switch (cmd) { - case aGPGConfList: + case aGPGConfList: { /* List options and default values in the GPG Conf format. */ char *config_filename_esc = percent_escape (opt.config_filename, NULL); @@ -712,7 +712,7 @@ main ( int argc, char **argv) case aCreate: /* Create a new container. */ { - if (argc != 1) + if (argc != 1) wrong_args ("--create filename"); start_idle_task (); err = g13_create_container (&ctrl, argv[0], recipients); @@ -726,7 +726,7 @@ main ( int argc, char **argv) case aMount: /* Mount a container. */ { - if (argc != 1 && argc != 2 ) + if (argc != 1 && argc != 2 ) wrong_args ("--mount filename [mountpoint]"); start_idle_task (); err = g13_mount_container (&ctrl, argv[0], argc == 2?argv[1]:NULL); @@ -796,7 +796,7 @@ handle_signal (int signo) log_info ("SIGHUP received - re-reading configuration\n"); /* Fixme: Not yet implemented. */ break; - + case SIGUSR1: log_info ("SIGUSR1 received - printing internal information:\n"); /* Fixme: We need to see how to integrate pth dumping into our @@ -823,14 +823,14 @@ handle_signal (int signo) g13_exit (0); } break; - + case SIGINT: log_info ("SIGINT received - immediate shutdown\n"); log_info( "%s %s stopped\n", strusage(11), strusage(13)); g13_exit (0); break; #endif /*!HAVE_W32_SYSTEM*/ - + default: log_info ("signal %d received - no action defined\n", signo); } @@ -932,16 +932,16 @@ start_idle_task (void) { pth_attr_t tattr; pth_t tid; - + tattr = pth_attr_new (); pth_attr_set (tattr, PTH_ATTR_JOINABLE, 1); pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 64*1024); pth_attr_set (tattr, PTH_ATTR_NAME, "idle-task"); - + tid = pth_spawn (tattr, idle_task, NULL); if (!tid) { - log_fatal ("error starting idle task: %s\n", + log_fatal ("error starting idle task: %s\n", gpg_strerror (gpg_error_from_syserror ())); return; /*NOTREACHED*/ } @@ -961,4 +961,3 @@ join_idle_task (void) gpg_strerror (gpg_error_from_syserror ())); } } - @@ -32,7 +32,7 @@ #include "../common/session-env.h" /* A large struct named "opt" to keep global flags. */ -struct +struct { unsigned int debug; /* Debug flags (DBG_foo_VALUE). */ int verbose; /* Verbosity level. */ @@ -43,12 +43,12 @@ struct const char *config_filename; /* Name of the used config file. */ /* Filename of the AGENT program. */ - const char *agent_program; + const char *agent_program; /* Filename of the GPG program. Unless set via an program option it is initialzed at the first engine startup to the standard gpg filename. */ - const char *gpg_program; + const char *gpg_program; /* Environment variables passed along to the engine. */ char *display; @@ -89,10 +89,10 @@ struct server_control_s int no_server; /* We are not running under server control */ int status_fd; /* Only for non-server mode */ struct server_local_s *server_local; - + int agent_seen; /* Flag indicating that the gpg-agent has been accessed. */ - + int with_colons; /* Use column delimited output format */ /* Type of the current container. See the CONTTYPE_ constants. */ diff --git a/g13/keyblob.h b/g13/keyblob.h index a7701005d..99d239fee 100644 --- a/g13/keyblob.h +++ b/g13/keyblob.h @@ -33,8 +33,8 @@ u32 Length of the entire header. This includes all bytes starting at the packet type and ending with the last padding byte of the header. - u8 Number of copies of this header (1..255). - u8 Number of copies of this header at the end of the + u8 Number of copies of this header (1..255). + u8 Number of copies of this header at the end of the container (usually 0). b6 reserved n bytes: OpenPGP encrypted and optionally signed message. @@ -55,7 +55,7 @@ b10 Value: "GnuPG/PAD\x00". b(n) Padding stuff. Given this structure the minimum padding is 16 bytes. - + n bytes: File system container. (optionally followed by copies on the header). */ diff --git a/g13/mount.c b/g13/mount.c index 2ab5cc636..387bb6f32 100644 --- a/g13/mount.c +++ b/g13/mount.c @@ -41,7 +41,7 @@ /* Parse the header prefix and return the length of the entire header. */ static gpg_error_t -parse_header (const char *filename, +parse_header (const char *filename, const unsigned char *packet, size_t packetlen, size_t *r_headerlen) { @@ -65,7 +65,7 @@ parse_header (const char *filename, return gpg_error (GPG_ERR_INV_OBJ); } if (packet[17] || packet[18] - || packet[26] || packet[27] || packet[28] || packet[29] + || packet[26] || packet[27] || packet[28] || packet[29] || packet[30] || packet[31]) log_info ("WARNING: unknown meta information in `%s'\n", filename); if (packet[19]) @@ -85,7 +85,7 @@ parse_header (const char *filename, log_error ("bad length given in container `%s'\n", filename); return gpg_error (GPG_ERR_INV_OBJ); } - + *r_headerlen = len; return 0; } @@ -100,7 +100,7 @@ read_keyblob_prefix (const char *filename, estream_t *r_fp, size_t *r_headerlen) gpg_error_t err; estream_t fp; unsigned char packet[32]; - + *r_fp = NULL; fp = es_fopen (filename, "rb"); @@ -110,7 +110,7 @@ read_keyblob_prefix (const char *filename, estream_t *r_fp, size_t *r_headerlen) log_error ("error reading `%s': %s\n", filename, gpg_strerror (err)); return err; } - + /* Read the header. It is defined as 32 bytes thus we read it in one go. */ if (es_fread (packet, 32, 1, fp) != 1) { @@ -120,7 +120,7 @@ read_keyblob_prefix (const char *filename, estream_t *r_fp, size_t *r_headerlen) es_fclose (fp); return err; } - + err = parse_header (filename, packet, 32, r_headerlen); if (err) es_fclose (fp); @@ -134,21 +134,21 @@ read_keyblob_prefix (const char *filename, estream_t *r_fp, size_t *r_headerlen) /* Read the keyblob at FILENAME. The caller should have acquired a lockfile and checked that the file exists. */ static gpg_error_t -read_keyblob (const char *filename, +read_keyblob (const char *filename, void **r_enckeyblob, size_t *r_enckeybloblen) { gpg_error_t err; estream_t fp = NULL; size_t headerlen, msglen; void *msg = NULL; - + *r_enckeyblob = NULL; *r_enckeybloblen = 0; err = read_keyblob_prefix (filename, &fp, &headerlen); if (err) goto leave; - + if (opt.verbose) log_info ("header length of `%s' is %zu\n", filename, headerlen); @@ -291,7 +291,7 @@ g13_mount_container (ctrl_t ctrl, const char *filename, const char *mountpoint) /* Check again that the file exists. */ { struct stat sb; - + if (stat (filename, &sb)) { err = gpg_error_from_syserror (); @@ -381,7 +381,7 @@ g13_umount_container (ctrl_t ctrl, const char *filename, const char *mountpoint) err = mountinfo_find_mount (filename, mountpoint, &rid); if (err) return err; - + runner = runner_find_by_rid (rid); if (!runner) { @@ -391,7 +391,7 @@ g13_umount_container (ctrl_t ctrl, const char *filename, const char *mountpoint) runner_cancel (runner); runner_release (runner); - + return 0; } @@ -414,5 +414,3 @@ g13_is_container (ctrl_t ctrl, const char *filename) es_fclose (fp); return err; } - - diff --git a/g13/mount.h b/g13/mount.h index f99426494..b2fe99e59 100644 --- a/g13/mount.h +++ b/g13/mount.h @@ -20,7 +20,7 @@ #ifndef G13_MOUNT_H #define G13_MOUNT_H -gpg_error_t g13_mount_container (ctrl_t ctrl, +gpg_error_t g13_mount_container (ctrl_t ctrl, const char *filename, const char *mountpoint); gpg_error_t g13_umount_container (ctrl_t ctrl, @@ -31,4 +31,3 @@ gpg_error_t g13_is_container (ctrl_t ctrl, const char *filename); #endif /*G13_MOUNT_H*/ - diff --git a/g13/mountinfo.c b/g13/mountinfo.c index 07c6240d4..90b205ed5 100644 --- a/g13/mountinfo.c +++ b/g13/mountinfo.c @@ -134,10 +134,10 @@ mountinfo_del_mount (const char *container, const char *mountpoint, { /* FIXME: This does not always work because the umount may not have completed yet. We should add the mountpoints - to an idle queue and retry a remove. */ + to an idle queue and retry a remove. */ if (rmdir (m->mountpoint)) log_error ("error removing mount point `%s': %s\n", - m->mountpoint, + m->mountpoint, gpg_strerror (gpg_error_from_syserror ())); } m->in_use = 0; @@ -192,8 +192,7 @@ mountinfo_dump_all (void) for (idx=0, m = mounttable; idx < mounttable_size; idx++, m++) if (m->in_use) - log_info ("mtab[%d] %s on %s type %d rid %u%s\n", + log_info ("mtab[%d] %s on %s type %d rid %u%s\n", idx, m->container, m->mountpoint, m->conttype, m->rid, m->flags.remove?" [remove]":""); } - diff --git a/g13/mountinfo.h b/g13/mountinfo.h index b8ac5bd7b..95e95f51c 100644 --- a/g13/mountinfo.h +++ b/g13/mountinfo.h @@ -38,4 +38,3 @@ void mountinfo_dump_all (void); #endif /*G13_MOUNTINFO_H*/ - diff --git a/g13/runner.c b/g13/runner.c index 720cd9e58..7e9c262c3 100644 --- a/g13/runner.c +++ b/g13/runner.c @@ -53,7 +53,7 @@ struct runner_s 1 = Thread not running or only the thread is still running. 2 = Thread is running and someone is holding a reference. */ - int refcount; + int refcount; pid_t pid; /* PID of the backend's process (the engine). */ int in_fd; /* File descriptors to read from the engine. */ @@ -82,7 +82,7 @@ writen (int fd, const void *buf, size_t nbytes) { size_t nleft = nbytes; int nwritten; - + while (nleft > 0) { nwritten = pth_write (fd, buf, nleft); @@ -96,7 +96,7 @@ writen (int fd, const void *buf, size_t nbytes) nleft -= nwritten; buf = (const char*)buf + nwritten; } - + return 0; } @@ -150,7 +150,7 @@ runner_release (runner_t runner) close (runner->in_fd); if (runner->out_fd != -1) close (runner->out_fd); - + /* Fixme: close the process. */ /* Tell the engine to release its data. */ @@ -177,7 +177,7 @@ runner_release (runner_t runner) /* Create a new runner context. On success a new runner object is stored at R_RUNNER. On failure NULL is stored at this address and an error code returned. */ -gpg_error_t +gpg_error_t runner_new (runner_t *r_runner, const char *name) { static unsigned int namecounter; /* Global name counter. */ @@ -215,14 +215,14 @@ runner_new (runner_t *r_runner, const char *name) runner->pid = (pid_t)(-1); runner->in_fd = -1; runner->out_fd = -1; - + *r_runner = runner; return 0; } /* Return the identifier of RUNNER. */ -unsigned int +unsigned int runner_get_rid (runner_t runner) { return runner->identifier; @@ -282,8 +282,8 @@ runner_set_pid (runner_t runner, pid_t pid) and its private HANDLER_DATA with RUNNER. */ void runner_set_handler (runner_t runner, - engine_handler_fnc_t handler, - engine_handler_cleanup_fnc_t handler_cleanup, + engine_handler_fnc_t handler, + engine_handler_cleanup_fnc_t handler_cleanup, void *handler_data) { if (check_already_spawned (runner, "runner_set_handler")) @@ -325,14 +325,14 @@ runner_thread (void *arg) { buffer[pos - (c == '\n')] = 0; if (opt.verbose) - log_info ("%s%s: %s\n", + log_info ("%s%s: %s\n", runner->name, cont_line? "(cont)":"", buffer); /* We handle only complete lines and ignore any stuff we possibly had to truncate. That is - at least for the encfs engine - not an issue because our changes to the tool make sure that only relatively short prompt lines are of interest. */ - if (!cont_line && runner->handler) + if (!cont_line && runner->handler) err = runner->handler (runner->handler_data, runner, buffer); pos = 0; @@ -349,7 +349,7 @@ runner_thread (void *arg) if (opt.verbose) log_info ("%s%s: %s\n", runner->name, cont_line? "(cont)":"", buffer); - if (!cont_line && !err && runner->handler) + if (!cont_line && !err && runner->handler) err = runner->handler (runner->handler_data, runner, buffer); } @@ -384,7 +384,7 @@ runner_thread (void *arg) log_debug ("runner thread releasing runner ...\n"); { runner_t r, rprev; - + for (r = running_threads, rprev = NULL; r; rprev = r, r = r->next_running) if (r == runner) { @@ -398,7 +398,7 @@ runner_thread (void *arg) } runner_release (runner); log_debug ("runner thread runner released\n"); - + return NULL; } @@ -410,7 +410,7 @@ runner_spawn (runner_t runner) gpg_error_t err; pth_attr_t tattr; pth_t tid; - + if (check_already_spawned (runner, "runner_spawn")) return gpg_error (GPG_ERR_BUG); @@ -421,7 +421,7 @@ runner_spawn (runner_t runner) if (runner->in_fd != -1) { estream_t fp; - + fp = es_fdopen (runner->in_fd, "r"); if (!fp) { @@ -437,7 +437,7 @@ runner_spawn (runner_t runner) pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 128*1024); pth_attr_set (tattr, PTH_ATTR_NAME, runner->name); - + tid = pth_spawn (tattr, runner_thread, runner); if (!tid) { @@ -483,7 +483,7 @@ runner_cancel_all (void) { runner_t r; - do + do { for (r = running_threads; r; r = r->next_running) if (r->spawned && !r->canceled) @@ -499,7 +499,7 @@ runner_cancel_all (void) /* Send a line of data down to the engine. This line may not contain a binary Nul or a LF character. This function is used by the engine's handler. */ -gpg_error_t +gpg_error_t runner_send_line (runner_t runner, const void *data, size_t datalen) { gpg_error_t err = 0; @@ -533,6 +533,6 @@ runner_send_line (runner_t runner, const void *data, size_t datalen) if (!err) if (writen (runner->out_fd, "\n", 1)) err = gpg_error_from_syserror (); - + return err; } diff --git a/g13/runner.h b/g13/runner.h index e68eca03a..3c8214304 100644 --- a/g13/runner.h +++ b/g13/runner.h @@ -25,7 +25,7 @@ struct runner_s; typedef struct runner_s *runner_t; /* Prototypes for the handler functions provided by the engine. */ -typedef gpg_error_t (*engine_handler_fnc_t) (void *opaque, +typedef gpg_error_t (*engine_handler_fnc_t) (void *opaque, runner_t runner, const char *statusline); typedef void (*engine_handler_cleanup_fnc_t) (void *opaque); @@ -41,7 +41,7 @@ gpg_error_t runner_new (runner_t *r_runner, const char *name); void runner_release (runner_t runner); /* Return the identifier of RUNNER. */ -unsigned int runner_get_rid (runner_t runner); +unsigned int runner_get_rid (runner_t runner); /* Find a runner by its rid. */ runner_t runner_find_by_rid (unsigned int rid); @@ -53,8 +53,8 @@ void runner_set_pid (runner_t runner, pid_t pid); /* Register the handler functions with a runner. */ void runner_set_handler (runner_t runner, - engine_handler_fnc_t handler, - engine_handler_cleanup_fnc_t handler_cleanup, + engine_handler_fnc_t handler, + engine_handler_cleanup_fnc_t handler_cleanup, void *handler_data); /* Start the runner. */ @@ -74,4 +74,3 @@ gpg_error_t runner_send_line (runner_t runner, #endif /*G13_RUNNER_H*/ - diff --git a/g13/server.c b/g13/server.c index 0c2b880f4..31c961dfb 100644 --- a/g13/server.c +++ b/g13/server.c @@ -39,7 +39,7 @@ static FILE *statusfp; /* Local data for this server module. A pointer to this is stored in the CTRL object of each connection. */ -struct server_local_s +struct server_local_s { /* The Assuan contect we are working on. */ assuan_context_t assuan_ctx; @@ -59,7 +59,7 @@ static int command_has_option (const char *cmd, const char *cmdopt); /* - Helper functions. + Helper functions. */ /* Set an error and a description. */ @@ -202,7 +202,7 @@ reset_notify (assuan_context_t ctx, char *line) } -static const char hlp_open[] = +static const char hlp_open[] = "OPEN [<options>] <filename>\n" "\n" "Open the container FILENAME. FILENAME must be percent-plus\n" @@ -255,14 +255,14 @@ cmd_open (assuan_context_t ctx, char *line) ctrl->server_local->containername = xtrystrdup (line); if (!ctrl->server_local->containername) err = gpg_error_from_syserror (); - - + + leave: return leave_cmd (ctx, err); } -static const char hlp_mount[] = +static const char hlp_mount[] = "MOUNT [options] [<mountpoint>]\n" "\n" "Mount the currently open file onto MOUNTPOINT. If MOUNTPOINT is not\n" @@ -305,7 +305,7 @@ cmd_mount (assuan_context_t ctx, char *line) } /* Perform the mount. */ - err = g13_mount_container (ctrl, ctrl->server_local->containername, + err = g13_mount_container (ctrl, ctrl->server_local->containername, *line? line : NULL); leave: @@ -313,7 +313,7 @@ cmd_mount (assuan_context_t ctx, char *line) } -static const char hlp_umount[] = +static const char hlp_umount[] = "UMOUNT [options] [<mountpoint>]\n" "\n" "Unmount the currently open file or the one opened at MOUNTPOINT.\n" @@ -350,7 +350,7 @@ cmd_umount (assuan_context_t ctx, char *line) } /* Perform the unmount. */ - err = g13_umount_container (ctrl, ctrl->server_local->containername, + err = g13_umount_container (ctrl, ctrl->server_local->containername, *line? line : NULL); leave: @@ -358,7 +358,7 @@ cmd_umount (assuan_context_t ctx, char *line) } -static const char hlp_recipient[] = +static const char hlp_recipient[] = "RECIPIENT <userID>\n" "\n" "Add USERID to the list of recipients to be used for the next CREATE\n" @@ -443,7 +443,7 @@ cmd_create (assuan_context_t ctx, char *line) if (!err) { FREE_STRLIST (ctrl->server_local->recipients); - + /* Store the filename. */ ctrl->server_local->containername = xtrystrdup (line); if (!ctrl->server_local->containername) @@ -455,7 +455,7 @@ cmd_create (assuan_context_t ctx, char *line) } -static const char hlp_getinfo[] = +static const char hlp_getinfo[] = "GETINFO <what>\n" "\n" "Multipurpose function to return a variety of information.\n" @@ -528,7 +528,7 @@ command_has_option (const char *cmd, const char *cmdopt) { (void)cmd; (void)cmdopt; - + return 0; } @@ -548,8 +548,8 @@ register_commands (assuan_context_t ctx) { "RECIPIENT", cmd_recipient, hlp_recipient }, { "SIGNER", cmd_signer, hlp_signer }, { "CREATE", cmd_create, hlp_create }, - { "INPUT", NULL }, - { "OUTPUT", NULL }, + { "INPUT", NULL }, + { "OUTPUT", NULL }, { "GETINFO", cmd_getinfo,hlp_getinfo }, { NULL } }; @@ -562,7 +562,7 @@ register_commands (assuan_context_t ctx) table[i].help); if (err) return err; - } + } return 0; } @@ -652,7 +652,7 @@ g13_server (ctrl_t ctrl) err = 0; else log_info ("Assuan accept problem: %s\n", gpg_strerror (err)); - + leave: reset_notify (ctx, NULL); /* Release all items hold by SERVER_LOCAL. */ if (ctrl->server_local) @@ -689,17 +689,17 @@ g13_status (ctrl_t ctrl, int no, ...) statusfp = stderr; else statusfp = fdopen (ctrl->status_fd, "w"); - + if (!statusfp) { log_fatal ("can't open fd %d for status output: %s\n", ctrl->status_fd, strerror(errno)); } } - + fputs ("[GNUPG:] ", statusfp); fputs (get_status_string (no), statusfp); - + while ( (text = va_arg (arg_ptr, const char*) )) { putc ( ' ', statusfp ); @@ -752,5 +752,3 @@ g13_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line) return 0; return assuan_inquire (ctrl->server_local->assuan_ctx, line, NULL, NULL, 0); } - - diff --git a/g13/server.h b/g13/server.h index 9b6eb98d5..af8494a67 100644 --- a/g13/server.h +++ b/g13/server.h @@ -26,4 +26,3 @@ gpg_error_t g13_server (ctrl_t ctrl); gpg_error_t g13_proxy_pinentry_notify (ctrl_t ctrl, const unsigned char *line); #endif /*G13_SERVER_H*/ - diff --git a/g13/utils.c b/g13/utils.c index 4b374df10..6fe3e5ac1 100644 --- a/g13/utils.c +++ b/g13/utils.c @@ -88,7 +88,7 @@ destroy_tupledesc (tupledesc_t tupledesc) { if (!tupledesc) return; - + if (!--tupledesc->refcount) { xfree (tupledesc->data); @@ -174,7 +174,6 @@ next_tuple (tupledesc_t tupledesc, unsigned int *r_tag, size_t *r_length) return s; } } - + return NULL; } - diff --git a/g13/utils.h b/g13/utils.h index cebd0436d..914b2cf3e 100644 --- a/g13/utils.h +++ b/g13/utils.h @@ -30,15 +30,14 @@ void append_tuple (membuf_t *membuf, struct tupledesc_s; typedef struct tupledesc_s *tupledesc_t; -gpg_error_t create_tupledesc (tupledesc_t *r_tupledesc, +gpg_error_t create_tupledesc (tupledesc_t *r_tupledesc, void *data, size_t datalen); void destroy_tupledesc (tupledesc_t tupledesc); tupledesc_t ref_tupledesc (tupledesc_t tupledesc); -const void *find_tuple (tupledesc_t tupledesc, +const void *find_tuple (tupledesc_t tupledesc, unsigned int tag, size_t *r_length); -const void *next_tuple (tupledesc_t tupledesc, +const void *next_tuple (tupledesc_t tupledesc, unsigned int *r_tag, size_t *r_length); #endif /*G13_UTILS_H*/ - |