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