/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/password-prompt.xml

  • Committer: teddy at recompile
  • Date: 2020-04-05 21:30:59 UTC
  • Revision ID: teddy@recompile.se-20200405213059-fb2a61ckqynrmatk
Fix file descriptor leak in mandos-client

When the local network has Mandos servers announcing themselves using
real, globally reachable, IPv6 addresses (i.e. not link-local
addresses), but there is no router on the local network providing IPv6
RA (Router Advertisement) packets, the client cannot reach the server
by normal means, since the client only has a link-local IPv6 address,
and has no usable route to reach the server's global IPv6 address.
(This is not a common situation, and usually only happens when the
router itself reboots and runs a Mandos client, since it cannot then
give RA packets to itself.)  The client code has a solution for
this, which consists of adding a temporary local route to reach the
address of the server during communication, and removing this
temporary route afterwards.

This solution with a temporary route works, but has a file descriptor
leak; it leaks one file descriptor for each addition and for each
removal of a route.  If one server requiring an added route is present
on the network, but no servers gives a password, making the client
retry after the default ten seconds, and we furthermore assume a
default 1024 open files limit, the client runs out of file descriptors
after about 90 minutes, after which time the client process will be
useless and fail to retrieve any passwords, necessitating manual
password entry via the keyboard.

Fix this by eliminating the file descriptor leak in the client.

* plugins.d/mandos-client.c (add_delete_local_route): Do
  close(devnull) also in parent process, also if fork() fails, and on
  any failure in child process.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version='1.0' encoding='UTF-8'?>
2
 
<?xml-stylesheet type="text/xsl"
3
 
        href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
 
1
<?xml version="1.0" encoding="UTF-8"?>
4
2
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
5
3
        "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
6
 
<!ENTITY VERSION "1.0">
7
4
<!ENTITY COMMANDNAME "password-prompt">
 
5
<!ENTITY TIMESTAMP "2019-07-27">
 
6
<!ENTITY % common SYSTEM "../common.ent">
 
7
%common;
8
8
]>
9
9
 
10
 
<refentry>
 
10
<refentry xmlns:xi="http://www.w3.org/2001/XInclude">
11
11
  <refentryinfo>
12
 
    <title>&COMMANDNAME;</title>
13
 
    <!-- NWalsh's docbook scripts use this to generate the footer: -->
14
 
    <productname>&COMMANDNAME;</productname>
15
 
    <productnumber>&VERSION;</productnumber>
 
12
    <title>Mandos Manual</title>
 
13
    <!-- NWalsh’s docbook scripts use this to generate the footer: -->
 
14
    <productname>Mandos</productname>
 
15
    <productnumber>&version;</productnumber>
 
16
    <date>&TIMESTAMP;</date>
16
17
    <authorgroup>
17
18
      <author>
18
19
        <firstname>Björn</firstname>
19
20
        <surname>Påhlsson</surname>
20
21
        <address>
21
 
          <email>belorn@fukt.bsnet.se</email>
 
22
          <email>belorn@recompile.se</email>
22
23
        </address>
23
24
      </author>
24
25
      <author>
25
26
        <firstname>Teddy</firstname>
26
27
        <surname>Hogeborn</surname>
27
28
        <address>
28
 
          <email>teddy@fukt.bsnet.se</email>
 
29
          <email>teddy@recompile.se</email>
29
30
        </address>
30
31
      </author>
31
32
    </authorgroup>
32
33
    <copyright>
33
34
      <year>2008</year>
34
 
      <holder>Teddy Hogeborn &amp; Björn Påhlsson</holder>
 
35
      <year>2009</year>
 
36
      <year>2010</year>
 
37
      <year>2011</year>
 
38
      <year>2012</year>
 
39
      <year>2013</year>
 
40
      <year>2014</year>
 
41
      <year>2015</year>
 
42
      <year>2016</year>
 
43
      <year>2017</year>
 
44
      <year>2018</year>
 
45
      <year>2019</year>
 
46
      <holder>Teddy Hogeborn</holder>
 
47
      <holder>Björn Påhlsson</holder>
35
48
    </copyright>
36
 
    <legalnotice>
37
 
      <para>
38
 
        This manual page is free software: you can redistribute it
39
 
        and/or modify it under the terms of the GNU General Public
40
 
        License as published by the Free Software Foundation,
41
 
        either version 3 of the License, or (at your option) any
42
 
        later version.
43
 
      </para>
44
 
 
45
 
      <para>
46
 
        This manual page is distributed in the hope that it will
47
 
        be useful, but WITHOUT ANY WARRANTY; without even the
48
 
        implied warranty of MERCHANTABILITY or FITNESS FOR A
49
 
        PARTICULAR PURPOSE.  See the GNU General Public License
50
 
        for more details.
51
 
      </para>
52
 
 
53
 
      <para>
54
 
        You should have received a copy of the GNU General Public
55
 
        License along with this program; If not, see
56
 
        <ulink url="http://www.gnu.org/licenses/"/>.
57
 
      </para>
58
 
    </legalnotice>
 
49
    <xi:include href="../legalnotice.xml"/>
59
50
  </refentryinfo>
60
 
 
 
51
  
61
52
  <refmeta>
62
53
    <refentrytitle>&COMMANDNAME;</refentrytitle>
63
54
    <manvolnum>8mandos</manvolnum>
65
56
  
66
57
  <refnamediv>
67
58
    <refname><command>&COMMANDNAME;</command></refname>
68
 
    <refpurpose>
69
 
      Passprompt for luks during boot sequence
70
 
    </refpurpose>
 
59
    <refpurpose>Prompt for a password and output it.</refpurpose>
71
60
  </refnamediv>
72
61
  
73
62
  <refsynopsisdiv>
74
63
    <cmdsynopsis>
75
64
      <command>&COMMANDNAME;</command>
76
 
      <arg choice='opt'>--prefix<arg choice='plain'>PREFIX</arg></arg>
77
 
      <arg choice='opt'>--debug</arg>
78
 
    </cmdsynopsis>
79
 
    <cmdsynopsis>
80
 
      <command>&COMMANDNAME;</command>
81
 
      <arg choice='plain'>--help</arg>
82
 
    </cmdsynopsis>
83
 
    <cmdsynopsis>
84
 
      <command>&COMMANDNAME;</command>
85
 
      <arg choice='plain'>--usage</arg>
86
 
    </cmdsynopsis>
87
 
    <cmdsynopsis>
88
 
      <command>&COMMANDNAME;</command>
89
 
      <arg choice='plain'>--version</arg>
90
 
    </cmdsynopsis>    
 
65
      <group choice="opt">
 
66
        <arg choice="plain"><option>--prefix <replaceable
 
67
        >PREFIX</replaceable></option></arg>
 
68
        <arg choice="plain"><option>-p </option><replaceable
 
69
        >PREFIX</replaceable></arg>
 
70
      </group>
 
71
      <sbr/>
 
72
      <arg choice="opt">
 
73
        <option>--prompt <replaceable>PROMPT</replaceable></option>
 
74
      </arg>
 
75
      <arg choice="opt"><option>--debug</option></arg>
 
76
    </cmdsynopsis>
 
77
    <cmdsynopsis>
 
78
      <command>&COMMANDNAME;</command>
 
79
      <group choice="req">
 
80
        <arg choice="plain"><option>--help</option></arg>
 
81
        <arg choice="plain"><option>-?</option></arg>
 
82
      </group>
 
83
    </cmdsynopsis>
 
84
    <cmdsynopsis>
 
85
      <command>&COMMANDNAME;</command>
 
86
      <arg choice="plain"><option>--usage</option></arg>
 
87
    </cmdsynopsis>
 
88
    <cmdsynopsis>
 
89
      <command>&COMMANDNAME;</command>
 
90
      <group choice="req">
 
91
        <arg choice="plain"><option>--version</option></arg>
 
92
        <arg choice="plain"><option>-V</option></arg>
 
93
      </group>
 
94
    </cmdsynopsis>
91
95
  </refsynopsisdiv>
92
 
 
 
96
  
93
97
  <refsect1 id="description">
94
98
    <title>DESCRIPTION</title>
95
99
    <para>
96
 
      <command>&COMMANDNAME;</command> is a terminal program that ask for
97
 
      passwords during boot sequence. It is a plugin to
98
 
      <firstterm>mandos</firstterm>, and is used as a fallback and
99
 
      alternative to retriving passwords from a mandos server. During
100
 
      boot sequence the user is prompted for the disk password, and
101
 
      when a password is given it then gets forwarded to
102
 
      <acronym>LUKS</acronym>.
103
 
    </para>
104
 
 
105
 
    <variablelist>
106
 
      <varlistentry>
107
 
        <term><literal>-p</literal>, <literal>--prefix=<replaceable>PREFIX
108
 
        </replaceable></literal></term>
109
 
        <listitem>
110
 
          <para>
111
 
            Prefix used before the passprompt
112
 
          </para>
113
 
        </listitem>
114
 
      </varlistentry>
115
 
      
116
 
      <varlistentry>
117
 
        <term><literal>--debug</literal></term>
118
 
        <listitem>
119
 
          <para>
120
 
            Debug mode
121
 
          </para>
122
 
        </listitem>
123
 
      </varlistentry>
124
 
      
125
 
      <varlistentry>
126
 
        <term><literal>-?</literal>, <literal>--help</literal></term>
127
 
        <listitem>
128
 
          <para>
129
 
            Gives a help message
130
 
          </para>
131
 
        </listitem>
132
 
      </varlistentry>
133
 
      
134
 
      <varlistentry>
135
 
        <term><literal>--usage</literal></term>
136
 
        <listitem>
137
 
          <para>
138
 
            Gives a short usage message
139
 
          </para>
140
 
        </listitem>
141
 
      </varlistentry>
142
 
 
143
 
      <varlistentry>
144
 
        <term><literal>-V</literal>, <literal>--version</literal></term>
145
 
        <listitem>
146
 
          <para>
147
 
            Prints the program version
148
 
          </para>
149
 
        </listitem>
150
 
      </varlistentry>            
151
 
    </variablelist>
 
100
      All <command>&COMMANDNAME;</command> does is prompt for a
 
101
      password and output any given password to standard output.
 
102
    </para>
 
103
    <para>
 
104
      This program is not very useful on its own.  This program is
 
105
      really meant to run as a plugin in the <application
 
106
      >Mandos</application> client-side system, where it is used as a
 
107
      fallback and alternative to retrieving passwords from a
 
108
      <application >Mandos</application> server.
 
109
    </para>
 
110
    <para>
 
111
      This program is little more than a <citerefentry><refentrytitle
 
112
      >getpass</refentrytitle><manvolnum>3</manvolnum></citerefentry>
 
113
      wrapper, although actual use of that function is not guaranteed
 
114
      or implied.
 
115
    </para>
 
116
    <para>
 
117
      This program tries to detect if a Plymouth daemon
 
118
      (<citerefentry><refentrytitle
 
119
      >plymouthd</refentrytitle><manvolnum>8</manvolnum></citerefentry>)
 
120
      is running, by looking for a
 
121
      <filename>/run/plymouth/pid</filename> file or a process named
 
122
      <quote><literal>plymouthd</literal></quote>.  If it is detected,
 
123
      this process will immediately exit without doing anything.
 
124
    </para>
 
125
  </refsect1>
 
126
  
 
127
  <refsect1 id="options">
 
128
    <title>OPTIONS</title>
 
129
    <para>
 
130
      This program is commonly not invoked from the command line; it
 
131
      is normally started by the <application>Mandos</application>
 
132
      plugin runner, see <citerefentry><refentrytitle
 
133
      >plugin-runner</refentrytitle><manvolnum>8mandos</manvolnum>
 
134
      </citerefentry>.  Any command line options this program accepts
 
135
      are therefore normally provided by the plugin runner, and not
 
136
      directly.
 
137
    </para>
 
138
    
 
139
    <variablelist>
 
140
      <varlistentry>
 
141
        <term><option>--prefix=<replaceable
 
142
        >PREFIX</replaceable></option></term>
 
143
        <term><option>-p
 
144
        <replaceable>PREFIX</replaceable></option></term>
 
145
        <listitem>
 
146
          <para>
 
147
            Prefix string shown before the password prompt.
 
148
          </para>
 
149
        </listitem>
 
150
      </varlistentry>
 
151
      
 
152
      <varlistentry>
 
153
        <term><option>--prompt=<replaceable
 
154
        >PROMPT</replaceable></option></term>
 
155
        <listitem>
 
156
          <para>
 
157
            The password prompt.  Using this option will make this
 
158
            program ignore the <envar>CRYPTTAB_SOURCE</envar> and
 
159
            <envar>CRYPTTAB_NAME</envar> environment variables.
 
160
          </para>
 
161
        </listitem>
 
162
      </varlistentry>
 
163
      
 
164
      <varlistentry>
 
165
        <term><option>--debug</option></term>
 
166
        <listitem>
 
167
          <para>
 
168
            Enable debug mode.  This will enable a lot of output to
 
169
            standard error about what the program is doing.  The
 
170
            program will still perform all other functions normally.
 
171
          </para>
 
172
        </listitem>
 
173
      </varlistentry>
 
174
      
 
175
      <varlistentry>
 
176
        <term><option>--help</option></term>
 
177
        <term><option>-?</option></term>
 
178
        <listitem>
 
179
          <para>
 
180
            Gives a help message about options and their meanings.
 
181
          </para>
 
182
        </listitem>
 
183
      </varlistentry>
 
184
      
 
185
      <varlistentry>
 
186
        <term><option>--usage</option></term>
 
187
        <listitem>
 
188
          <para>
 
189
            Gives a short usage message.
 
190
          </para>
 
191
        </listitem>
 
192
      </varlistentry>
 
193
      
 
194
      <varlistentry>
 
195
        <term><option>--version</option></term>
 
196
        <term><option>-V</option></term>
 
197
        <listitem>
 
198
          <para>
 
199
            Prints the program version.
 
200
          </para>
 
201
        </listitem>
 
202
      </varlistentry>
 
203
    </variablelist>
 
204
  </refsect1>
 
205
  
 
206
  <refsect1 id="exit_status">
 
207
    <title>EXIT STATUS</title>
 
208
    <para>
 
209
      If exit status is 0, the output from the program is the password
 
210
      as it was read.  Otherwise, if exit status is other than 0, the
 
211
      program has encountered an error, and any output so far could be
 
212
      corrupt and/or truncated, and should therefore be ignored.
 
213
    </para>
 
214
  </refsect1>
 
215
  
 
216
  <refsect1 id="environment">
 
217
    <title>ENVIRONMENT</title>
 
218
    <variablelist>
 
219
      <varlistentry>
 
220
        <term><envar>CRYPTTAB_SOURCE</envar></term>
 
221
        <term><envar>CRYPTTAB_NAME</envar></term>
 
222
        <listitem>
 
223
          <para>
 
224
            If set, and if the <option>--prompt</option> option is not
 
225
            used, these environment variables will be assumed to
 
226
            contain the source device name and the target device
 
227
            mapper name, respectively, and will be shown as part of
 
228
            the prompt.
 
229
        </para>
 
230
        <para>
 
231
          These variables will normally be inherited from
 
232
          <citerefentry><refentrytitle>plugin-runner</refentrytitle>
 
233
          <manvolnum>8mandos</manvolnum></citerefentry>, which might
 
234
          have in turn inherited them from its calling process.
 
235
        </para>
 
236
        <para>
 
237
          This behavior is meant to exactly mirror the behavior of
 
238
          <command>askpass</command>, the default password prompter
 
239
          from initramfs-tools.
 
240
        </para>
 
241
        </listitem>
 
242
      </varlistentry>
 
243
    </variablelist>
 
244
  </refsect1>
 
245
  
 
246
  <refsect1 id="bugs">
 
247
    <title>BUGS</title>
 
248
    <xi:include href="../bugs.xml"/>
 
249
  </refsect1>
 
250
  
 
251
  <refsect1 id="example">
 
252
    <title>EXAMPLE</title>
 
253
    <para>
 
254
      Note that normally, command line options will not be given
 
255
      directly, but via options for the Mandos <citerefentry
 
256
      ><refentrytitle>plugin-runner</refentrytitle>
 
257
      <manvolnum>8mandos</manvolnum></citerefentry>.
 
258
    </para>
 
259
    <informalexample>
 
260
      <para>
 
261
        Normal invocation needs no options:
 
262
      </para>
 
263
      <para>
 
264
        <userinput>&COMMANDNAME;</userinput>
 
265
      </para>
 
266
    </informalexample>
 
267
    <informalexample>
 
268
      <para>
 
269
        Show a prefix before the prompt; in this case, a host name.
 
270
        It might be useful to be reminded of which host needs a
 
271
        password, in case of <acronym>KVM</acronym> switches, etc.
 
272
      </para>
 
273
      <para>
 
274
 
 
275
<!-- do not wrap this line -->
 
276
<userinput>&COMMANDNAME; --prefix=host.example.org:</userinput>
 
277
 
 
278
      </para>
 
279
    </informalexample>
 
280
    <informalexample>
 
281
      <para>
 
282
        Run in debug mode.
 
283
      </para>
 
284
      <para>
 
285
        <!-- do not wrap this line -->
 
286
        <userinput>&COMMANDNAME; --debug</userinput>
 
287
      </para>
 
288
    </informalexample>
 
289
  </refsect1>
 
290
  
 
291
  <refsect1 id="security">
 
292
    <title>SECURITY</title>
 
293
    <para>
 
294
      On its own, this program is very simple, and does not exactly
 
295
      present any security risks.  The one thing that could be
 
296
      considered worthy of note is this: This program is meant to be
 
297
      run by <citerefentry><refentrytitle
 
298
      >plugin-runner</refentrytitle><manvolnum>8mandos</manvolnum>
 
299
      </citerefentry>, and will, when run standalone, outside, in a
 
300
      normal environment, immediately output on its standard output
 
301
      any presumably secret password it just received.  Therefore,
 
302
      when running this program standalone (which should never
 
303
      normally be done), take care not to type in any real secret
 
304
      password by force of habit, since it would then immediately be
 
305
      shown as output.
 
306
    </para>
 
307
    <para>
 
308
      To further alleviate any risk of being locked out of a system,
 
309
      the <citerefentry><refentrytitle>plugin-runner</refentrytitle>
 
310
      <manvolnum>8mandos</manvolnum></citerefentry> has a fallback
 
311
      mode which does the same thing as this program, only with less
 
312
      features.
 
313
    </para>
 
314
  </refsect1>
 
315
  
 
316
  <refsect1 id="see_also">
 
317
    <title>SEE ALSO</title>
 
318
    <para>
 
319
      <citerefentry><refentrytitle>intro</refentrytitle>
 
320
      <manvolnum>8mandos</manvolnum></citerefentry>,
 
321
      <citerefentry><refentrytitle>mandos-client</refentrytitle>
 
322
      <manvolnum>8mandos</manvolnum></citerefentry>,
 
323
      <citerefentry><refentrytitle>plugin-runner</refentrytitle>
 
324
      <manvolnum>8mandos</manvolnum></citerefentry>,
 
325
      <citerefentry><refentrytitle>plymouthd</refentrytitle>
 
326
      <manvolnum>8</manvolnum></citerefentry>
 
327
    </para>
152
328
  </refsect1>
153
329
</refentry>
 
330
<!-- Local Variables: -->
 
331
<!-- time-stamp-start: "<!ENTITY TIMESTAMP [\"']" -->
 
332
<!-- time-stamp-end: "[\"']>" -->
 
333
<!-- time-stamp-format: "%:y-%02m-%02d" -->
 
334
<!-- End: -->