summaryrefslogtreecommitdiff
path: root/src/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2019-07-02 00:46:21 -0400
committerJoey Hess2019-07-02 00:46:21 -0400
commit2ba2cda972f484771b763603bf09d555003861b7 (patch)
tree13c79ae8e9f46cf6c9ec5353ca366555da0e0ab1 /src/Propellor/Property
parent7ac0fbfa247ca153a6187c47dde9fc3a94c9cdb5 (diff)
Revert "Revert "custom type error messages""
This reverts commit 665ea0d3d9e1b0e90278fd659dee0ef8642030da.
Diffstat (limited to 'src/Propellor/Property')
-rw-r--r--src/Propellor/Property/Aiccu.hs5
-rw-r--r--src/Propellor/Property/Atomic.hs12
-rw-r--r--src/Propellor/Property/Systemd.hs1
-rw-r--r--src/Propellor/Property/Tor.hs30
4 files changed, 23 insertions, 25 deletions
diff --git a/src/Propellor/Property/Aiccu.hs b/src/Propellor/Property/Aiccu.hs
index 1b28759c..8bf3f283 100644
--- a/src/Propellor/Property/Aiccu.hs
+++ b/src/Propellor/Property/Aiccu.hs
@@ -47,8 +47,7 @@ hasConfig :: TunnelId -> UserName -> Property (HasInfo + DebianLike)
hasConfig t u = prop `onChange` restarted
where
prop :: Property (HasInfo + UnixLike)
- prop = withSomePrivData [(Password (u++"/"++t)), (Password u)] (Context "aiccu") $
- property' "aiccu configured" . writeConfig
- writeConfig getpassword w = getpassword $ ensureProperty w . go
+ prop = withSomePrivData [(Password (u++"/"++t)), (Password u)] (Context "aiccu") $ \getpassword ->
+ property' "aiccu configured" $ \w -> getpassword $ ensureProperty w . go
go (Password u', p) = confPath `File.hasContentProtected` config u' t p
go (f, _) = error $ "Unexpected type of privdata: " ++ show f
diff --git a/src/Propellor/Property/Atomic.hs b/src/Propellor/Property/Atomic.hs
index 8519048b..2c7433f6 100644
--- a/src/Propellor/Property/Atomic.hs
+++ b/src/Propellor/Property/Atomic.hs
@@ -46,10 +46,8 @@ type CheckAtomicResourcePair a = AtomicResourcePair a -> Propellor (AtomicResour
-- inactiveAtomicResource, and if it was successful,
-- atomically activating that resource.
atomicUpdate
- -- Constriaints inherited from ensureProperty.
- :: ( Cannot_ensureProperty_WithInfo t ~ 'True
- , (Targets t `NotSuperset` Targets t) ~ 'CanCombine
- )
+ -- Constriaint inherited from ensureProperty.
+ :: (EnsurePropertyAllowed t t ~ 'True)
=> SingI t
=> AtomicResourcePair a
-> CheckAtomicResourcePair a
@@ -92,10 +90,8 @@ atomicUpdate rbase rcheck rswap mkp = property' d $ \w -> do
-- children: a symlink with the name of the directory itself, and two copies
-- of the directory, with names suffixed with ".1" and ".2"
atomicDirUpdate
- -- Constriaints inherited from ensureProperty.
- :: ( Cannot_ensureProperty_WithInfo t ~ 'True
- , (Targets t `NotSuperset` Targets t) ~ 'CanCombine
- )
+ -- Constriaint inherited from ensureProperty.
+ :: (EnsurePropertyAllowed t t ~ 'True)
=> SingI t
=> FilePath
-> (FilePath -> Property (MetaTypes t))
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index bfc0f9a5..5d597ac6 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -391,6 +391,7 @@ mungename = replace "/" "_"
containerCfg :: String -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux)
containerCfg p = RevertableProperty (mk True) (mk False)
where
+ mk :: Bool -> Property (HasInfo + Linux)
mk b = tightenTargets $
pureInfoProperty desc $
mempty { _chrootCfg = SystemdNspawnCfg [(p', b)] }
diff --git a/src/Propellor/Property/Tor.hs b/src/Propellor/Property/Tor.hs
index 426d4209..862af983 100644
--- a/src/Propellor/Property/Tor.hs
+++ b/src/Propellor/Property/Tor.hs
@@ -172,20 +172,22 @@ hiddenServiceData hn context = combineProperties desc $ props
where
desc = unwords ["hidden service data available in", varLib </> hn]
installonion :: FilePath -> Property (HasInfo + DebianLike)
- installonion f = withPrivData (PrivFile $ varLib </> hn </> f) context $ \getcontent ->
- property' desc $ \w -> getcontent $ install w $ varLib </> hn </> f
- install w f privcontent = ifM (liftIO $ doesFileExist f)
- ( noChange
- , ensureProperty w $ propertyList desc $ toProps
- [ property desc $ makeChange $ do
- createDirectoryIfMissing True (takeDirectory f)
- writeFileProtected f (unlines (privDataLines privcontent))
- , File.mode (takeDirectory f) $ combineModes
- [ownerReadMode, ownerWriteMode, ownerExecuteMode]
- , File.ownerGroup (takeDirectory f) user (userGroup user)
- , File.ownerGroup f user (userGroup user)
- ]
- )
+ installonion basef =
+ let f = varLib </> hn </> basef
+ in withPrivData (PrivFile f) context $ \getcontent ->
+ property' desc $ \w -> getcontent $ \privcontent ->
+ ifM (liftIO $ doesFileExist f)
+ ( noChange
+ , ensureProperty w $ propertyList desc $ toProps
+ [ property desc $ makeChange $ do
+ createDirectoryIfMissing True (takeDirectory f)
+ writeFileProtected f (unlines (privDataLines privcontent))
+ , File.mode (takeDirectory f) $ combineModes
+ [ownerReadMode, ownerWriteMode, ownerExecuteMode]
+ , File.ownerGroup (takeDirectory f) user (userGroup user)
+ , File.ownerGroup f user (userGroup user)
+ ]
+ )
restarted :: Property DebianLike
restarted = Service.restarted "tor"