Skip to content

Commit a58001a

Browse files
committed
(PUP-11454) Enforce salt requirements for macOS versions 10.15+
For macOS versions 10.15 and higher, it is required that the salt is 32 bytes. user.rb was modified so the salt requirements were included. directoryservice.rb was modified so the salt requirements are enforced. should_allow_managed_macos_users_to_login.rb was modified so it would test on macOS versions 10 and higher, not just 11.
1 parent 183db92 commit a58001a

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

acceptance/tests/resource/user/should_allow_managed_macos_users_to_login.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
on(agent, "dscl /Local/Default -authonly testuser helloworld", :acceptable_exit_codes => 0)
3636
end
3737

38-
unless agent['platform'] =~ /osx-11/
39-
skip_test "AuthenticationAuthority field fix test is not valid for macOS older than Big Sur (11.0)"
38+
unless agent['platform'] =~ /^osx-1[1-9]/
39+
skip_test "AuthenticationAuthority field fix test is not valid for macOS before Big Sur (11.0)"
4040
end
4141

4242
# Setting up environment to mimic situation on macOS 11 BigSur

lib/puppet/provider/user/directoryservice.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ def iterations=(value)
401401
# we have to treat the ds cache just like you would in the password=
402402
# method.
403403
def salt=(value)
404+
if (Puppet::Util::Package.versioncmp(self.class.get_os_version, '10.15') >= 0)
405+
if value.length != 64
406+
self.fail "macOS versions 10.15 and higher require the salt to be 32-bytes. Since Puppet's user resource requires the value to be hex encoded, the length of the salt's string must be 64. Please check your salt and try again."
407+
end
408+
end
404409
if (Puppet::Util::Package.versioncmp(self.class.get_os_version, '10.7') > 0)
405410
assert_full_pbkdf2_password
406411

lib/puppet/type/user.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ def change_to_s(currentvalue, newvalue)
227227
* OS X 10.8 and higher use salted SHA512 PBKDF2 hashes. When managing passwords
228228
on these systems, the `salt` and `iterations` attributes need to be specified as
229229
well as the password.
230+
* macOS 10.15 and higher require the salt to be 32-bytes. Since Puppet's user
231+
resource requires the value to be hex encoded, the length of the salt's
232+
string must be 64.
230233
* Windows passwords can be managed only in cleartext, because there is no Windows
231234
API for setting the password hash.
232235

0 commit comments

Comments
 (0)