Imported Upstream version 2.1.23
[platform/upstream/gpg2.git] / doc / tools.texi
1 @c Copyright (C) 2004, 2008 Free Software Foundation, Inc.
2 @c This is part of the GnuPG manual.
3 @c For copying conditions, see the file GnuPG.texi.
4
5 @include defs.inc
6
7 @node Helper Tools
8 @chapter Helper Tools
9
10 GnuPG comes with a couple of smaller tools:
11
12 @menu
13 * watchgnupg::            Read logs from a socket.
14 * gpgv::                  Verify OpenPGP signatures.
15 * addgnupghome::          Create .gnupg home directories.
16 * gpgconf::               Modify .gnupg home directories.
17 * applygnupgdefaults::    Run gpgconf for all users.
18 * gpg-preset-passphrase:: Put a passphrase into the cache.
19 * gpg-connect-agent::     Communicate with a running agent.
20 * dirmngr-client::        How to use the Dirmngr client tool.
21 * gpgparsemail::          Parse a mail message into an annotated format
22 * symcryptrun::           Call a simple symmetric encryption tool.
23 * gpg-zip::               Encrypt or sign files into an archive.
24 @end menu
25
26 @c
27 @c  WATCHGNUPG
28 @c
29 @manpage watchgnupg.1
30 @node watchgnupg
31 @section Read logs from a socket
32 @ifset manverb
33 .B watchgnupg
34 \- Read and print logs from a socket
35 @end ifset
36
37 @mansect synopsis
38 @ifset manverb
39 .B  watchgnupg
40 .RB [ \-\-force ]
41 .RB [ \-\-verbose ]
42 .I socketname
43 @end ifset
44
45 @mansect description
46 Most of the main utilities are able to write their log files to a Unix
47 Domain socket if configured that way.  @command{watchgnupg} is a simple
48 listener for such a socket.  It ameliorates the output with a time stamp
49 and makes sure that long lines are not interspersed with log output from
50 other utilities.  This tool is not available for Windows.
51
52
53 @noindent
54 @command{watchgnupg} is commonly invoked as
55
56 @example
57 watchgnupg --force $(gpgconf --list-dirs socketdir)/S.log
58 @end example
59 @manpause
60
61 @noindent
62 This starts it on the current terminal for listening on the standard
63 logging socket (which is either @file{~/.gnupg/S.log} or
64 @file{/var/run/user/UID/gnupg/S.log}).
65
66 @mansect options
67 @noindent
68 @command{watchgnupg} understands these options:
69
70 @table @gnupgtabopt
71
72 @item --force
73 @opindex force
74 Delete an already existing socket file.
75
76 @anchor{option watchgnupg --tcp}
77 @item --tcp @var{n}
78 Instead of reading from a local socket, listen for connects on TCP port
79 @var{n}.
80
81 @item --time-only
82 @opindex time-only
83 Do not print the date part of the timestamp.
84
85 @item --verbose
86 @opindex verbose
87 Enable extra informational output.
88
89 @item --version
90 @opindex version
91 Print version of the program and exit.
92
93 @item --help
94 @opindex help
95 Display a brief help page and exit.
96
97 @end table
98
99 @noindent
100 @mansect examples
101 @chapheading Examples
102
103 @example
104 $ watchgnupg --force --time-only $(gpgconf --list-dirs socketdir)/S.log
105 @end example
106
107 This waits for connections on the local socket
108 (e.g. @file{/home/foo/.gnupg/S.log}) and shows all log entries.  To
109 make this work the option @option{log-file} needs to be used with all
110 modules which logs are to be shown.  The suggested entry for the
111 configuration files is:
112
113 @example
114 log-file socket://
115 @end example
116
117 If the default socket as given above and returned by "echo $(gpgconf
118 --list-dirs socketdir)/S.log" is not desired an arbitrary socket name
119 can be specified, for example @file{socket:///home/foo/bar/mysocket}.
120 For debugging purposes it is also possible to do remote logging.  Take
121 care if you use this feature because the information is send in the
122 clear over the network.  Use this syntax in the conf files:
123
124 @example
125 log-file tcp://192.168.1.1:4711
126 @end example
127
128 You may use any port and not just 4711 as shown above; only IP
129 addresses are supported (v4 and v6) and no host names.  You need to
130 start @command{watchgnupg} with the @option{tcp} option.  Note that
131 under Windows the registry entry
132 @var{HKCU\Software\GNU\GnuPG:DefaultLogFile} can be used to change the
133 default log output from @code{stderr} to whatever is given by that
134 entry.  However the only useful entry is a TCP name for remote
135 debugging.
136
137
138 @mansect see also
139 @ifset isman
140 @command{gpg}(1),
141 @command{gpgsm}(1),
142 @command{gpg-agent}(1),
143 @command{scdaemon}(1)
144 @end ifset
145 @include see-also-note.texi
146
147
148 @c
149 @c  GPGV
150 @c
151 @include gpgv.texi
152
153
154 @c
155 @c    ADDGNUPGHOME
156 @c
157 @manpage addgnupghome.8
158 @node addgnupghome
159 @section Create .gnupg home directories
160 @ifset manverb
161 .B addgnupghome
162 \- Create .gnupg home directories
163 @end ifset
164
165 @mansect synopsis
166 @ifset manverb
167 .B  addgnupghome
168 .I account_1
169 .IR account_2 ... account_n
170 @end ifset
171
172 @mansect description
173 If GnuPG is installed on a system with existing user accounts, it is
174 sometimes required to populate the GnuPG home directory with existing
175 files.  Especially a @file{trustlist.txt} and a keybox with some
176 initial certificates are often desired.  This script helps to do this
177 by copying all files from @file{/etc/skel/.gnupg} to the home
178 directories of the accounts given on the command line.  It takes care
179 not to overwrite existing GnuPG home directories.
180
181 @noindent
182 @command{addgnupghome} is invoked by root as:
183
184 @example
185 addgnupghome account1 account2 ... accountn
186 @end example
187
188
189 @c
190 @c   GPGCONF
191 @c
192 @manpage gpgconf.1
193 @node gpgconf
194 @section Modify .gnupg home directories
195 @ifset manverb
196 .B gpgconf
197 \- Modify .gnupg home directories
198 @end ifset
199
200 @mansect synopsis
201 @ifset manverb
202 .B gpgconf
203 .RI [ options ]
204 .B \-\-list-components
205 .br
206 .B gpgconf
207 .RI [ options ]
208 .B \-\-list-options
209 .I component
210 .br
211 .B gpgconf
212 .RI [ options ]
213 .B \-\-change-options
214 .I component
215 @end ifset
216
217
218 @mansect description
219 The @command{gpgconf} is a utility to automatically and reasonable
220 safely query and modify configuration files in the @file{.gnupg} home
221 directory.  It is designed not to be invoked manually by the user, but
222 automatically by graphical user interfaces (GUI).@footnote{Please note
223 that currently no locking is done, so concurrent access should be
224 avoided.  There are some precautions to avoid corruption with
225 concurrent usage, but results may be inconsistent and some changes may
226 get lost.  The stateless design makes it difficult to provide more
227 guarantees.}
228
229 @command{gpgconf} provides access to the configuration of one or more
230 components of the GnuPG system.  These components correspond more or
231 less to the programs that exist in the GnuPG framework, like GPG,
232 GPGSM, DirMngr, etc.  But this is not a strict one-to-one
233 relationship.  Not all configuration options are available through
234 @command{gpgconf}.  @command{gpgconf} provides a generic and abstract
235 method to access the most important configuration options that can
236 feasibly be controlled via such a mechanism.
237
238 @command{gpgconf} can be used to gather and change the options
239 available in each component, and can also provide their default
240 values.  @command{gpgconf} will give detailed type information that
241 can be used to restrict the user's input without making an attempt to
242 commit the changes.
243
244 @command{gpgconf} provides the backend of a configuration editor.  The
245 configuration editor would usually be a graphical user interface
246 program that displays the current options, their default
247 values, and allows the user to make changes to the options.  These
248 changes can then be made active with @command{gpgconf} again.  Such a
249 program that uses @command{gpgconf} in this way will be called GUI
250 throughout this section.
251
252 @menu
253 * Invoking gpgconf::       List of all commands and options.
254 * Format conventions::     Formatting conventions relevant for all commands.
255 * Listing components::     List all gpgconf components.
256 * Checking programs::      Check all programs known to gpgconf.
257 * Listing options::        List all options of a component.
258 * Changing options::       Changing options of a component.
259 * Listing global options:: List all global options.
260 * Querying versions::      Get and compare software versions.
261 * Files used by gpgconf::  What files are used by gpgconf.
262 @end menu
263
264 @manpause
265 @node Invoking gpgconf
266 @subsection Invoking gpgconf
267
268 @mansect commands
269 One of the following commands must be given:
270
271 @table @gnupgtabopt
272
273 @item --list-components
274 List all components.  This is the default command used if none is
275 specified.
276
277 @item --check-programs
278 List all available backend programs and test whether they are runnable.
279
280 @item --list-options @var{component}
281 List all options of the component @var{component}.
282
283 @item --change-options @var{component}
284 Change the options of the component @var{component}.
285
286 @item --check-options @var{component}
287 Check the options for the component @var{component}.
288
289 @item --apply-profile @var{file}
290 Apply the configuration settings listed in @var{file} to the
291 configuration files.  If @var{file} has no suffix and no slashes the
292 command first tries to read a file with the suffix @code{.prf} from
293 the the data directory (@code{gpgconf --list-dirs datadir}) before it
294 reads the file verbatim.  A profile is divided into sections using the
295 bracketed  component name.  Each section then lists the option which
296 shall go into the respective configuration file.
297
298 @item --apply-defaults
299 Update all configuration files with values taken from the global
300 configuration file (usually @file{/etc/gnupg/gpgconf.conf}).
301
302 @item --list-dirs [@var{names}]
303 Lists the directories used by @command{gpgconf}.  One directory is
304 listed per line, and each line consists of a colon-separated list where
305 the first field names the directory type (for example @code{sysconfdir})
306 and the second field contains the percent-escaped directory.  Although
307 they are not directories, the socket file names used by
308 @command{gpg-agent} and @command{dirmngr} are printed as well.  Note
309 that the socket file names and the @code{homedir} lines are the default
310 names and they may be overridden by command line switches.  If
311 @var{names} are given only the directories or file names specified by
312 the list names are printed without any escaping.
313
314 @item --list-config [@var{filename}]
315 List the global configuration file in a colon separated format.  If
316 @var{filename} is given, check that file instead.
317
318 @item --check-config [@var{filename}]
319 Run a syntax check on the global configuration file.  If @var{filename}
320 is given, check that file instead.
321
322
323 @item --query-swdb @var{package_name} [@var{version_string}]
324 Returns the current version for @var{package_name} and if
325 @var{version_string} is given also an indicator on whether an update
326 is available.  The actual file with the software version is
327 automatically downloaded and checked by @command{dirmngr}.
328 @command{dirmngr} uses a thresholds to avoid download the file too
329 often and it does this by default only if it can be done via Tor.  To
330 force an update of that file this command can be used:
331
332 @example
333        gpg-connect-agent --dirmngr 'loadswdb --force' /bye
334 @end example
335
336
337 @item --reload [@var{component}]
338 @opindex reload
339 Reload all or the given component. This is basically the same as
340 sending a SIGHUP to the component.  Components which don't support
341 reloading are ignored.  Without @var{component} or by using "all" for
342 @var{component} all components which are daemons are reloaded.
343
344 @item --launch [@var{component}]
345 @opindex launch
346 If the @var{component} is not already running, start it.
347 @command{component} must be a daemon.  This is in general not required
348 because the system starts these daemons as needed.  However, external
349 software making direct use of @command{gpg-agent} or @command{dirmngr}
350 may use this command to ensure that they are started.  Using "all" for
351 @var{component} launches all components which are daemons.
352
353 @item --kill [@var{component}]
354 @opindex kill
355 Kill the given component.  Components which support killing are
356 @command{gpg-agent} and @command{scdaemon}.  Components which don't
357 support reloading are ignored.  Using "all" for @var{component} kills
358 all components running as daemons.  Note that as of now reload and
359 kill have the same effect for @command{scdaemon}.
360
361 @item --create-socketdir
362 @opindex create-socketdir
363 Create a directory for sockets below /run/user or /var/run/user.  This
364 is command is only required if a non default home directory is used
365 and the /run based sockets shall be used.  For the default home
366 directory GnUPG creates a directory on the fly.
367
368 @item --remove-socketdir
369 @opindex remove-socketdir
370 Remove a directory created with command @option{--create-socketdir}.
371
372 @end table
373
374
375 @mansect options
376
377 The following options may be used:
378
379 @table @gnupgtabopt
380
381 @item -o @var{file}
382 @itemx --output @var{file}
383 Write output to @var{file}.  Default is to write to stdout.
384
385 @item -v
386 @itemx --verbose
387 Outputs additional information while running.  Specifically, this
388 extends numerical field values by human-readable descriptions.
389
390 @item -q
391 @itemx --quiet
392 @opindex quiet
393 Try to be as quiet as possible.
394
395 @item -n
396 @itemx --dry-run
397 Do not actually change anything.  This is currently only implemented
398 for @code{--change-options} and can be used for testing purposes.
399
400 @item -r
401 @itemx --runtime
402 Only used together with @code{--change-options}.  If one of the
403 modified options can be changed in a running daemon process, signal
404 the running daemon to ask it to reparse its configuration file after
405 changing.
406
407 This means that the changes will take effect at run-time, as far as
408 this is possible.  Otherwise, they will take effect at the next start
409 of the respective backend programs.
410 @manpause
411 @end table
412
413
414 @node Format conventions
415 @subsection Format conventions
416
417 Some lines in the output of @command{gpgconf} contain a list of
418 colon-separated fields.  The following conventions apply:
419
420 @itemize @bullet
421 @item
422 The GUI program is required to strip off trailing newline and/or
423 carriage return characters from the output.
424
425 @item
426 @command{gpgconf} will never leave out fields.  If a certain version
427 provides a certain field, this field will always be present in all
428 @command{gpgconf} versions from that time on.
429
430 @item
431 Future versions of @command{gpgconf} might append fields to the list.
432 New fields will always be separated from the previously last field by
433 a colon separator.  The GUI should be prepared to parse the last field
434 it knows about up until a colon or end of line.
435
436 @item
437 Not all fields are defined under all conditions.  You are required to
438 ignore the content of undefined fields.
439 @end itemize
440
441 There are several standard types for the content of a field:
442
443 @table @asis
444 @item verbatim
445 Some fields contain strings that are not escaped in any way.  Such
446 fields are described to be used @emph{verbatim}.  These fields will
447 never contain a colon character (for obvious reasons).  No de-escaping
448 or other formatting is required to use the field content.  This is for
449 easy parsing of the output, when it is known that the content can
450 never contain any special characters.
451
452 @item percent-escaped
453 Some fields contain strings that are described to be
454 @emph{percent-escaped}.  Such strings need to be de-escaped before
455 their content can be presented to the user.  A percent-escaped string
456 is de-escaped by replacing all occurrences of @code{%XY} by the byte
457 that has the hexadecimal value @code{XY}.  @code{X} and @code{Y} are
458 from the set @code{0-9a-f}.
459
460 @item localized
461 Some fields contain strings that are described to be @emph{localized}.
462 Such strings are translated to the active language and formatted in
463 the active character set.
464
465 @item @w{unsigned number}
466 Some fields contain an @emph{unsigned number}.  This number will
467 always fit into a 32-bit unsigned integer variable.  The number may be
468 followed by a space, followed by a human readable description of that
469 value (if the verbose option is used).  You should ignore everything
470 in the field that follows the number.
471
472 @item @w{signed number}
473 Some fields contain a @emph{signed number}.  This number will always
474 fit into a 32-bit signed integer variable.  The number may be followed
475 by a space, followed by a human readable description of that value (if
476 the verbose option is used).  You should ignore everything in the
477 field that follows the number.
478
479 @item @w{boolean value}
480 Some fields contain a @emph{boolean value}.  This is a number with
481 either the value 0 or 1.  The number may be followed by a space,
482 followed by a human readable description of that value (if the verbose
483 option is used).  You should ignore everything in the field that follows
484 the number; checking just the first character is sufficient in this
485 case.
486
487 @item option
488 Some fields contain an @emph{option} argument.  The format of an
489 option argument depends on the type of the option and on some flags:
490
491 @table @asis
492 @item no argument
493 The simplest case is that the option does not take an argument at all
494 (@var{type} @code{0}).  Then the option argument is an unsigned number
495 that specifies how often the option occurs.  If the @code{list} flag
496 is not set, then the only valid number is @code{1}.  Options that do
497 not take an argument never have the @code{default} or @code{optional
498 arg} flag set.
499
500 @item number
501 If the option takes a number argument (@var{alt-type} is @code{2} or
502 @code{3}), and it can only occur once (@code{list} flag is not set),
503 then the option argument is either empty (only allowed if the argument
504 is optional), or it is a number.  A number is a string that begins
505 with an optional minus character, followed by one or more digits.  The
506 number must fit into an integer variable (unsigned or signed,
507 depending on @var{alt-type}).
508
509 @item number list
510 If the option takes a number argument and it can occur more than once,
511 then the option argument is either empty, or it is a comma-separated
512 list of numbers as described above.
513
514 @item string
515 If the option takes a string argument (@var{alt-type} is 1), and it
516 can only occur once (@code{list} flag is not set) then the option
517 argument is either empty (only allowed if the argument is optional),
518 or it starts with a double quote character (@code{"}) followed by a
519 percent-escaped string that is the argument value.  Note that there is
520 only a leading double quote character, no trailing one.  The double
521 quote character is only needed to be able to differentiate between no
522 value and the empty string as value.
523
524 @item string list
525 If the option takes a string argument and it can occur more than once,
526 then the option argument is either empty, or it is a comma-separated
527 list of string arguments as described above.
528 @end table
529 @end table
530
531 The active language and character set are currently determined from
532 the locale environment of the @command{gpgconf} program.
533
534 @c FIXME: Document the active language and active character set.  Allow
535 @c to change it via the command line?
536
537
538 @mansect usage
539 @node Listing components
540 @subsection Listing components
541
542 The command @code{--list-components} will list all components that can
543 be configured with @command{gpgconf}.  Usually, one component will
544 correspond to one GnuPG-related program and contain the options of
545 that program's configuration file that can be modified using
546 @command{gpgconf}.  However, this is not necessarily the case.  A
547 component might also be a group of selected options from several
548 programs, or contain entirely virtual options that have a special
549 effect rather than changing exactly one option in one configuration
550 file.
551
552 A component is a set of configuration options that semantically belong
553 together.  Furthermore, several changes to a component can be made in
554 an atomic way with a single operation.  The GUI could for example
555 provide a menu with one entry for each component, or a window with one
556 tabulator sheet per component.
557
558 The command @code{--list-components} lists all available
559 components, one per line.  The format of each line is:
560
561 @code{@var{name}:@var{description}:@var{pgmname}:}
562
563 @table @var
564 @item name
565 This field contains a name tag of the component.  The name tag is used
566 to specify the component in all communication with @command{gpgconf}.
567 The name tag is to be used @emph{verbatim}.  It is thus not in any
568 escaped format.
569
570 @item description
571 The @emph{string} in this field contains a human-readable description
572 of the component.  It can be displayed to the user of the GUI for
573 informational purposes.  It is @emph{percent-escaped} and
574 @emph{localized}.
575
576 @item pgmname
577 The @emph{string} in this field contains the absolute name of the
578 program's file.  It can be used to unambiguously invoke that program.
579 It is @emph{percent-escaped}.
580 @end table
581
582 Example:
583 @example
584 $ gpgconf --list-components
585 gpg:GPG for OpenPGP:/usr/local/bin/gpg2:
586 gpg-agent:GPG Agent:/usr/local/bin/gpg-agent:
587 scdaemon:Smartcard Daemon:/usr/local/bin/scdaemon:
588 gpgsm:GPG for S/MIME:/usr/local/bin/gpgsm:
589 dirmngr:Directory Manager:/usr/local/bin/dirmngr:
590 @end example
591
592
593
594 @node Checking programs
595 @subsection Checking programs
596
597 The command @code{--check-programs} is similar to
598 @code{--list-components} but works on backend programs and not on
599 components.  It runs each program to test whether it is installed and
600 runnable.  This also includes a syntax check of all config file options
601 of the program.
602
603 The command @code{--check-programs} lists all available
604 programs, one per line.  The format of each line is:
605
606 @code{@var{name}:@var{description}:@var{pgmname}:@var{avail}:@var{okay}:@var{cfgfile}:@var{line}:@var{error}:}
607
608 @table @var
609 @item name
610 This field contains a name tag of the program which is identical to the
611 name of the component.  The name tag is to be used @emph{verbatim}.  It
612 is thus not in any escaped format.  This field may be empty to indicate
613 a continuation of error descriptions for the last name.  The description
614 and pgmname fields are then also empty.
615
616 @item description
617 The @emph{string} in this field contains a human-readable description
618 of the component.  It can be displayed to the user of the GUI for
619 informational purposes.  It is @emph{percent-escaped} and
620 @emph{localized}.
621
622 @item pgmname
623 The @emph{string} in this field contains the absolute name of the
624 program's file.  It can be used to unambiguously invoke that program.
625 It is @emph{percent-escaped}.
626
627 @item avail
628 The @emph{boolean value} in this field indicates whether the program is
629 installed and runnable.
630
631 @item okay
632 The @emph{boolean value} in this field indicates whether the program's
633 config file is syntactically okay.
634
635 @item cfgfile
636 If an error occurred in the configuration file (as indicated by a false
637 value in the field @code{okay}), this field has the name of the failing
638 configuration file.  It is @emph{percent-escaped}.
639
640 @item line
641 If an error occurred in the configuration file, this field has the line
642 number of the failing statement in the configuration file.
643 It is an @emph{unsigned number}.
644
645 @item error
646 If an error occurred in the configuration file, this field has the error
647 text of the failing statement in the configuration file.  It is
648 @emph{percent-escaped} and @emph{localized}.
649
650 @end table
651
652 @noindent
653 In the following example the @command{dirmngr} is not runnable and the
654 configuration file of @command{scdaemon} is not okay.
655
656 @example
657 $ gpgconf --check-programs
658 gpg:GPG for OpenPGP:/usr/local/bin/gpg2:1:1:
659 gpg-agent:GPG Agent:/usr/local/bin/gpg-agent:1:1:
660 scdaemon:Smartcard Daemon:/usr/local/bin/scdaemon:1:0:
661 gpgsm:GPG for S/MIME:/usr/local/bin/gpgsm:1:1:
662 dirmngr:Directory Manager:/usr/local/bin/dirmngr:0:0:
663 @end example
664
665 @noindent
666 The command @w{@code{--check-options @var{component}}} will verify the
667 configuration file in the same manner as @code{--check-programs}, but
668 only for the component @var{component}.
669
670
671 @node Listing options
672 @subsection Listing options
673
674 Every component contains one or more options.  Options may be gathered
675 into option groups to allow the GUI to give visual hints to the user
676 about which options are related.
677
678 The command @code{@w{--list-options @var{component}}} lists
679 all options (and the groups they belong to) in the component
680 @var{component}, one per line.  @var{component} must be the string in
681 the field @var{name} in the output of the @code{--list-components}
682 command.
683
684 There is one line for each option and each group.  First come all
685 options that are not in any group.  Then comes a line describing a
686 group.  Then come all options that belong into each group.  Then comes
687 the next group and so on.  There does not need to be any group (and in
688 this case the output will stop after the last non-grouped option).
689
690 The format of each line is:
691
692 @code{@var{name}:@var{flags}:@var{level}:@var{description}:@var{type}:@var{alt-type}:@var{argname}:@var{default}:@var{argdef}:@var{value}}
693
694 @table @var
695 @item name
696 This field contains a name tag for the group or option.  The name tag
697 is used to specify the group or option in all communication with
698 @command{gpgconf}.  The name tag is to be used @emph{verbatim}.  It is
699 thus not in any escaped format.
700
701 @item flags
702 The flags field contains an @emph{unsigned number}.  Its value is the
703 OR-wise combination of the following flag values:
704
705 @table @code
706 @item group (1)
707 If this flag is set, this is a line describing a group and not an
708 option.
709 @end table
710
711 The following flag values are only defined for options (that is, if
712 the @code{group} flag is not used).
713
714 @table @code
715 @item optional arg (2)
716 If this flag is set, the argument is optional.  This is never set for
717 @var{type} @code{0} (none) options.
718
719 @item list (4)
720 If this flag is set, the option can be given multiple times.
721
722 @item runtime (8)
723 If this flag is set, the option can be changed at runtime.
724
725 @item default (16)
726 If this flag is set, a default value is available.
727
728 @item default desc (32)
729 If this flag is set, a (runtime) default is available.  This and the
730 @code{default} flag are mutually exclusive.
731
732 @item no arg desc (64)
733 If this flag is set, and the @code{optional arg} flag is set, then the
734 option has a special meaning if no argument is given.
735
736 @item no change (128)
737 If this flag is set, @command{gpgconf} ignores requests to change the
738 value.  GUI frontends should grey out this option.  Note, that manual
739 changes of the configuration files are still possible.
740 @end table
741
742 @item level
743 This field is defined for options and for groups.  It contains an
744 @emph{unsigned number} that specifies the expert level under which
745 this group or option should be displayed.  The following expert levels
746 are defined for options (they have analogous meaning for groups):
747
748 @table @code
749 @item basic (0)
750 This option should always be offered to the user.
751
752 @item advanced (1)
753 This option may be offered to advanced users.
754
755 @item expert (2)
756 This option should only be offered to expert users.
757
758 @item invisible (3)
759 This option should normally never be displayed, not even to expert
760 users.
761
762 @item internal (4)
763 This option is for internal use only.  Ignore it.
764 @end table
765
766 The level of a group will always be the lowest level of all options it
767 contains.
768
769 @item description
770 This field is defined for options and groups.  The @emph{string} in
771 this field contains a human-readable description of the option or
772 group.  It can be displayed to the user of the GUI for informational
773 purposes.  It is @emph{percent-escaped} and @emph{localized}.
774
775 @item type
776 This field is only defined for options.  It contains an @emph{unsigned
777 number} that specifies the type of the option's argument, if any.  The
778 following types are defined:
779
780 Basic types:
781
782 @table @code
783 @item none (0)
784 No argument allowed.
785
786 @item string (1)
787 An @emph{unformatted string}.
788
789 @item int32 (2)
790 A @emph{signed number}.
791
792 @item uint32 (3)
793 An @emph{unsigned number}.
794 @end table
795
796 Complex types:
797
798 @table @code
799 @item pathname (32)
800 A @emph{string} that describes the pathname of a file.  The file does
801 not necessarily need to exist.
802
803 @item ldap server (33)
804 A @emph{string} that describes an LDAP server in the format:
805
806 @code{@var{hostname}:@var{port}:@var{username}:@var{password}:@var{base_dn}}
807
808 @item key fingerprint (34)
809 A @emph{string} with a 40 digit fingerprint specifying a certificate.
810
811 @item pub key (35)
812 A @emph{string} that describes a certificate by user ID, key ID or
813 fingerprint.
814
815 @item sec key (36)
816 A @emph{string} that describes a certificate with a key by user ID,
817 key ID or fingerprint.
818
819 @item alias list (37)
820 A @emph{string} that describes an alias list, like the one used with
821 gpg's group option.  The list consists of a key, an equal sign and space
822 separated values.
823 @end table
824
825 More types will be added in the future.  Please see the @var{alt-type}
826 field for information on how to cope with unknown types.
827
828 @item alt-type
829 This field is identical to @var{type}, except that only the types
830 @code{0} to @code{31} are allowed.  The GUI is expected to present the
831 user the option in the format specified by @var{type}.  But if the
832 argument type @var{type} is not supported by the GUI, it can still
833 display the option in the more generic basic type @var{alt-type}.  The
834 GUI must support all the defined basic types to be able to display all
835 options.  More basic types may be added in future versions.  If the
836 GUI encounters a basic type it doesn't support, it should report an
837 error and abort the operation.
838
839 @item argname
840 This field is only defined for options with an argument type
841 @var{type} that is not @code{0}.  In this case it may contain a
842 @emph{percent-escaped} and @emph{localized string} that gives a short
843 name for the argument.  The field may also be empty, though, in which
844 case a short name is not known.
845
846 @item default
847 This field is defined only for options for which the @code{default} or
848 @code{default desc} flag is set.  If the @code{default} flag is set,
849 its format is that of an @emph{option argument} (@pxref{Format
850 conventions}, for details).  If the default value is empty, then no
851 default is known.  Otherwise, the value specifies the default value
852 for this option.  If the @code{default desc} flag is set, the field is
853 either empty or contains a description of the effect if the option is
854 not given.
855
856 @item argdef
857 This field is defined only for options for which the @code{optional
858 arg} flag is set.  If the @code{no arg desc} flag is not set, its
859 format is that of an @emph{option argument} (@pxref{Format
860 conventions}, for details).  If the default value is empty, then no
861 default is known.  Otherwise, the value specifies the default argument
862 for this option.  If the @code{no arg desc} flag is set, the field is
863 either empty or contains a description of the effect of this option if
864 no argument is given.
865
866 @item value
867 This field is defined only for options.  Its format is that of an
868 @emph{option argument}.  If it is empty, then the option is not
869 explicitly set in the current configuration, and the default applies
870 (if any).  Otherwise, it contains the current value of the option.
871 Note that this field is also meaningful if the option itself does not
872 take a real argument (in this case, it contains the number of times
873 the option appears).
874 @end table
875
876
877 @node Changing options
878 @subsection Changing options
879
880 The command @w{@code{--change-options @var{component}}} will attempt
881 to change the options of the component @var{component} to the
882 specified values.  @var{component} must be the string in the field
883 @var{name} in the output of the @code{--list-components} command.  You
884 have to provide the options that shall be changed in the following
885 format on standard input:
886
887 @code{@var{name}:@var{flags}:@var{new-value}}
888
889 @table @var
890 @item name
891 This is the name of the option to change.  @var{name} must be the
892 string in the field @var{name} in the output of the
893 @code{--list-options} command.
894
895 @item flags
896 The flags field contains an @emph{unsigned number}.  Its value is the
897 OR-wise combination of the following flag values:
898
899 @table @code
900 @item default (16)
901 If this flag is set, the option is deleted and the default value is
902 used instead (if applicable).
903 @end table
904
905 @item new-value
906 The new value for the option.  This field is only defined if the
907 @code{default} flag is not set.  The format is that of an @emph{option
908 argument}.  If it is empty (or the field is omitted), the default
909 argument is used (only allowed if the argument is optional for this
910 option).  Otherwise, the option will be set to the specified value.
911 @end table
912
913 @noindent
914 The output of the command is the same as that of
915 @code{--check-options} for the modified configuration file.
916
917 Examples:
918
919 To set the force option, which is of basic type @code{none (0)}:
920
921 @example
922 $ echo 'force:0:1' | gpgconf --change-options dirmngr
923 @end example
924
925 To delete the force option:
926
927 @example
928 $ echo 'force:16:' | gpgconf --change-options dirmngr
929 @end example
930
931 The @code{--runtime} option can influence when the changes take
932 effect.
933
934
935 @node Listing global options
936 @subsection Listing global options
937
938 Sometimes it is useful for applications to look at the global options
939 file @file{gpgconf.conf}.
940 The colon separated listing format is record oriented and uses the first
941 field to identify the record type:
942
943 @table @code
944 @item k
945 This describes a key record to start the definition of a new ruleset for
946 a user/group.  The format of a key record is:
947
948   @code{k:@var{user}:@var{group}:}
949
950 @table @var
951 @item user
952 This is the user field of the key.  It is percent escaped.  See the
953 definition of the gpgconf.conf format for details.
954
955 @item group
956 This is the group field of the key.  It is percent escaped.
957 @end table
958
959 @item r
960 This describes a rule record. All rule records up to the next key record
961 make up a rule set for that key.  The format of a rule record is:
962
963   @code{r:::@var{component}:@var{option}:@var{flag}:@var{value}:}
964
965 @table @var
966 @item component
967 This is the component part of a rule.  It is a plain string.
968
969 @item option
970 This is the option part of a rule.  It is a plain string.
971
972 @item flag
973 This is the flags part of a rule.  There may be only one flag per rule
974 but by using the same component and option, several flags may be
975 assigned to an option.  It is a plain string.
976
977 @item value
978 This is the optional value for the option.  It is a percent escaped
979 string with a single quotation mark to indicate a string.  The quotation
980 mark is only required to distinguish between no value specified and an
981 empty string.
982 @end table
983
984 @end table
985
986 @noindent
987 Unknown record types should be ignored.  Note that there is intentionally
988 no feature to change the global option file through @command{gpgconf}.
989
990
991 @node Querying versions
992 @subsection Get and compare software versions.
993
994 The GnuPG Project operates a server to query the current versions of
995 software packages related to GnuPG.  @command{gpgconf} can be used to
996 access this online database.  To allow for offline operations, this
997 feature works by having @command{dirmngr} download a file from
998 @code{https://versions.gnupg.org}, checking the signature of that file
999 and storing the file in the GnuPG home directory.  If
1000 @command{gpgconf} is used and @command{dirmngr} is running, it may ask
1001 @command{dirmngr} to refresh that file before itself uses the file.
1002
1003 The command @option{--query-swdb} returns information for the given
1004 package in a colon delimited format:
1005
1006 @table @var
1007
1008 @item name
1009 This is the name of the package as requested.  Note that "gnupg" is a
1010 special name which is replaced by the actual package implementing this
1011 version of GnuPG.  For this name it is also not required to specify a
1012 version because @command{gpgconf} takes its own version in this case.
1013
1014 @item iversion
1015 The currently installed version or an empty string.  The value is
1016 taken from the command line argument but may be provided by gpg
1017 if not given.
1018
1019 @item status
1020 The status of the software package according to this table:
1021 @table @code
1022 @item -
1023 No information available.  This is either because no current version
1024 has been specified or due to an error.
1025 @item ?
1026 The given name is not known in the online database.
1027 @item u
1028 An update of the software is available.
1029 @item c
1030 The installed version of the software is current.
1031 @item n
1032 The installed version is already newer than the released version.
1033 @end table
1034
1035 @item urgency
1036 If the value (the empty string should be considered as zero) is
1037 greater than zero an important update is available.
1038
1039 @item error
1040 This returns an @command{gpg-error} error code to distinguish between
1041 various failure modes.
1042
1043 @item filedate
1044 This gives the date of the file with the version numbers in standard
1045 ISO format (@code{yyyymmddThhmmss}).  The date has been extracted by
1046 @command{dirmngr} from the signature of the file.
1047
1048 @item verified
1049 This gives the date in ISO format the file was downloaded.  This value
1050 can be used to evaluate the freshness of the information.
1051
1052 @item version
1053 This returns the version string for the requested software from the
1054 file.
1055
1056 @item reldate
1057 This returns the release date in ISO format.
1058
1059 @item size
1060 This returns the size of the package as decimal number of bytes.
1061
1062 @item hash
1063 This returns a hexified SHA-2 hash of the package.
1064
1065 @end table
1066
1067 @noindent
1068 More fields may be added in future to the output.
1069
1070
1071 @mansect files
1072 @node Files used by gpgconf
1073 @subsection Files used by gpgconf
1074
1075 @table @file
1076
1077 @item /etc/gnupg/gpgconf.conf
1078 @cindex gpgconf.conf
1079   If this file exists, it is processed as a global configuration file.
1080   A commented example can be found in the @file{examples} directory of
1081   the distribution.
1082
1083 @item @var{GNUPGHOME}/swdb.lst
1084 @cindex swdb.lst
1085   A file with current software versions.  @command{dirmngr} creates
1086   this file on demand from an online resource.
1087
1088 @end table
1089
1090
1091 @mansect see also
1092 @ifset isman
1093 @command{gpg}(1),
1094 @command{gpgsm}(1),
1095 @command{gpg-agent}(1),
1096 @command{scdaemon}(1),
1097 @command{dirmngr}(1)
1098 @end ifset
1099 @include see-also-note.texi
1100
1101
1102
1103 @c
1104 @c    APPLYGNUPGDEFAULTS
1105 @c
1106 @manpage applygnupgdefaults.8
1107 @node applygnupgdefaults
1108 @section Run gpgconf for all users
1109 @ifset manverb
1110 .B applygnupgdefaults
1111 \- Run gpgconf --apply-defaults for all users.
1112 @end ifset
1113
1114 @mansect synopsis
1115 @ifset manverb
1116 .B  applygnupgdefaults
1117 @end ifset
1118
1119 @mansect description
1120 This script is a wrapper around @command{gpgconf} to run it with the
1121 command @code{--apply-defaults} for all real users with an existing
1122 GnuPG home directory.  Admins might want to use this script to update he
1123 GnuPG configuration files for all users after
1124 @file{/etc/gnupg/gpgconf.conf} has been changed.  This allows enforcing
1125 certain policies for all users.  Note, that this is not a bulletproof way to
1126 force a user to use certain options.  A user may always directly edit
1127 the configuration files and bypass gpgconf.
1128
1129 @noindent
1130 @command{applygnupgdefaults} is invoked by root as:
1131
1132 @example
1133 applygnupgdefaults
1134 @end example
1135
1136
1137 @c
1138 @c   GPG-PRESET-PASSPHRASE
1139 @c
1140 @node gpg-preset-passphrase
1141 @section Put a passphrase into the cache
1142 @manpage gpg-preset-passphrase.1
1143 @ifset manverb
1144 .B gpg-preset-passphrase
1145 \- Put a passphrase into gpg-agent's cache
1146 @end ifset
1147
1148 @mansect synopsis
1149 @ifset manverb
1150 .B  gpg-preset-passphrase
1151 .RI [ options ]
1152 .RI [ command ]
1153 .I cache-id
1154 @end ifset
1155
1156 @mansect description
1157 The @command{gpg-preset-passphrase} is a utility to seed the internal
1158 cache of a running @command{gpg-agent} with passphrases.  It is mainly
1159 useful for unattended machines, where the usual @command{pinentry} tool
1160 may not be used and the passphrases for the to be used keys are given at
1161 machine startup.
1162
1163 This program works with GnuPG 2 and later.  GnuPG 1.x is not supported.
1164
1165 Passphrases set with this utility don't expire unless the
1166 @option{--forget} option is used to explicitly clear them from the
1167 cache --- or @command{gpg-agent} is either restarted or reloaded (by
1168 sending a SIGHUP to it).  Note that the maximum cache time as set with
1169 @option{--max-cache-ttl} is still honored.  It is necessary to allow
1170 this passphrase presetting by starting @command{gpg-agent} with the
1171 @option{--allow-preset-passphrase}.
1172
1173 @menu
1174 * Invoking gpg-preset-passphrase::   List of all commands and options.
1175 @end menu
1176
1177 @manpause
1178 @node Invoking gpg-preset-passphrase
1179 @subsection List of all commands and options
1180 @mancont
1181
1182 @noindent
1183 @command{gpg-preset-passphrase} is invoked this way:
1184
1185 @example
1186 gpg-preset-passphrase [options] [command] @var{cacheid}
1187 @end example
1188
1189 @var{cacheid} is either a 40 character keygrip of hexadecimal
1190 characters identifying the key for which the passphrase should be set
1191 or cleared.  The keygrip is listed along with the key when running the
1192 command: @code{gpgsm --with-keygrip --list-secret-keys}.
1193 Alternatively an arbitrary string may be used to identify a
1194 passphrase; it is suggested that such a string is prefixed with the
1195 name of the application (e.g @code{foo:12346}).  Scripts should always
1196 use the option @option{--with-colons}, which provides the keygrip in a
1197 "grp" line (cf. @file{doc/DETAILS})/
1198
1199 @noindent
1200 One of the following command options must be given:
1201
1202 @table @gnupgtabopt
1203 @item --preset
1204 @opindex preset
1205 Preset a passphrase. This is what you usually will
1206 use. @command{gpg-preset-passphrase} will then read the passphrase from
1207 @code{stdin}.
1208
1209 @item --forget
1210 @opindex forget
1211 Flush the passphrase for the given cache ID from the cache.
1212
1213 @end table
1214
1215 @noindent
1216 The following additional options may be used:
1217
1218 @table @gnupgtabopt
1219 @item -v
1220 @itemx --verbose
1221 @opindex verbose
1222 Output additional information while running.
1223
1224 @item -P @var{string}
1225 @itemx --passphrase @var{string}
1226 @opindex passphrase
1227 Instead of reading the passphrase from @code{stdin}, use the supplied
1228 @var{string} as passphrase.  Note that this makes the passphrase visible
1229 for other users.
1230 @end table
1231
1232 @mansect see also
1233 @ifset isman
1234 @command{gpg}(1),
1235 @command{gpgsm}(1),
1236 @command{gpg-agent}(1),
1237 @command{scdaemon}(1)
1238 @end ifset
1239 @include see-also-note.texi
1240
1241
1242
1243
1244 @c
1245 @c   GPG-CONNECT-AGENT
1246 @c
1247 @node gpg-connect-agent
1248 @section Communicate with a running agent
1249 @manpage gpg-connect-agent.1
1250 @ifset manverb
1251 .B gpg-connect-agent
1252 \- Communicate with a running agent
1253 @end ifset
1254
1255 @mansect synopsis
1256 @ifset manverb
1257 .B  gpg-connect-agent
1258 .RI [ options ] [commands]
1259 @end ifset
1260
1261 @mansect description
1262 The @command{gpg-connect-agent} is a utility to communicate with a
1263 running @command{gpg-agent}.  It is useful to check out the commands
1264 @command{gpg-agent} provides using the Assuan interface.  It might
1265 also be useful for scripting simple applications.  Input is expected
1266 at stdin and output gets printed to stdout.
1267
1268 It is very similar to running @command{gpg-agent} in server mode; but
1269 here we connect to a running instance.
1270
1271 @menu
1272 * Invoking gpg-connect-agent::       List of all options.
1273 * Controlling gpg-connect-agent::    Control commands.
1274 @end menu
1275
1276 @manpause
1277 @node Invoking gpg-connect-agent
1278 @subsection List of all options
1279
1280 @noindent
1281 @command{gpg-connect-agent} is invoked this way:
1282
1283 @example
1284 gpg-connect-agent [options] [commands]
1285 @end example
1286 @mancont
1287
1288 @noindent
1289 The following options may be used:
1290
1291 @table @gnupgtabopt
1292 @item -v
1293 @itemx --verbose
1294 @opindex verbose
1295 Output additional information while running.
1296
1297 @item -q
1298 @item --quiet
1299 @opindex q
1300 @opindex quiet
1301 Try to be as quiet as possible.
1302
1303 @include opt-homedir.texi
1304
1305 @item --agent-program @var{file}
1306 @opindex agent-program
1307 Specify the agent program to be started if none is running.  The
1308 default value is determined by running @command{gpgconf} with the
1309 option @option{--list-dirs}.  Note that the pipe symbol (@code{|}) is
1310 used for a regression test suite hack and may thus not be used in the
1311 file name.
1312
1313 @item --dirmngr-program @var{file}
1314 @opindex dirmngr-program
1315 Specify the directory manager (keyserver client) program to be started
1316 if none is running.  This has only an effect if used together with the
1317 option @option{--dirmngr}.
1318
1319 @item --dirmngr
1320 @opindex dirmngr
1321 Connect to a running directory manager (keyserver client) instead of
1322 to the gpg-agent.  If a dirmngr is not running, start it.
1323
1324 @item -S
1325 @itemx --raw-socket @var{name}
1326 @opindex raw-socket
1327 Connect to socket @var{name} assuming this is an Assuan style server.
1328 Do not run any special initializations or environment checks.  This may
1329 be used to directly connect to any Assuan style socket server.
1330
1331 @item -E
1332 @itemx --exec
1333 @opindex exec
1334 Take the rest of the command line as a program and it's arguments and
1335 execute it as an Assuan server. Here is how you would run @command{gpgsm}:
1336 @smallexample
1337  gpg-connect-agent --exec gpgsm --server
1338 @end smallexample
1339 Note that you may not use options on the command line in this case.
1340
1341 @item --no-ext-connect
1342 @opindex no-ext-connect
1343 When using @option{-S} or @option{--exec}, @command{gpg-connect-agent}
1344 connects to the Assuan server in extended mode to allow descriptor
1345 passing.  This option makes it use the old mode.
1346
1347 @item --no-autostart
1348 @opindex no-autostart
1349 Do not start the gpg-agent or the dirmngr if it has not yet been
1350 started.
1351
1352 @item -r @var{file}
1353 @itemx --run @var{file}
1354 @opindex run
1355 Run the commands from @var{file} at startup and then continue with the
1356 regular input method.  Note, that commands given on the command line are
1357 executed after this file.
1358
1359 @item -s
1360 @itemx --subst
1361 @opindex subst
1362 Run the command @code{/subst} at startup.
1363
1364 @item --hex
1365 @opindex hex
1366 Print data lines in a hex format and the ASCII representation of
1367 non-control characters.
1368
1369 @item --decode
1370 @opindex decode
1371 Decode data lines.  That is to remove percent escapes but make sure that
1372 a new line always starts with a D and a space.
1373
1374 @end table
1375
1376 @mansect control commands
1377 @node Controlling gpg-connect-agent
1378 @subsection Control commands
1379
1380 While reading Assuan commands, gpg-agent also allows a few special
1381 commands to control its operation.  These control commands all start
1382 with a slash (@code{/}).
1383
1384 @table @code
1385
1386 @item /echo @var{args}
1387 Just print @var{args}.
1388
1389 @item /let @var{name} @var{value}
1390 Set the variable @var{name} to @var{value}.  Variables are only
1391 substituted on the input if the @command{/subst} has been used.
1392 Variables are referenced by prefixing the name with a dollar sign and
1393 optionally include the name in curly braces.  The rules for a valid name
1394 are identically to those of the standard bourne shell.  This is not yet
1395 enforced but may be in the future.  When used with curly braces no
1396 leading or trailing white space is allowed.
1397
1398 If a variable is not found, it is searched in the environment and if
1399 found copied to the table of variables.
1400
1401 Variable functions are available: The name of the function must be
1402 followed by at least one space and the at least one argument.  The
1403 following functions are available:
1404
1405 @table @code
1406 @item get
1407 Return a value described by the argument.  Available arguments are:
1408
1409 @table @code
1410 @item cwd
1411 The current working directory.
1412 @item homedir
1413 The gnupg homedir.
1414 @item sysconfdir
1415 GnuPG's system configuration directory.
1416 @item bindir
1417 GnuPG's binary directory.
1418 @item libdir
1419 GnuPG's library directory.
1420 @item libexecdir
1421 GnuPG's library directory for executable files.
1422 @item datadir
1423 GnuPG's data directory.
1424 @item serverpid
1425 The PID of the current server. Command @command{/serverpid} must
1426 have been given to return a useful value.
1427 @end table
1428
1429 @item unescape @var{args}
1430 Remove C-style escapes from @var{args}.  Note that @code{\0} and
1431 @code{\x00} terminate the returned string implicitly.  The string to be
1432 converted are the entire arguments right behind the delimiting space of
1433 the function name.
1434
1435 @item unpercent @var{args}
1436 @itemx unpercent+ @var{args}
1437 Remove percent style escaping from @var{args}.  Note that @code{%00}
1438 terminates the string implicitly.  The string to be converted are the
1439 entire arguments right behind the delimiting space of the function
1440 name. @code{unpercent+} also maps plus signs to a spaces.
1441
1442 @item percent @var{args}
1443 @itemx percent+ @var{args}
1444 Escape the @var{args} using percent style escaping.  Tabs, formfeeds,
1445 linefeeds, carriage returns and colons are escaped. @code{percent+} also
1446 maps spaces to plus signs.
1447
1448 @item errcode @var{arg}
1449 @itemx errsource @var{arg}
1450 @itemx errstring @var{arg}
1451 Assume @var{arg} is an integer and evaluate it using @code{strtol}.  Return
1452 the gpg-error error code, error source or a formatted string with the
1453 error code and error source.
1454
1455
1456 @item +
1457 @itemx -
1458 @itemx *
1459 @itemx /
1460 @itemx %
1461 Evaluate all arguments as long integers using @code{strtol} and apply
1462 this operator.  A division by zero yields an empty string.
1463
1464 @item !
1465 @itemx |
1466 @itemx &
1467 Evaluate all arguments as long integers using @code{strtol} and apply
1468 the logical operators NOT, OR or AND.  The NOT operator works on the
1469 last argument only.
1470
1471
1472 @end table
1473
1474
1475 @item /definq @var{name} @var{var}
1476 Use content of the variable @var{var} for inquiries with @var{name}.
1477 @var{name} may be an asterisk (@code{*}) to match any inquiry.
1478
1479
1480 @item /definqfile @var{name} @var{file}
1481 Use content of @var{file} for inquiries with @var{name}.
1482 @var{name} may be an asterisk (@code{*}) to match any inquiry.
1483
1484 @item /definqprog @var{name} @var{prog}
1485 Run @var{prog} for inquiries matching @var{name} and pass the
1486 entire line to it as command line arguments.
1487
1488 @item /datafile @var{name}
1489 Write all data lines from the server to the file @var{name}.  The file
1490 is opened for writing and created if it does not exists.  An existing
1491 file is first truncated to 0.  The data written to the file fully
1492 decoded.  Using a single dash for @var{name} writes to stdout.  The
1493 file is kept open until a new file is set using this command or this
1494 command is used without an argument.
1495
1496 @item /showdef
1497 Print all definitions
1498
1499 @item /cleardef
1500 Delete all definitions
1501
1502 @item /sendfd @var{file} @var{mode}
1503 Open @var{file} in @var{mode} (which needs to be a valid @code{fopen}
1504 mode string) and send the file descriptor to the server.  This is
1505 usually followed by a command like @code{INPUT FD} to set the
1506 input source for other commands.
1507
1508 @item /recvfd
1509 Not yet implemented.
1510
1511 @item /open @var{var} @var{file} [@var{mode}]
1512 Open @var{file} and assign the file descriptor to @var{var}.  Warning:
1513 This command is experimental and might change in future versions.
1514
1515 @item /close @var{fd}
1516 Close the file descriptor @var{fd}.  Warning: This command is
1517 experimental and might change in future versions.
1518
1519 @item /showopen
1520 Show a list of open files.
1521
1522 @item /serverpid
1523 Send the Assuan command @command{GETINFO pid} to the server and store
1524 the returned PID for internal purposes.
1525
1526 @item /sleep
1527 Sleep for a second.
1528
1529 @item /hex
1530 @itemx /nohex
1531 Same as the command line option @option{--hex}.
1532
1533 @item /decode
1534 @itemx /nodecode
1535 Same as the command line option @option{--decode}.
1536
1537 @item /subst
1538 @itemx /nosubst
1539 Enable and disable variable substitution.  It defaults to disabled
1540 unless the command line option @option{--subst} has been used.
1541 If /subst as been enabled once, leading whitespace is removed from
1542 input lines which makes scripts easier to read.
1543
1544 @item /while @var{condition}
1545 @itemx /end
1546 These commands provide a way for executing loops.  All lines between
1547 the @code{while} and the corresponding @code{end} are executed as long
1548 as the evaluation of @var{condition} yields a non-zero value or is the
1549 string @code{true} or @code{yes}.  The evaluation is done by passing
1550 @var{condition} to the @code{strtol} function.  Example:
1551
1552 @smallexample
1553   /subst
1554   /let i 3
1555   /while $i
1556     /echo loop couter is $i
1557     /let i $@{- $i 1@}
1558   /end
1559 @end smallexample
1560
1561 @item /if @var{condition}
1562 @itemx /end
1563 These commands provide a way for conditional execution.  All lines between
1564 the @code{if} and the corresponding @code{end} are executed only if
1565 the evaluation of @var{condition} yields a non-zero value or is the
1566 string @code{true} or @code{yes}.  The evaluation is done by passing
1567 @var{condition} to the @code{strtol} function.
1568
1569 @item /run @var{file}
1570 Run commands from @var{file}.
1571
1572 @item /bye
1573 Terminate the connection and the program.
1574
1575 @item /help
1576 Print a list of available control commands.
1577
1578 @end table
1579
1580
1581 @ifset isman
1582 @mansect see also
1583 @command{gpg-agent}(1),
1584 @command{scdaemon}(1)
1585 @include see-also-note.texi
1586 @end ifset
1587
1588 @c
1589 @c   DIRMNGR-CLIENT
1590 @c
1591 @node dirmngr-client
1592 @section The Dirmngr Client Tool
1593
1594 @manpage dirmngr-client.1
1595 @ifset manverb
1596 .B dirmngr-client
1597 \- Tool to access the Dirmngr services
1598 @end ifset
1599
1600 @mansect synopsis
1601 @ifset manverb
1602 .B  dirmngr-client
1603 .RI [ options ]
1604 .RI [ certfile | pattern ]
1605 @end ifset
1606
1607 @mansect description
1608 The @command{dirmngr-client} is a simple tool to contact a running
1609 dirmngr and test whether a certificate has been revoked --- either by
1610 being listed in the corresponding CRL or by running the OCSP protocol.
1611 If no dirmngr is running, a new instances will be started but this is
1612 in general not a good idea due to the huge performance overhead.
1613
1614 @noindent
1615 The usual way to run this tool is either:
1616
1617 @example
1618 dirmngr-client @var{acert}
1619 @end example
1620
1621 @noindent
1622 or
1623
1624 @example
1625 dirmngr-client <@var{acert}
1626 @end example
1627
1628 Where @var{acert} is one DER encoded (binary) X.509 certificates to be
1629 tested.
1630 @ifclear isman
1631 The return value of this command is
1632 @end ifclear
1633
1634 @mansect return value
1635 @ifset isman
1636 @command{dirmngr-client} returns these values:
1637 @end ifset
1638 @table @code
1639
1640 @item 0
1641 The certificate under question is valid; i.e. there is a valid CRL
1642 available and it is not listed there or the OCSP request returned that
1643 that certificate is valid.
1644
1645 @item 1
1646 The certificate has been revoked
1647
1648 @item 2 (and other values)
1649 There was a problem checking the revocation state of the certificate.
1650 A message to stderr has given more detailed information.  Most likely
1651 this is due to a missing or expired CRL or due to a network problem.
1652
1653 @end table
1654
1655 @mansect options
1656 @noindent
1657 @command{dirmngr-client} may be called with the following options:
1658
1659
1660 @table @gnupgtabopt
1661 @item --version
1662 @opindex version
1663 Print the program version and licensing information.  Note that you cannot
1664 abbreviate this command.
1665
1666 @item --help, -h
1667 @opindex help
1668 Print a usage message summarizing the most useful command-line options.
1669 Note that you cannot abbreviate this command.
1670
1671 @item --quiet, -q
1672 @opindex quiet
1673 Make the output extra brief by suppressing any informational messages.
1674
1675 @item -v
1676 @item --verbose
1677 @opindex v
1678 @opindex verbose
1679 Outputs additional information while running.
1680 You can increase the verbosity by giving several
1681 verbose commands to @sc{dirmngr}, such as @samp{-vv}.
1682
1683 @item --pem
1684 @opindex pem
1685 Assume that the given certificate is in PEM (armored) format.
1686
1687 @item --ocsp
1688 @opindex ocsp
1689 Do the check using the OCSP protocol and ignore any CRLs.
1690
1691 @item --force-default-responder
1692 @opindex force-default-responder
1693 When checking using the OCSP protocol, force the use of the default OCSP
1694 responder.  That is not to use the Reponder as given by the certificate.
1695
1696 @item --ping
1697 @opindex ping
1698 Check whether the dirmngr daemon is up and running.
1699
1700 @item --cache-cert
1701 @opindex cache-cert
1702 Put the given certificate into the cache of a running dirmngr.  This is
1703 mainly useful for debugging.
1704
1705 @item --validate
1706 @opindex validate
1707 Validate the given certificate using dirmngr's internal validation code.
1708 This is mainly useful for debugging.
1709
1710 @item --load-crl
1711 @opindex load-crl
1712 This command expects a list of filenames with DER encoded CRL files.
1713 With the option @option{--url} URLs are expected in place of filenames
1714 and they are loaded directly from the given location.  All CRLs will be
1715 validated and then loaded into dirmngr's cache.
1716
1717 @item --lookup
1718 @opindex lookup
1719 Take the remaining arguments and run a lookup command on each of them.
1720 The results are Base-64 encoded outputs (without header lines).  This
1721 may be used to retrieve certificates from a server. However the output
1722 format is not very well suited if more than one certificate is returned.
1723
1724 @item --url
1725 @itemx -u
1726 @opindex url
1727 Modify the @command{lookup} and @command{load-crl} commands to take an URL.
1728
1729 @item --local
1730 @itemx -l
1731 @opindex url
1732 Let the @command{lookup} command only search the local cache.
1733
1734 @item --squid-mode
1735 @opindex squid-mode
1736 Run @sc{dirmngr-client} in a mode suitable as a helper program for
1737 Squid's @option{external_acl_type} option.
1738
1739
1740 @end table
1741
1742 @ifset isman
1743 @mansect see also
1744 @command{dirmngr}(8),
1745 @command{gpgsm}(1)
1746 @include see-also-note.texi
1747 @end ifset
1748
1749
1750 @c
1751 @c   GPGPARSEMAIL
1752 @c
1753 @node gpgparsemail
1754 @section Parse a mail message into an annotated format
1755
1756 @manpage gpgparsemail.1
1757 @ifset manverb
1758 .B gpgparsemail
1759 \- Parse a mail message into an annotated format
1760 @end ifset
1761
1762 @mansect synopsis
1763 @ifset manverb
1764 .B  gpgparsemail
1765 .RI [ options ]
1766 .RI [ file ]
1767 @end ifset
1768
1769 @mansect description
1770 The @command{gpgparsemail} is a utility currently only useful for
1771 debugging.  Run it with @code{--help} for usage information.
1772
1773
1774
1775 @c
1776 @c   SYMCRYPTRUN
1777 @c
1778 @node symcryptrun
1779 @section Call a simple symmetric encryption tool
1780 @manpage symcryptrun.1
1781 @ifset manverb
1782 .B symcryptrun
1783 \- Call a simple symmetric encryption tool
1784 @end ifset
1785
1786 @mansect synopsis
1787 @ifset manverb
1788 .B  symcryptrun
1789 .B \-\-class
1790 .I class
1791 .B \-\-program
1792 .I program
1793 .B \-\-keyfile
1794 .I keyfile
1795 .RB [ --decrypt | --encrypt ]
1796 .RI [ inputfile ]
1797 @end ifset
1798
1799 @mansect description
1800 Sometimes simple encryption tools are already in use for a long time
1801 and there might be a desire to integrate them into the GnuPG
1802 framework.  The protocols and encryption methods might be non-standard
1803 or not even properly documented, so that a full-fledged encryption
1804 tool with an interface like @command{gpg} is not doable.
1805 @command{symcryptrun} provides a solution: It operates by calling the
1806 external encryption/decryption module and provides a passphrase for a
1807 key using the standard @command{pinentry} based mechanism through
1808 @command{gpg-agent}.
1809
1810 Note, that @command{symcryptrun} is only available if GnuPG has been
1811 configured with @samp{--enable-symcryptrun} at build time.
1812
1813 @menu
1814 * Invoking symcryptrun::   List of all commands and options.
1815 @end menu
1816
1817 @manpause
1818 @node Invoking symcryptrun
1819 @subsection List of all commands and options
1820
1821 @noindent
1822 @command{symcryptrun} is invoked this way:
1823
1824 @example
1825 symcryptrun --class CLASS --program PROGRAM --keyfile KEYFILE
1826    [--decrypt | --encrypt] [inputfile]
1827 @end example
1828 @mancont
1829
1830 For encryption, the plain text must be provided on STDIN or as the
1831 argument @var{inputfile}, and the ciphertext will be output to STDOUT.
1832 For decryption vice versa.
1833
1834 @var{CLASS} describes the calling conventions of the external tool.
1835 Currently it must be given as @samp{confucius}.  @var{PROGRAM} is
1836 the full filename of that external tool.
1837
1838 For the class @samp{confucius} the option @option{--keyfile} is
1839 required; @var{keyfile} is the name of a file containing the secret key,
1840 which may be protected by a passphrase.  For detailed calling
1841 conventions, see the source code.
1842
1843 @noindent
1844 Note, that @command{gpg-agent} must be running before starting
1845 @command{symcryptrun}.
1846
1847 @noindent
1848 The following additional options may be used:
1849
1850 @table @gnupgtabopt
1851 @item -v
1852 @itemx --verbose
1853 @opindex verbose
1854 Output additional information while running.
1855
1856 @item -q
1857 @item --quiet
1858 @opindex q
1859 @opindex quiet
1860 Try to be as quiet as possible.
1861
1862 @include opt-homedir.texi
1863
1864
1865 @item --log-file @var{file}
1866 @opindex log-file
1867 Append all logging output to @var{file}.  Use @file{socket://} to log
1868 to socket.  Default is to write logging information to STDERR.
1869
1870 @end table
1871
1872 @noindent
1873 The possible exit status codes of @command{symcryptrun} are:
1874
1875 @table @code
1876 @item 0
1877         Success.
1878 @item 1
1879         Some error occurred.
1880 @item 2
1881         No valid passphrase was provided.
1882 @item 3
1883         The operation was canceled by the user.
1884
1885 @end table
1886
1887 @mansect see also
1888 @ifset isman
1889 @command{gpg}(1),
1890 @command{gpgsm}(1),
1891 @command{gpg-agent}(1),
1892 @end ifset
1893 @include see-also-note.texi
1894
1895
1896 @c
1897 @c  GPG-ZIP
1898 @c
1899 @c The original manpage on which this section is based was written
1900 @c by Colin Tuckley  <colin@tuckley.org> and Daniel Leidert
1901 @c <daniel.leidert@wgdd.de> for the Debian distribution (but may be used by
1902 @c others).
1903 @manpage gpg-zip.1
1904 @node gpg-zip
1905 @section Encrypt or sign files into an archive
1906 @ifset manverb
1907 .B gpg-zip
1908 \- Encrypt or sign files into an archive
1909 @end ifset
1910
1911 @mansect synopsis
1912 @ifset manverb
1913 .B  gpg-zip
1914 .RI [ options ]
1915 .I filename1
1916 .I [ filename2, ... ]
1917 .I directory1
1918 .I [ directory2, ... ]
1919 @end ifset
1920
1921 @mansect description
1922 @command{gpg-zip} encrypts or signs files into an archive.  It is an
1923 gpg-ized tar using the same format as used by PGP's PGP Zip.
1924
1925 @manpause
1926 @noindent
1927 @command{gpg-zip} is invoked this way:
1928
1929 @example
1930 gpg-zip [options] @var{filename1} [@var{filename2}, ...] @var{directory} [@var{directory2}, ...]
1931 @end example
1932
1933 @mansect options
1934 @noindent
1935 @command{gpg-zip} understands these options:
1936
1937 @table @gnupgtabopt
1938
1939 @item --encrypt
1940 @itemx -e
1941 @opindex encrypt
1942 Encrypt data.  This option may be combined with @option{--symmetric} (for  output that may be decrypted via a secret key or a passphrase).
1943
1944 @item --decrypt
1945 @itemx -d
1946 @opindex decrypt
1947 Decrypt data.
1948
1949 @item --symmetric
1950 @itemx -c
1951 Encrypt with a symmetric cipher using a passphrase.  The default
1952 symmetric cipher used is CAST5, but may be chosen with the
1953 @option{--cipher-algo} option to @command{gpg}.
1954
1955 @item --sign
1956 @itemx -s
1957 Make a signature.  See @command{gpg}.
1958
1959 @item --recipient @var{user}
1960 @itemx -r @var{user}
1961 @opindex recipient
1962 Encrypt for user id @var{user}. See @command{gpg}.
1963
1964 @item --local-user @var{user}
1965 @itemx -u @var{user}
1966 @opindex local-user
1967 Use @var{user} as the key to sign with.  See @command{gpg}.
1968
1969 @item --list-archive
1970 @opindex list-archive
1971 List the contents of the specified archive.
1972
1973 @item --output @var{file}
1974 @itemx -o @var{file}
1975 @opindex output
1976 Write output to specified file @var{file}.
1977
1978 @item --gpg @var{gpgcmd}
1979 @opindex gpg
1980 Use the specified command @var{gpgcmd} instead of @command{gpg}.
1981
1982 @item --gpg-args @var{args}
1983 @opindex gpg-args
1984 Pass the specified options to @command{gpg}.
1985
1986 @item --tar @var{tarcmd}
1987 @opindex tar
1988 Use the specified command @var{tarcmd} instead of @command{tar}.
1989
1990 @item --tar-args @var{args}
1991 @opindex tar-args
1992 Pass the specified options to @command{tar}.
1993
1994 @item --version
1995 @opindex version
1996 Print version of the program and exit.
1997
1998 @item --help
1999 @opindex help
2000 Display a brief help page and exit.
2001
2002 @end table
2003
2004 @mansect diagnostics
2005 @noindent
2006 The program returns 0 if everything was fine, 1 otherwise.
2007
2008
2009 @mansect examples
2010 @ifclear isman
2011 @noindent
2012 Some examples:
2013
2014 @end ifclear
2015 @noindent
2016 Encrypt the contents of directory @file{mydocs} for user Bob to file
2017 @file{test1}:
2018
2019 @example
2020 gpg-zip --encrypt --output test1 --gpg-args  -r Bob mydocs
2021 @end example
2022
2023 @noindent
2024 List the contents of archive @file{test1}:
2025
2026 @example
2027 gpg-zip --list-archive test1
2028 @end example
2029
2030
2031 @mansect see also
2032 @ifset isman
2033 @command{gpg}(1),
2034 @command{tar}(1),
2035 @end ifset
2036 @include see-also-note.texi