summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Postfix.hs
diff options
context:
space:
mode:
authorJoey Hess2015-11-25 13:59:51 -0400
committerJoey Hess2015-11-25 14:02:32 -0400
commit4e2aa1f39abd3a9c11fd863bf3b100653c7b961a (patch)
tree440ecf8c13fd2493dedde0de2026663ca7d7a0ec /src/Propellor/Property/Postfix.hs
parent6284e3f825ddf785f460f62ed4d681ad28ac788e (diff)
Added Postfix.saslPasswdSet.
Diffstat (limited to 'src/Propellor/Property/Postfix.hs')
-rw-r--r--src/Propellor/Property/Postfix.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Propellor/Property/Postfix.hs b/src/Propellor/Property/Postfix.hs
index 562444da..5e265e6f 100644
--- a/src/Propellor/Property/Postfix.hs
+++ b/src/Propellor/Property/Postfix.hs
@@ -157,3 +157,19 @@ saslAuthdInstalled = setupdaemon
postfixgroup = (User "postfix") `User.hasGroup` (Group "sasl")
`onChange` restarted
dir = "/var/spool/postfix/var/run/saslauthd"
+
+-- | Uses `saslpasswd2` to set the password for a user in the sasldb2 file.
+--
+-- The password is taken from the privdata.
+saslPasswdSet :: Domain -> User -> Property HasInfo
+saslPasswdSet domain (User user) = withPrivData src ctx $ \getpw ->
+ property ("sasl password for " ++ uatd) $ getpw $ \pw -> makeChange $
+ withHandle StdinHandle createProcessSuccess p $ \h -> do
+ hPutStrLn h (privDataVal pw)
+ hClose h
+ where
+ uatd = user ++ "@" ++ domain
+ ps = ["-p", "-c", "-u", domain, user]
+ p = proc "saslpasswd2" ps
+ ctx = Context "sasl"
+ src = PrivDataSource (Password uatd) "enter password"