From 4e2aa1f39abd3a9c11fd863bf3b100653c7b961a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 25 Nov 2015 13:59:51 -0400 Subject: Added Postfix.saslPasswdSet. --- src/Propellor/Property/Postfix.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/Propellor/Property/Postfix.hs') 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" -- cgit v1.3-2-g0d8e