summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2015-04-19 21:02:00 -0400
committerJoey Hess2015-04-19 21:02:00 -0400
commit96631ad0cbb3cb05f8baed3a7221df4f297c4293 (patch)
tree914ef242f2cb200b74f90bf0ecb9a755cfe9abc3 /src
parent10ed35441f7be707e55291891991eb98bbfb1263 (diff)
parent3d735c52f4186133da7113ca671a16d68fe76b33 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/User.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Propellor/Property/User.hs b/src/Propellor/Property/User.hs
index 9e115290..557875fb 100644
--- a/src/Propellor/Property/User.hs
+++ b/src/Propellor/Property/User.hs
@@ -3,6 +3,7 @@ module Propellor.Property.User where
import System.Posix
import Propellor
+import qualified Propellor.Property.File as File
data Eep = YesReallyDeleteHome
@@ -110,3 +111,21 @@ shadowConfig False = check shadowExists $
shadowExists :: IO Bool
shadowExists = doesFileExist "/etc/shadow"
+
+-- | Ensures that a user has a specified login shell, and that the shell
+-- is enabled in /etc/shells.
+hasLoginShell :: UserName -> FilePath -> Property NoInfo
+hasLoginShell user loginshell = shellSetTo user loginshell `requires` shellEnabled loginshell
+
+shellSetTo :: UserName -> FilePath -> Property NoInfo
+shellSetTo user loginshell = check needchangeshell $
+ cmdProperty "chsh" ["--shell", loginshell, user]
+ `describe` (user ++ " has login shell " ++ loginshell)
+ where
+ needchangeshell = do
+ currshell <- userShell <$> getUserEntryForName user
+ return (currshell /= loginshell)
+
+-- | Ensures that /etc/shells contains a shell.
+shellEnabled :: FilePath -> Property NoInfo
+shellEnabled loginshell = "/etc/shells" `File.containsLine` loginshell