diff options
author | Joey Hess <joeyh@joeyh.name> | 2018-08-19 13:24:52 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2018-08-19 13:24:52 -0400 |
commit | 5f5d99824a2b24d11ccbf4969f934c94e58a9a90 (patch) | |
tree | 985e3b5195084debf100c3b690a31d5c6da46010 | |
parent | 5f530af0223913a9a5ff50a806ee5b4f8e527983 (diff) |
Split mailname property out of Hostname.sane
Since bad mailname guesses can lead to ugly surprises. (API change)
Kept it in the Hostname module for easy discoverability, and similar to
Hostname.searchDomain it sets a value based on the hostname so makes sense
to keep it in that module.
Didn't implement the mailname equivilant of Hostname.setTo, because it's
trivial to write the mailname file with a custom value if desired.
This commit was sponsored by John Pellman on Patreon.
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | doc/forum/mailname_set_by_Propellor.Property.Hostname.sane/comment_6_3c962f6aeff10726ae469ca7f48ab34c._comment | 7 | ||||
-rw-r--r-- | joeyconfig.hs | 3 | ||||
-rw-r--r-- | propellor.cabal | 2 | ||||
-rw-r--r-- | src/Propellor/Property/HostingProvider/CloudAtCost.hs | 1 | ||||
-rw-r--r-- | src/Propellor/Property/Hostname.hs | 17 | ||||
-rw-r--r-- | src/Propellor/Property/Installer/Target.hs | 1 | ||||
-rw-r--r-- | src/Propellor/Property/OS.hs | 1 |
8 files changed, 30 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog index 1da97c15..080884ab 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ -propellor (5.4.2) UNRELEASED; urgency=medium +propellor (5.5.0) UNRELEASED; urgency=medium * letsencrypt': Pass --expand to support expanding the list of domains + * Split mailname property out of Hostname.sane, since bad mailname + guesses can lead to ugly surprises. (API change) -- Joey Hess <id@joeyh.name> Thu, 09 Aug 2018 10:54:41 -0400 diff --git a/doc/forum/mailname_set_by_Propellor.Property.Hostname.sane/comment_6_3c962f6aeff10726ae469ca7f48ab34c._comment b/doc/forum/mailname_set_by_Propellor.Property.Hostname.sane/comment_6_3c962f6aeff10726ae469ca7f48ab34c._comment new file mode 100644 index 00000000..f9666ca1 --- /dev/null +++ b/doc/forum/mailname_set_by_Propellor.Property.Hostname.sane/comment_6_3c962f6aeff10726ae469ca7f48ab34c._comment @@ -0,0 +1,7 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 6""" + date="2018-08-19T17:22:18Z" + content=""" +Ok, did that. +"""]] diff --git a/joeyconfig.hs b/joeyconfig.hs index 4b9fb785..05c93346 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -66,6 +66,7 @@ darkstar = host "darkstar.kitenet.net" $ props & osDebian Unstable X86_64 & ipv6 "2001:4830:1600:187::2" & Hostname.sane + & Hostname.mailname & Apt.serviceInstalledRunning "swapspace" & Laptop.powertopAutoTuneOnBoot & Laptop.trimSSD @@ -461,6 +462,7 @@ keysafe :: Host keysafe = host "keysafe.joeyh.name" $ props & ipv4 "139.59.17.168" & Hostname.sane + & Hostname.mailname & osDebian (Stable "stretch") X86_64 & Apt.stdSourcesList `onChange` Apt.upgrade & Apt.unattendedUpgrades @@ -565,6 +567,7 @@ standardSystemUnhardened :: DebianSuite -> Architecture -> Motd -> Property (Has standardSystemUnhardened suite arch motd = propertyList "standard system" $ props & osDebian suite arch & Hostname.sane + & Hostname.mailname & Hostname.searchDomain & Locale.available "en_US.UTF-8" & File.hasContent "/etc/motd" ("":motd++[""]) diff --git a/propellor.cabal b/propellor.cabal index 26c05a1d..904a8f64 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -1,5 +1,5 @@ Name: propellor -Version: 5.4.1 +Version: 5.5.0 Cabal-Version: 1.20 License: BSD2 Maintainer: Joey Hess <id@joeyh.name> diff --git a/src/Propellor/Property/HostingProvider/CloudAtCost.hs b/src/Propellor/Property/HostingProvider/CloudAtCost.hs index 48c19572..839aa14e 100644 --- a/src/Propellor/Property/HostingProvider/CloudAtCost.hs +++ b/src/Propellor/Property/HostingProvider/CloudAtCost.hs @@ -13,6 +13,7 @@ import qualified Propellor.Property.User as User decruft :: Property DebianLike decruft = propertyList "cloudatcost cleanup" $ props & Hostname.sane + & Hostname.mailname & grubbugfix & nukecruft where diff --git a/src/Propellor/Property/Hostname.hs b/src/Propellor/Property/Hostname.hs index 1eb9d690..0ece92a8 100644 --- a/src/Propellor/Property/Hostname.hs +++ b/src/Propellor/Property/Hostname.hs @@ -14,8 +14,6 @@ import Data.List -- (However, when used inside a chroot, avoids setting the current hostname -- as that would impact the system outside the chroot.) -- --- Configures </etc/mailname> with the domain part of the hostname. --- -- </etc/hosts> is also configured, with an entry for 127.0.1.1, which is -- standard at least on Debian to set the FDQN. -- @@ -46,8 +44,6 @@ setTo' extractdomain hn = combineProperties desc $ toProps , check (not <$> inChroot) $ cmdProperty "hostname" [basehost] `assume` NoChange - , "/etc/mailname" `File.hasContent` - [if null domain then hn else domain] ] where desc = "hostname " ++ hn @@ -85,6 +81,19 @@ searchDomain' extractdomain = property' desc $ \w -> | "search " `isPrefixOf` l = False | otherwise = True +-- Configures </etc/mailname> with the domain part of the hostname of the +-- `Host` it's used in. +mailname :: Property UnixLike +mailname = mailname' extractDomain + +mailname' :: ExtractDomain -> Property UnixLike +mailname' extractdomain = property' ("mailname set from hostname") $ \w -> + ensureProperty w . go =<< asks hostName + where + go mn = "/etc/mailname" `File.hasContent` [if null mn' then mn else mn'] + where + mn' = extractdomain mn + -- | Function to extract the domain name from a HostName. type ExtractDomain = HostName -> String diff --git a/src/Propellor/Property/Installer/Target.hs b/src/Propellor/Property/Installer/Target.hs index 8c865143..c6889dc5 100644 --- a/src/Propellor/Property/Installer/Target.hs +++ b/src/Propellor/Property/Installer/Target.hs @@ -24,6 +24,7 @@ -- > seed ver = host "debian.local" $ props -- > & osDebian Unstable X86_64 -- > & Hostname.sane +-- > & Hostname.mailname -- > & Apt.stdSourcesList -- > & Apt.installed ["linux-image-amd64"] -- > & Grub.installed PC diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs index c31bef7b..503f303d 100644 --- a/src/Propellor/Property/OS.hs +++ b/src/Propellor/Property/OS.hs @@ -58,6 +58,7 @@ import Control.Exception (throw) -- > -- , oldOsRemoved (Confirmed "foo.example.com") -- > ] -- > & Hostname.sane +-- > & Hostname.mailname -- > & Apt.installed ["linux-image-amd64"] -- > & Apt.installed ["ssh"] -- > & User.hasSomePassword "root" |