/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
	"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY COMMANDNAME "mandos-client">
<!ENTITY TIMESTAMP "2019-02-10">
<!ENTITY % common SYSTEM "../common.ent">
%common;
]>

<refentry xmlns:xi="http://www.w3.org/2001/XInclude">
  <refentryinfo>
    <title>Mandos Manual</title>
    <!-- NWalsh’s docbook scripts use this to generate the footer: -->
    <productname>Mandos</productname>
    <productnumber>&version;</productnumber>
    <date>&TIMESTAMP;</date>
    <authorgroup>
      <author>
	<firstname>Björn</firstname>
	<surname>Påhlsson</surname>
	<address>
	  <email>belorn@recompile.se</email>
	</address>
      </author>
      <author>
	<firstname>Teddy</firstname>
	<surname>Hogeborn</surname>
	<address>
	  <email>teddy@recompile.se</email>
	</address>
      </author>
    </authorgroup>
    <copyright>
      <year>2008</year>
      <year>2009</year>
      <year>2010</year>
      <year>2011</year>
      <year>2012</year>
      <year>2013</year>
      <year>2014</year>
      <year>2015</year>
      <year>2016</year>
      <year>2017</year>
      <year>2018</year>
      <year>2019</year>
      <holder>Teddy Hogeborn</holder>
      <holder>Björn Påhlsson</holder>
    </copyright>
    <xi:include href="../legalnotice.xml"/>
  </refentryinfo>
  
  <refmeta>
    <refentrytitle>&COMMANDNAME;</refentrytitle>
    <manvolnum>8mandos</manvolnum>
  </refmeta>
  
  <refnamediv>
    <refname><command>&COMMANDNAME;</command></refname>
    <refpurpose>
      Client for <application>Mandos</application>
    </refpurpose>
  </refnamediv>
  
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <group>
	<arg choice="plain"><option>--connect
	<replaceable>ADDRESS</replaceable><literal>:</literal
	><replaceable>PORT</replaceable></option></arg>
	<arg choice="plain"><option>-c
	<replaceable>ADDRESS</replaceable><literal>:</literal
	><replaceable>PORT</replaceable></option></arg>
      </group>
      <sbr/>
      <group rep='repeat'>
	<arg choice="plain"><option>--interface
	<replaceable>NAME</replaceable><arg rep='repeat'
	>,<replaceable>NAME</replaceable></arg></option></arg>
	<arg choice="plain"><option>-i <replaceable>NAME</replaceable
	><arg rep='repeat'>,<replaceable>NAME</replaceable></arg
	></option></arg>
      </group>
      <sbr/>
      <group>
	<arg choice="plain"><option>--pubkey
	<replaceable>FILE</replaceable></option></arg>
	<arg choice="plain"><option>-p
	<replaceable>FILE</replaceable></option></arg>
      </group>
      <sbr/>
      <group>
	<arg choice="plain"><option>--seckey
	<replaceable>FILE</replaceable></option></arg>
	<arg choice="plain"><option>-s
	<replaceable>FILE</replaceable></option></arg>
      </group>
      <sbr/>
      <group>
	<arg choice="plain"><option>--tls-privkey
	<replaceable>FILE</replaceable></option></arg>
	<arg choice="plain"><option>-t
	<replaceable>FILE</replaceable></option></arg>
      </group>
      <sbr/>
      <group>
	<arg choice="plain"><option>--tls-pubkey
	<replaceable>FILE</replaceable></option></arg>
	<arg choice="plain"><option>-T
	<replaceable>FILE</replaceable></option></arg>
      </group>
      <sbr/>
      <arg>
	<option>--priority <replaceable>STRING</replaceable></option>
      </arg>
      <sbr/>
      <arg>
	<option>--dh-bits <replaceable>BITS</replaceable></option>
      </arg>
      <sbr/>
      <arg>
	<option>--dh-params <replaceable>FILE</replaceable></option>
      </arg>
      <sbr/>
      <arg>
	<option>--delay <replaceable>SECONDS</replaceable></option>
      </arg>
      <sbr/>
      <arg>
	<option>--retry <replaceable>SECONDS</replaceable></option>
      </arg>
      <sbr/>
      <arg>
	<option>--network-hook-dir
	<replaceable>DIR</replaceable></option>
      </arg>
      <sbr/>
      <arg>
	<option>--debug</option>
      </arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <group choice="req">
	<arg choice="plain"><option>--help</option></arg>
	<arg choice="plain"><option>-?</option></arg>
      </group>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice="plain"><option>--usage</option></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <group choice="req">
	<arg choice="plain"><option>--version</option></arg>
	<arg choice="plain"><option>-V</option></arg>
      </group>
    </cmdsynopsis>
  </refsynopsisdiv>
  
  <refsect1 id="description">
    <title>DESCRIPTION</title>
    <para>
      <command>&COMMANDNAME;</command> is a client program that
      communicates with <citerefentry><refentrytitle
      >mandos</refentrytitle><manvolnum>8</manvolnum></citerefentry>
      to get a password.  In slightly more detail, this client program
      brings up network interfaces, uses the interfaces’ IPv6
      link-local addresses to get network connectivity, uses Zeroconf
      to find servers on the local network, and communicates with
      servers using TLS with a raw public key to ensure authenticity
      and confidentiality.  This client program keeps running, trying
      all servers on the network, until it receives a satisfactory
      reply or a TERM signal.  After all servers have been tried, all
      servers are periodically retried.  If no servers are found it
      will wait indefinitely for new servers to appear.
    </para>
    <para>
      The network interfaces are selected like this: If any interfaces
      are specified using the <option>--interface</option> option,
      those interface are used.  Otherwise,
      <command>&COMMANDNAME;</command> will use all interfaces that
      are not loopback interfaces, are not point-to-point interfaces,
      are capable of broadcasting and do not have the NOARP flag (see
      <citerefentry><refentrytitle>netdevice</refentrytitle>
      <manvolnum>7</manvolnum></citerefentry>).  (If the
      <option>--connect</option> option is used, point-to-point
      interfaces and non-broadcast interfaces are accepted.)  If any
      used interfaces are not up and running, they are first taken up
      (and later taken down again on program exit).
    </para>
    <para>
      Before network interfaces are selected, all <quote>network
      hooks</quote> are run; see <xref linkend="network-hooks"/>.
    </para>
    <para>
      This program is not meant to be run directly; it is really meant
      to run as a plugin of the <application>Mandos</application>
      <citerefentry><refentrytitle>plugin-runner</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>, which runs in the
      initial <acronym>RAM</acronym> disk environment because it is
      specified as a <quote>keyscript</quote> in the <citerefentry>
      <refentrytitle>crypttab</refentrytitle><manvolnum>5</manvolnum>
      </citerefentry> file.
    </para>
  </refsect1>
  
  <refsect1 id="purpose">
    <title>PURPOSE</title>
    <para>
      The purpose of this is to enable <emphasis>remote and unattended
      rebooting</emphasis> of client host computer with an
      <emphasis>encrypted root file system</emphasis>.  See <xref
      linkend="overview"/> for details.
    </para>
  </refsect1>
  
  <refsect1 id="options">
    <title>OPTIONS</title>
    <para>
      This program is commonly not invoked from the command line; it
      is normally started by the <application>Mandos</application>
      plugin runner, see <citerefentry><refentrytitle
      >plugin-runner</refentrytitle><manvolnum>8mandos</manvolnum>
      </citerefentry>.  Any command line options this program accepts
      are therefore normally provided by the plugin runner, and not
      directly.
    </para>
    
    <variablelist>
      <varlistentry>
	<term><option>--connect=<replaceable
	>ADDRESS</replaceable><literal>:</literal><replaceable
	>PORT</replaceable></option></term>
	<term><option>-c
	<replaceable>ADDRESS</replaceable><literal>:</literal
	><replaceable>PORT</replaceable></option></term>
	<listitem>
	  <para>
	    Do not use Zeroconf to locate servers.  Connect directly
	    to only one specified <application>Mandos</application>
	    server.  Note that an IPv6 address has colon characters in
	    it, so the <emphasis>last</emphasis> colon character is
	    assumed to separate the address from the port number.
	  </para>
	  <para>
	    Normally, Zeroconf would be used to locate Mandos servers,
	    in which case this option would only be used when testing
	    and debugging.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--interface=<replaceable
	>NAME</replaceable><arg rep='repeat'>,<replaceable
	>NAME</replaceable></arg></option></term>
	<term><option>-i
	<replaceable>NAME</replaceable><arg rep='repeat'>,<replaceable
	>NAME</replaceable></arg></option></term>
	<listitem>
	  <para>
	    Comma separated list of network interfaces that will be
	    brought up and scanned for Mandos servers to connect to.
	    The default is the empty string, which will automatically
	    use all appropriate interfaces.
	  </para>
	  <para>
	    If the <option>--connect</option> option is used, and
	    exactly one interface name is specified (except
	    <quote><literal>none</literal></quote>), this specifies
	    the interface to use to connect to the address given.
	  </para>
	  <para>
	    Note that since this program will normally run in the
	    initial RAM disk environment, the interface must be an
	    interface which exists at that stage.  Thus, the interface
	    can normally not be a pseudo-interface such as
	    <quote>br0</quote> or <quote>tun0</quote>; such interfaces
	    will not exist until much later in the boot process, and
	    can not be used by this program, unless created by a
	    <quote>network hook</quote>  see <xref
	    linkend="network-hooks"/>.
	  </para>
	  <para>
	    <replaceable>NAME</replaceable> can be the string
	    <quote><literal>none</literal></quote>; this will make
	    <command>&COMMANDNAME;</command> only bring up interfaces
	    specified <emphasis>before</emphasis> this string.  This
	    is not recommended, and only meant for advanced users.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--pubkey=<replaceable
	>FILE</replaceable></option></term>
	<term><option>-p
	<replaceable>FILE</replaceable></option></term>
	<listitem>
	  <para>
	    OpenPGP public key file name.  The default name is
	    <quote><filename>/conf/conf.d/mandos/pubkey.txt</filename
	    ></quote>.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--seckey=<replaceable
	>FILE</replaceable></option></term>
	<term><option>-s
	<replaceable>FILE</replaceable></option></term>
	<listitem>
	  <para>
	    OpenPGP secret key file name.  The default name is
	    <quote><filename>/conf/conf.d/mandos/seckey.txt</filename
	    ></quote>.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--tls-pubkey=<replaceable
	>FILE</replaceable></option></term>
	<term><option>-T
	<replaceable>FILE</replaceable></option></term>
	<listitem>
	  <para>
	    TLS raw public key file name.  The default name is
	    <quote><filename>/conf/conf.d/mandos/tls-pubkey.pem</filename
	    ></quote>.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><option>--tls-privkey=<replaceable
	>FILE</replaceable></option></term>
	<term><option>-t
	<replaceable>FILE</replaceable></option></term>
	<listitem>
	  <para>
	    TLS secret key file name.  The default name is
	    <quote><filename>/conf/conf.d/mandos/tls-privkey.pem</filename
	    ></quote>.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><option>--priority=<replaceable
	>STRING</replaceable></option></term>
	<listitem>
	  <xi:include href="../mandos-options.xml"
		      xpointer="priority"/>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--dh-bits=<replaceable
	>BITS</replaceable></option></term>
	<listitem>
	  <para>
	    Sets the number of bits to use for the prime number in the
	    TLS Diffie-Hellman key exchange.  The default value is
	    selected automatically based on the GnuTLS security
	    profile set in its priority string.  Note that if the
	    <option>--dh-params</option> option is used, the values
	    from that file will be used instead.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--dh-params=<replaceable
	>FILE</replaceable></option></term>
	<listitem>
	  <para>
	    Specifies a PEM-encoded PKCS#3 file to read the parameters
	    needed by the TLS Diffie-Hellman key exchange from.  If
	    this option is not given, or if the file for some reason
	    could not be used, the parameters will be generated on
	    startup, which will take some time and processing power.
	    Those using servers running under time, power or processor
	    constraints may want to generate such a file in advance
	    and use this option.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><option>--delay=<replaceable
	>SECONDS</replaceable></option></term>
	<listitem>
	  <para>
	    After bringing a network interface up, the program waits
	    for the interface to arrive in a <quote>running</quote>
	    state before proceeding.  During this time, the kernel log
	    level will be lowered to reduce clutter on the system
	    console, alleviating any other plugins which might be
	    using the system console.  This option sets the upper
	    limit of seconds to wait.  The default is 2.5 seconds.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><option>--retry=<replaceable
	>SECONDS</replaceable></option></term>
	<listitem>
	  <para>
	    All Mandos servers are tried repeatedly until a password
	    is received.  This value specifies, in seconds, how long
	    between each successive try <emphasis>for the same
	    server</emphasis>.  The default is 10 seconds.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term><option>--network-hook-dir=<replaceable
	>DIR</replaceable></option></term>
	<listitem>
	  <para>
	    Network hook directory.  The default directory is
	    <quote><filename class="directory"
	    >/lib/mandos/network-hooks.d</filename></quote>.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--debug</option></term>
	<listitem>
	  <para>
	    Enable debug mode.  This will enable a lot of output to
	    standard error about what the program is doing.  The
	    program will still perform all other functions normally.
	  </para>
	  <para>
	    It will also enable debug mode in the Avahi and GnuTLS
	    libraries, making them print large amounts of debugging
	    output.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--help</option></term>
	<term><option>-?</option></term>
	<listitem>
	  <para>
	    Gives a help message about options and their meanings.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--usage</option></term>
	<listitem>
	  <para>
	    Gives a short usage message.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--version</option></term>
	<term><option>-V</option></term>
	<listitem>
	  <para>
	    Prints the program version.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  
  <refsect1 id="overview">
    <title>OVERVIEW</title>
    <xi:include href="../overview.xml"/>
    <para>
      This program is the client part.  It is a plugin started by
      <citerefentry><refentrytitle>plugin-runner</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry> which will run in
      an initial <acronym>RAM</acronym> disk environment.
    </para>
    <para>
      This program could, theoretically, be used as a keyscript in
      <filename>/etc/crypttab</filename>, but it would then be
      impossible to enter a password for the encrypted root disk at
      the console, since this program does not read from the console
      at all.  This is why a separate plugin runner (<citerefentry>
      <refentrytitle>plugin-runner</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>) is used to run
      both this program and others in in parallel,
      <emphasis>one</emphasis> of which (<citerefentry>
      <refentrytitle>password-prompt</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>) will prompt for
      passwords on the system console.
    </para>
  </refsect1>
  
  <refsect1 id="exit_status">
    <title>EXIT STATUS</title>
    <para>
      This program will exit with a successful (zero) exit status if a
      server could be found and the password received from it could be
      successfully decrypted and output on standard output.  The
      program will exit with a non-zero exit status only if a critical
      error occurs.  Otherwise, it will forever connect to any
      discovered <application>Mandos</application> servers, trying to
      get a decryptable password and print it.
    </para>
  </refsect1>
  
  <refsect1 id="environment">
    <title>ENVIRONMENT</title>
    <variablelist>
      <varlistentry>
	<term><envar>MANDOSPLUGINHELPERDIR</envar></term>
	<listitem>
	  <para>
	    This environment variable will be assumed to contain the
	    directory containing any helper executables.  The use and
	    nature of these helper executables, if any, is
	    purposefully not documented.
	</para>
	</listitem>
      </varlistentry>
    </variablelist>
    <para>
      This program does not use any other environment variables, not
      even the ones provided by <citerefentry><refentrytitle
      >cryptsetup</refentrytitle><manvolnum>8</manvolnum>
    </citerefentry>.
    </para>
  </refsect1>
  
  <refsect1 id="network-hooks">
    <title>NETWORK HOOKS</title>
    <para>
      If a network interface like a bridge or tunnel is required to
      find a Mandos server, this requires the interface to be up and
      running before <command>&COMMANDNAME;</command> starts looking
      for Mandos servers.  This can be accomplished by creating a
      <quote>network hook</quote> program, and placing it in a special
      directory.
    </para>
    <para>
      Before the network is used (and again before program exit), any
      runnable programs found in the network hook directory are run
      with the argument <quote><literal>start</literal></quote> or
      <quote><literal>stop</literal></quote>.  This should bring up or
      down, respectively, any network interface which
      <command>&COMMANDNAME;</command> should use.
    </para>
    <refsect2 id="hook-requirements">
      <title>REQUIREMENTS</title>
      <para>
	A network hook must be an executable file, and its name must
	consist entirely of upper and lower case letters, digits,
	underscores, periods, and hyphens.
      </para>
      <para>
	A network hook will receive one argument, which can be one of
	the following:
      </para>
      <variablelist>
	<varlistentry>
	  <term><literal>start</literal></term>
	  <listitem>
	    <para>
	      This should make the network hook create (if necessary)
	      and bring up a network interface.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>stop</literal></term>
	  <listitem>
	    <para>
	      This should make the network hook take down a network
	      interface, and delete it if it did not exist previously.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>files</literal></term>
	  <listitem>
	    <para>
	      This should make the network hook print, <emphasis>one
	      file per line</emphasis>, all the files needed for it to
	      run.  (These files will be copied into the initial RAM
	      filesystem.)  Typical use is for a network hook which is
	      a shell script to print its needed binaries.
	    </para>
	    <para>
	      It is not necessary to print any non-executable files
	      already in the network hook directory, these will be
	      copied implicitly if they otherwise satisfy the name
	      requirements.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>modules</literal></term>
	  <listitem>
	    <para>
	      This should make the network hook print, <emphasis>on
	      separate lines</emphasis>, all the kernel modules needed
	      for it to run.  (These modules will be copied into the
	      initial RAM filesystem.)  For instance, a tunnel
	      interface needs the
	      <quote><literal>tun</literal></quote> module.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
      <para>
	The network hook will be provided with a number of environment
	variables:
      </para>
      <variablelist>
	<varlistentry>
	  <term><envar>MANDOSNETHOOKDIR</envar></term>
	  <listitem>
	    <para>
	      The network hook directory, specified to
	      <command>&COMMANDNAME;</command> by the
	      <option>--network-hook-dir</option> option.  Note: this
	      should <emphasis>always</emphasis> be used by the
	      network hook to refer to itself or any files in the hook
	      directory it may require.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><envar>DEVICE</envar></term>
	  <listitem>
	    <para>
	      The network interfaces, as specified to
	      <command>&COMMANDNAME;</command> by the
	      <option>--interface</option> option, combined to one
	      string and separated by commas.  If this is set, and
	      does not contain the interface a hook will bring up,
	      there is no reason for a hook to continue.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><envar>MODE</envar></term>
	  <listitem>
	    <para>
	      This will be the same as the first argument;
	      i.e. <quote><literal>start</literal></quote>,
	      <quote><literal>stop</literal></quote>,
	      <quote><literal>files</literal></quote>, or
	      <quote><literal>modules</literal></quote>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><envar>VERBOSITY</envar></term>
	  <listitem>
	    <para>
	      This will be the <quote><literal>1</literal></quote> if
	      the <option>--debug</option> option is passed to
	      <command>&COMMANDNAME;</command>, otherwise
	      <quote><literal>0</literal></quote>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><envar>DELAY</envar></term>
	  <listitem>
	    <para>
	      This will be the same as the <option>--delay</option>
	      option passed to <command>&COMMANDNAME;</command>.  Is
	      only set if <envar>MODE</envar> is
	      <quote><literal>start</literal></quote> or
	      <quote><literal>stop</literal></quote>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><envar>CONNECT</envar></term>
	  <listitem>
	    <para>
	      This will be the same as the <option>--connect</option>
	      option passed to <command>&COMMANDNAME;</command>.  Is
	      only set if <option>--connect</option> is passed and
	      <envar>MODE</envar> is
	      <quote><literal>start</literal></quote> or
	      <quote><literal>stop</literal></quote>.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
      <para>
	A hook may not read from standard input, and should be
	restrictive in printing to standard output or standard error
	unless <varname>VERBOSITY</varname> is
	<quote><literal>1</literal></quote>.
      </para>
    </refsect2>
  </refsect1>
  
  <refsect1 id="files">
    <title>FILES</title>
    <variablelist>
      <varlistentry>
	<term><filename>/conf/conf.d/mandos/pubkey.txt</filename
	></term>
	<term><filename>/conf/conf.d/mandos/seckey.txt</filename
	></term>
	<listitem>
	  <para>
	    OpenPGP public and private key files, in <quote>ASCII
	    Armor</quote> format.  These are the default file names,
	    they can be changed with the <option>--pubkey</option> and
	    <option>--seckey</option> options.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/conf/conf.d/mandos/tls-pubkey.pem</filename
	></term>
	<term><filename>/conf/conf.d/mandos/tls-privkey.pem</filename
	></term>
	<listitem>
	  <para>
	    Public and private raw key files, in <quote>PEM</quote>
	    format.  These are the default file names, they can be
	    changed with the <option>--tls-pubkey</option> and
	    <option>--tls-privkey</option> options.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename
	class="directory">/lib/mandos/network-hooks.d</filename></term>
	<listitem>
	  <para>
	    Directory where network hooks are located.  Change this
	    with the <option>--network-hook-dir</option> option.  See
	    <xref linkend="network-hooks"/>.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  
  <refsect1 id="bugs">
    <title>BUGS</title>
    <xi:include href="../bugs.xml"/>
  </refsect1>
  
  <refsect1 id="example">
    <title>EXAMPLE</title>
    <para>
      Note that normally, command line options will not be given
      directly, but via options for the Mandos <citerefentry
      ><refentrytitle>plugin-runner</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>.
    </para>
    <informalexample>
      <para>
	Normal invocation needs no options, if the network interfaces
	can be automatically determined:
      </para>
      <para>
	<userinput>&COMMANDNAME;</userinput>
      </para>
    </informalexample>
    <informalexample>
      <para>
	Search for Mandos servers (and connect to them) using one
	specific interface:
      </para>
      <para>
	<!-- do not wrap this line -->
	<userinput>&COMMANDNAME; --interface eth1</userinput>
      </para>
    </informalexample>
    <informalexample>
      <para>
	Run in debug mode, and use custom keys:
      </para>
      <para>

<!-- do not wrap this line -->
<userinput>&COMMANDNAME; --debug --pubkey keydir/pubkey.txt --seckey keydir/seckey.txt --tls-pubkey keydir/tls-pubkey.pem --tls-privkey keydir/tls-privkey.pem</userinput>

      </para>
    </informalexample>
    <informalexample>
      <para>
	Run in debug mode, with custom keys, and do not use Zeroconf
	to locate a server; connect directly to the IPv6 link-local
	address <quote><systemitem class="ipaddress"
	>fe80::aede:48ff:fe71:f6f2</systemitem></quote>, port 4711,
	using interface eth2:
      </para>
      <para>

<!-- do not wrap this line -->
<userinput>&COMMANDNAME; --debug --pubkey keydir/pubkey.txt --seckey keydir/seckey.txt --tls-pubkey keydir/tls-pubkey.pem --tls-privkey keydir/tls-privkey.pem --connect fe80::aede:48ff:fe71:f6f2:4711 --interface eth2</userinput>

      </para>
    </informalexample>
  </refsect1>
  
  <refsect1 id="security">
    <title>SECURITY</title>
    <para>
      This program is set-uid to root, but will switch back to the
      original (and presumably non-privileged) user and group after
      bringing up the network interface.
    </para>
    <para>
      To use this program for its intended purpose (see <xref
      linkend="purpose"/>), the password for the root file system will
      have to be given out to be stored in a server computer, after
      having been encrypted using an OpenPGP key.  This encrypted data
      which will be stored in a server can only be decrypted by the
      OpenPGP key, and the data will only be given out to those
      clients who can prove they actually have that key.  This key,
      however, is stored unencrypted on the client side in its initial
      <acronym>RAM</acronym> disk image file system.  This is normally
      readable by all, but this is normally fixed during installation
      of this program; file permissions are set so that no-one is able
      to read that file.
    </para>
    <para>
      The only remaining weak point is that someone with physical
      access to the client hard drive might turn off the client
      computer, read the OpenPGP and TLS keys directly from the hard
      drive, and communicate with the server.  To safeguard against
      this, the server is supposed to notice the client disappearing
      and stop giving out the encrypted data.  Therefore, it is
      important to set the timeout and checker interval values tightly
      on the server.  See <citerefentry><refentrytitle
      >mandos</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
    </para>
    <para>
      It will also help if the checker program on the server is
      configured to request something from the client which can not be
      spoofed by someone else on the network, like SSH server key
      fingerprints, and unlike unencrypted <acronym>ICMP</acronym>
      echo (<quote>ping</quote>) replies.
    </para>
    <para>
      <emphasis>Note</emphasis>: This makes it completely insecure to
      have <application >Mandos</application> clients which dual-boot
      to another operating system which is <emphasis>not</emphasis>
      trusted to keep the initial <acronym>RAM</acronym> disk image
      confidential.
    </para>
  </refsect1>
  
  <refsect1 id="see_also">
    <title>SEE ALSO</title>
    <para>
      <citerefentry><refentrytitle>intro</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>cryptsetup</refentrytitle>
      <manvolnum>8</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>crypttab</refentrytitle>
      <manvolnum>5</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>mandos</refentrytitle>
      <manvolnum>8</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>password-prompt</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>plugin-runner</refentrytitle>
      <manvolnum>8mandos</manvolnum></citerefentry>
    </para>
    <variablelist>
      <varlistentry>
	<term>
	  <ulink url="http://www.zeroconf.org/">Zeroconf</ulink>
	</term>
	<listitem>
	  <para>
	    Zeroconf is the network protocol standard used for finding
	    Mandos servers on the local network.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <ulink url="http://www.avahi.org/">Avahi</ulink>
	</term>
      <listitem>
	<para>
	  Avahi is the library this program calls to find Zeroconf
	  services.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <ulink url="https://www.gnutls.org/">GnuTLS</ulink>
	</term>
      <listitem>
	<para>
	  GnuTLS is the library this client uses to implement TLS for
	  communicating securely with the server, and at the same time
	  send the public key to the server.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <ulink url="https://www.gnupg.org/related_software/gpgme/"
		 >GPGME</ulink>
	</term>
	<listitem>
	  <para>
	    GPGME is the library used to decrypt the OpenPGP data sent
	    by the server.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 4291: <citetitle>IP Version 6 Addressing
	  Architecture</citetitle>
	</term>
	<listitem>
	  <variablelist>
	    <varlistentry>
	      <term>Section 2.2: <citetitle>Text Representation of
	      Addresses</citetitle></term>
	      <listitem><para/></listitem>
	    </varlistentry>
	    <varlistentry>
	      <term>Section 2.5.5.2: <citetitle>IPv4-Mapped IPv6
	      Address</citetitle></term>
	      <listitem><para/></listitem>
	    </varlistentry>
	    <varlistentry>
	    <term>Section 2.5.6, <citetitle>Link-Local IPv6 Unicast
	    Addresses</citetitle></term>
	    <listitem>
	      <para>
		This client uses IPv6 link-local addresses, which are
		immediately usable since a link-local addresses is
		automatically assigned to a network interface when it
		is brought up.
	      </para>
	    </listitem>
	    </varlistentry>
	  </variablelist>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 5246: <citetitle>The Transport Layer Security (TLS)
	  Protocol Version 1.2</citetitle>
	</term>
      <listitem>
	<para>
	  TLS 1.2 is the protocol implemented by GnuTLS.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 4880: <citetitle>OpenPGP Message Format</citetitle>
	</term>
      <listitem>
	<para>
	  The data received from the server is binary encrypted
	  OpenPGP data.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 7250: <citetitle>Using Raw Public Keys in Transport
	  Layer Security (TLS) and Datagram Transport Layer Security
	  (DTLS)</citetitle>
	</term>
      <listitem>
	<para>
	  This is implemented by GnuTLS in version 3.6.6 and is, if
	  present, used by this program so that raw public keys can be
	  used.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 6091: <citetitle>Using OpenPGP Keys for Transport Layer
	  Security</citetitle>
	</term>
      <listitem>
	<para>
	  This is implemented by GnuTLS before version 3.6.0 and is,
	  if present, used by this program so that OpenPGP keys can be
	  used.
	</para>
      </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
</refentry>

<!-- Local Variables: -->
<!-- time-stamp-start: "<!ENTITY TIMESTAMP [\"']" -->
<!-- time-stamp-end: "[\"']>" -->
<!-- time-stamp-format: "%:y-%02m-%02d" -->
<!-- End: -->