From 93d698a803d8ca2d8290dc7b79ee8c319fad2522 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Nov 2015 17:05:55 -0400 Subject: User.hasDesktopGroups changed to avoid trying to add the user to groups that don't exist. This is the same method user-setup uses. --- debian/changelog | 7 +++++++ src/Propellor/Property/User.hs | 11 +++++++++-- 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 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 -- cgit v1.2.3