summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog7
-rw-r--r--src/Propellor/Property/User.hs11
2 files changed, 16 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 6b358633..4bcca675 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+propellor (2.14.1) UNRELEASED; urgency=medium
+
+ * User.hasDesktopGroups changed to avoid trying to add the user to
+ groups that don't exist.
+
+ -- Joey Hess <id@joeyh.name> Tue, 24 Nov 2015 17:06:12 -0400
+
propellor (2.14.0) unstable; urgency=medium
* Add Propellor.Property.PropellorRepo.hasOriginUrl, an explicit way to
diff --git a/src/Propellor/Property/User.hs b/src/Propellor/Property/User.hs
index f3842892..5bb4e1a7 100644
--- a/src/Propellor/Property/User.hs
+++ b/src/Propellor/Property/User.hs
@@ -1,6 +1,7 @@
module Propellor.Property.User where
import System.Posix
+import Data.List
import Propellor.Base
import qualified Propellor.Property.File as File
@@ -109,9 +110,15 @@ hasGroup (User user) (Group group') = check test $ cmdProperty "adduser"
-- | Gives a user access to the secondary groups, including audio and
-- video, that the OS installer normally gives a desktop user access to.
+--
+-- Note that some groups may only exit after installation of other
+-- software. When a group does not exist yet, the user won't be added to it.
hasDesktopGroups :: User -> Property NoInfo
-hasDesktopGroups user@(User u) = combineProperties desc $
- map (hasGroup user . Group) desktopgroups
+hasDesktopGroups user@(User u) = property desc $ do
+ existinggroups <- map (fst . break (== ':')) . lines
+ <$> liftIO (readFile "/etc/group")
+ let toadd = filter (`elem` existinggroups) desktopgroups
+ ensureProperty $ propertyList desc $ map (hasGroup user . Group) toadd
where
desc = "user " ++ u ++ " is in standard desktop groups"
-- This list comes from user-setup's debconf