Use sysadminctl to set user picture

This commit is contained in:
Rezart Qelibari
2022-04-27 09:37:01 +02:00
parent e4c965f37c
commit a9d7b8c04d

View File

@@ -93,7 +93,7 @@ function doesFileVaultUserExist() {
function _createFileVaultUser() { function _createFileVaultUser() {
local un=${filevault_username} fn=${filevault_fullname} pw=${filevault_password} local un=${filevault_username} fn=${filevault_fullname} pw=${filevault_password}
lop -- -d 'Creating FileVault user' -d "${un}" lop -- -d 'Creating FileVault user' -d "${un}"
sysadminctl -addUser "${un}" -fullName "${fn}" -shell /usr/bin/false -home '/var/empty' -password "${pw}" sysadminctl -addUser ${un} -fullName ${fn} -shell /usr/bin/false -home /var/empty -password ${pw} -picture ${filevault_picture}
lop -- -d 'Return value of sysadminctl is ' -d "$?" lop -- -d 'Return value of sysadminctl is ' -d "$?"
return 0 return 0
} }
@@ -106,7 +106,6 @@ function _configureFileVaultUser() {
local un=${filevault_username} local un=${filevault_username}
dscl . -create "/Users/${un}" IsHidden 1 dscl . -create "/Users/${un}" IsHidden 1
chsh -s /usr/bin/false "${un}" >&! /dev/null chsh -s /usr/bin/false "${un}" >&! /dev/null
setPictureForUser "${un}" "${filevault_picture}"
} }
function configureFileVaultUser() { function configureFileVaultUser() {
@@ -116,7 +115,7 @@ function configureFileVaultUser() {
function configureSecureToken() { function configureSecureToken() {
local un=${filevault_username} up=${filevault_password} local un=${filevault_username} up=${filevault_password}
local stun=${secure_token_user_username} stup=${secure_token_user_password} local stun=${secure_token_user_username} stup=${secure_token_user_password}
sysadminctl -secureTokenOn "${un}" -password "${up}" -adminUser "${stun}" -adminPassword "${stup}" sysadminctl -secureTokenOn ${un} -password ${up} -adminUser ${stun} -adminPassword "${stup}"
} }
function canUserUnlockDisk() { function canUserUnlockDisk() {
@@ -127,14 +126,6 @@ function canUserUnlockDisk() {
return -1 return -1
} }
function setPictureForUser() {
local username="${1}"
local image="${2}"
dscl . delete "/Users/${username}" JPEGPhoto >&! /dev/null
dscl . delete "/Users/${username}" Picture >&! /dev/null
dscl . create "/Users/${username}" Picture "${image}"
}
function _allowOrEnableDiskUnlock() { function _allowOrEnableDiskUnlock() {
local username="${1}" password="${2}" verb=enable local username="${1}" password="${2}" verb=enable
if fdesetup isactive >&! /dev/null; then if fdesetup isactive >&! /dev/null; then