/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 DBUS-API

  • 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:
27
27
    Removes a client
28
28
   
29
29
** Signals:
30
 
*** ClientNotFound(s: Fingerprint, s: Address)
31
 
    A client connected from Address using Fingerprint, but was
32
 
    rejected because it was not found in the server.  The fingerprint
 
30
*** ClientNotFound(s: KeyID, s: Address)
 
31
    A client connected from Address using KeyID, but was
 
32
    rejected because it was not found in the server.  The key ID
33
33
    is represented as a string of hexadecimal digits.  The address is
34
34
    an IPv4 or IPv6 address in its normal string format.
35
35
 
55
55
   
56
56
   | Name                    | Type | Access     | clients.conf        |
57
57
   |-------------------------+------+------------+---------------------|
58
 
   | ApprovedByDefault       | b    | Read/Write | approved_by_default |
59
58
   | ApprovalDelay (a)       | t    | Read/Write | approval_delay      |
60
59
   | ApprovalDuration (a)    | t    | Read/Write | approval_duration   |
61
60
   | ApprovalPending (b)     | b    | Read       | N/A                 |
 
61
   | ApprovedByDefault       | b    | Read/Write | approved_by_default |
62
62
   | Checker                 | s    | Read/Write | checker             |
63
63
   | CheckerRunning (c)      | b    | Read/Write | N/A                 |
64
64
   | Created (d)             | s    | Read       | N/A                 |
68
68
   | Fingerprint             | s    | Read       | fingerprint         |
69
69
   | Host                    | s    | Read/Write | host                |
70
70
   | Interval (a)            | t    | Read/Write | interval            |
 
71
   | KeyID                   | s    | Read       | key_id              |
71
72
   | LastApprovalRequest (g) | s    | Read       | N/A                 |
72
73
   | LastCheckedOK (h)       | s    | Read/Write | N/A                 |
73
74
   | LastCheckerStatus (i)   | n    | Read       | N/A                 |
130
131
 
131
132
* Copyright
132
133
 
133
 
    Copyright © 2010-2015 Teddy Hogeborn
134
 
    Copyright © 2010-2015 Björn Påhlsson
 
134
    Copyright © 2010-2019 Teddy Hogeborn
 
135
    Copyright © 2010-2019 Björn Påhlsson
135
136
  
136
137
** License:
137
 
   
138
 
   This program is free software: you can redistribute it and/or
139
 
   modify it under the terms of the GNU General Public License as
140
 
   published by the Free Software Foundation, either version 3 of the
141
 
   License, or (at your option) any later version.
142
 
 
143
 
   This program is distributed in the hope that it will be useful, but
 
138
 
 
139
   This file is part of Mandos.
 
140
 
 
141
   Mandos is free software: you can redistribute it and/or modify it
 
142
   under the terms of the GNU General Public License as published by
 
143
   the Free Software Foundation, either version 3 of the License, or
 
144
   (at your option) any later version.
 
145
 
 
146
   Mandos is distributed in the hope that it will be useful, but
144
147
   WITHOUT ANY WARRANTY; without even the implied warranty of
145
148
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
146
149
   General Public License for more details.
147
150
 
148
151
   You should have received a copy of the GNU General Public License
149
 
   along with this program.  If not, see
150
 
   <http://www.gnu.org/licenses/>.
 
152
   along with Mandos.  If not, see <http://www.gnu.org/licenses/>.
151
153
 
152
154
 
153
155
#+STARTUP: showall