diff options
| -rw-r--r-- | debian/changelog | 2 | ||||
| -rw-r--r-- | src/Propellor/Property/Network.hs | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index 008ac687..7a37cd9b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ propellor (2.17.0) UNRELEASED; urgency=medium which modified the locale.gen file and sometimes caused the property to need to make changes every time. * Force ssh, scp, and git commands to be run in the foreground. + * Network: Filter out characters not allowed in interfaces.d files. + Thanks, Félix Sipma. -- Joey Hess <id@joeyh.name> Mon, 29 Feb 2016 17:58:08 -0400 diff --git a/src/Propellor/Property/Network.hs b/src/Propellor/Property/Network.hs index 1908bbb3..382f5d9d 100644 --- a/src/Propellor/Property/Network.hs +++ b/src/Propellor/Property/Network.hs @@ -3,6 +3,8 @@ module Propellor.Property.Network where import Propellor.Base import Propellor.Property.File +import Data.Char + type Interface = String ifUp :: Interface -> Property NoInfo @@ -45,7 +47,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 @@ -97,7 +99,12 @@ interfacesFile = "/etc/network/interfaces" -- | A file in the interfaces.d directory. interfaceDFile :: Interface -> FilePath -interfaceDFile iface = "/etc/network/interfaces.d" </> iface +interfaceDFile i = "/etc/network/interfaces.d" </> escapeInterfaceDName i + +-- | /etc/network/interfaces.d/ files have to match -- ^[a-zA-Z0-9_-]+$ +-- see "man 5 interfaces" +escapeInterfaceDName :: Interface -> FilePath +escapeInterfaceDName = filter (\c -> isAscii c && (isAlphaNum c || c `elem` "_-")) -- | Ensures that files in the the interfaces.d directory are used. interfacesDEnabled :: Property NoInfo |
