summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2016-03-07 12:17:50 -0400
committerJoey Hess2016-03-07 12:17:50 -0400
commit6eb4f7a2f9bbabc5c606f624e9b8380a16224690 (patch)
tree1e818d99a61e029c3d2d2d30e52b28a231315aaa
parent6cb5e3bbf5bf05637d71695ebc001be103526782 (diff)
parent9003983998e50f11e85e7f29e3eae3c486c0f6d0 (diff)
Merge branch 'joeyconfig'
-rw-r--r--debian/changelog2
-rw-r--r--src/Propellor/Property/Network.hs11
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