summaryrefslogtreecommitdiff
path: root/Property/User.hs
diff options
context:
space:
mode:
authorJoey Hess2014-03-29 23:10:52 -0400
committerJoey Hess2014-03-29 23:16:43 -0400
commitd9af8bac5eb7836a3c90e37e870fd73d30b841fd (patch)
tree40443efd384415172cf393571fe3f1651ea57423 /Property/User.hs
initial check-in
too young to have a name
Diffstat (limited to 'Property/User.hs')
-rw-r--r--Property/User.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Property/User.hs b/Property/User.hs
new file mode 100644
index 00000000..f43c9b20
--- /dev/null
+++ b/Property/User.hs
@@ -0,0 +1,22 @@
+module Property.User where
+
+import Data.List
+import System.Posix
+import Control.Applicative
+import Data.Maybe
+
+import Property
+import Utility.SafeCommand
+import Utility.Exception
+
+type UserName = String
+
+nonsystem :: UserName -> Property
+nonsystem user = check (isNothing <$> homedir user) $ cmdProperty "adduser"
+ [ Param "--disabled-password"
+ , Param "--gecos", Param ""
+ , Param user
+ ]
+
+homedir :: UserName -> IO (Maybe FilePath)
+homedir user = catchMaybeIO $ homeDirectory <$> getUserEntryForName user