hasSomePassword and hasPassword now check to make sure shadow passwords are enabled.

This commit is contained in:
Joey Hess 2014-12-05 16:33:23 -04:00
parent 2559b23482
commit 527975dffe
4 changed files with 13 additions and 11 deletions

View File

@ -57,8 +57,7 @@ testvm = host "testvm.kitenet.net"
& os (System (Debian Unstable) "amd64") & os (System (Debian Unstable) "amd64")
& OS.cleanInstallOnce (OS.Confirmed "testvm.kitenet.net") & OS.cleanInstallOnce (OS.Confirmed "testvm.kitenet.net")
`onChange` propertyList "fixing up after clean install" `onChange` propertyList "fixing up after clean install"
[ User.shadowConfig True [ OS.preserveRootSshAuthorized
, OS.preserveRootSshAuthorized
, OS.preserveResolvConf , OS.preserveResolvConf
, Apt.update , Apt.update
, Grub.boots "/dev/sda" , Grub.boots "/dev/sda"

2
debian/changelog vendored
View File

@ -21,6 +21,8 @@ propellor (1.1.0) UNRELEASED; urgency=medium
* hasSomePassword and hasPassword now default to using the name of the * hasSomePassword and hasPassword now default to using the name of the
host as the Context for the password. To specify a different context, host as the Context for the password. To specify a different context,
use hasSomePassword' and hasPassword' (API change) use hasSomePassword' and hasPassword' (API change)
* hasSomePassword and hasPassword now check to make sure shadow passwords
are enabled.
* cron.runPropellor now runs propellor, rather than using its Makefile. * cron.runPropellor now runs propellor, rather than using its Makefile.
This is more robust. This is more robust.
* propellor.debug can be set in the git config to enable more persistent * propellor.debug can be set in the git config to enable more persistent

View File

@ -45,8 +45,7 @@ import Control.Exception (throw)
-- > & os (System (Debian Unstable) "amd64") -- > & os (System (Debian Unstable) "amd64")
-- > & cleanInstallOnce (Confirmed "foo.example.com") -- > & cleanInstallOnce (Confirmed "foo.example.com")
-- > `onChange` propertyList "fixing up after clean install" -- > `onChange` propertyList "fixing up after clean install"
-- > [ User.shadowConfig True -- > [ preserveNetworkInterfaces
-- > , preserveNetworkInterfaces
-- > , preserveResolvConf -- > , preserveResolvConf
-- > , preserverRootSshAuthorized -- > , preserverRootSshAuthorized
-- > , Apt.update -- > , Apt.update

View File

@ -44,13 +44,15 @@ hasPassword user = property (user ++ "has password") $ do
ensureProperty $ hasPassword' user (Context hostname) ensureProperty $ hasPassword' user (Context hostname)
hasPassword' :: UserName -> Context -> Property hasPassword' :: UserName -> Context -> Property
hasPassword' user context = withPrivData (Password user) context $ \getpassword -> hasPassword' user context = go `requires` shadowConfig True
property (user ++ " has password") $ where
getpassword $ \password -> makeChange $ go = withPrivData (Password user) context $ \getpassword ->
withHandle StdinHandle createProcessSuccess property (user ++ " has password") $
(proc "chpasswd" []) $ \h -> do getpassword $ \password -> makeChange $
hPutStrLn h $ user ++ ":" ++ password withHandle StdinHandle createProcessSuccess
hClose h (proc "chpasswd" []) $ \h -> do
hPutStrLn h $ user ++ ":" ++ password
hClose h
lockedPassword :: UserName -> Property lockedPassword :: UserName -> Property
lockedPassword user = check (not <$> isLockedPassword user) $ cmdProperty "passwd" lockedPassword user = check (not <$> isLockedPassword user) $ cmdProperty "passwd"