diff options
| author | Félix Sipma <felix.sipma@no-log.org> | 2016-03-07 15:01:45 +0100 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-03-07 12:14:16 -0400 |
| commit | 48ca5d1e423b5a3ac78d25c2252f7a45bacc7474 (patch) | |
| tree | 381c7c6b260fbd87a3578450acb17ec4cddca6dc /src | |
| parent | cef0ee73bb57980bb084025971734cb158842fdc (diff) | |
Network: escape interfaceDFile names
(cherry picked from commit 125135ea5d42d623346a385faf7ed404f8878891)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/Network.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Propellor/Property/Network.hs b/src/Propellor/Property/Network.hs index 1908bbb3..0d079899 100644 --- a/src/Propellor/Property/Network.hs +++ b/src/Propellor/Property/Network.hs @@ -45,7 +45,7 @@ dhcp iface = hasContent (interfaceDFile iface) -- -- If the interface file already exists, this property does nothing, -- no matter its content. --- +-- -- (ipv6 addresses are not included because it's assumed they come up -- automatically in most situations.) static :: Interface -> Property NoInfo @@ -96,8 +96,19 @@ interfacesFile :: FilePath interfacesFile = "/etc/network/interfaces" -- | A file in the interfaces.d directory. +-- /etc/network/interfaces.d/ files have to match -- ^[a-zA-Z0-9_-]+$ +-- see "man 5 interfaces" interfaceDFile :: Interface -> FilePath -interfaceDFile iface = "/etc/network/interfaces.d" </> iface +interfaceDFile i = interfaceDFile' (escapeInterfaceDName i) + +interfaceDFile' :: Interface -> FilePath +interfaceDFile' iface = "/etc/network/interfaces.d" </> iface + +escapeInterfaceDName :: Interface -> FilePath +escapeInterfaceDName "" = "" +escapeInterfaceDName (':' : xs) = escapeInterfaceDName xs +escapeInterfaceDName ('.' : xs) = escapeInterfaceDName xs +escapeInterfaceDName (x : xs) = x : escapeInterfaceDName xs -- | Ensures that files in the the interfaces.d directory are used. interfacesDEnabled :: Property NoInfo |
