mirror of
https://github.com/munki/munki.git
synced 2026-05-03 02:40:32 -05:00
Fixes for auth restart when starting a macOS install and user has provided a password via the GUI
This commit is contained in:
@@ -45,7 +45,7 @@ from munkilib import prefs
|
||||
|
||||
|
||||
APPNAME = 'authrestartd'
|
||||
VERSION = '0.1'
|
||||
VERSION = '0.2'
|
||||
|
||||
|
||||
class FDEUtilError(Exception):
|
||||
@@ -362,6 +362,9 @@ def main():
|
||||
time.sleep(10)
|
||||
return 1
|
||||
|
||||
# Keep track of time for launchd.
|
||||
start_time = time.time()
|
||||
|
||||
# Get socket file descriptors from launchd.
|
||||
socket_fd = launchd.get_socket_fd('authrestartd')
|
||||
if not socket_fd:
|
||||
@@ -375,9 +378,25 @@ def main():
|
||||
|
||||
daemon.log.info('%s v%s starting', APPNAME, VERSION)
|
||||
|
||||
# Once we're launched, we run until restart
|
||||
# Process incoming requests
|
||||
while True:
|
||||
daemon.handle_request()
|
||||
if not daemon.timed_out or daemon.stored_password:
|
||||
continue
|
||||
# we timed out and we don't have a stored password, so we can exit
|
||||
# Keep running for at least 10 seconds make launchd happy.
|
||||
run_time = time.time() - start_time
|
||||
daemon.log.info("run time: %fs", run_time)
|
||||
if run_time < 10.0:
|
||||
# Only sleep for a short while in case new requests pop up.
|
||||
sleep_time = min(1.0, 10.0 - run_time)
|
||||
daemon.log.debug(
|
||||
"sleeping for %f seconds to make launchd happy",
|
||||
sleep_time)
|
||||
time.sleep(sleep_time)
|
||||
else:
|
||||
daemon.log.info('Nothing to do: exiting')
|
||||
break
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -36,6 +36,8 @@ from Foundation import kCFPreferencesCurrentHost
|
||||
# pylint: enable=E0611
|
||||
|
||||
# our imports
|
||||
import munkilib.authrestart.client as authrestartd
|
||||
|
||||
from . import FoundationPlist
|
||||
from . import authrestart
|
||||
from . import display
|
||||
@@ -116,7 +118,10 @@ class StartOSInstallRunner(object):
|
||||
os.unlink(self.installer)
|
||||
except (IOError, OSError):
|
||||
pass
|
||||
if authrestart.can_attempt_auth_restart():
|
||||
# ask authrestartd if we can do an auth restart, or look for a recovery
|
||||
# key (via munkilib.authrestart methods)
|
||||
if (authrestartd.verify_can_attempt_auth_restart() or
|
||||
authrestart.can_attempt_auth_restart()):
|
||||
# set a secret preference to tell the osinstaller process to exit
|
||||
# instead of restart
|
||||
# this is the equivalent of:
|
||||
@@ -322,8 +327,9 @@ class StartOSInstallRunner(object):
|
||||
CFPreferencesSetValue(
|
||||
'IAQuitInsteadOfReboot', None, '.GlobalPreferences',
|
||||
kCFPreferencesAnyUser, kCFPreferencesCurrentHost)
|
||||
# restart
|
||||
authrestart.do_authorized_or_normal_restart()
|
||||
# attempt to do an auth restart, or regular restart
|
||||
if not authrestartd.restart():
|
||||
authrestart.do_authorized_or_normal_restart()
|
||||
else:
|
||||
raise StartOSInstallError(
|
||||
'startosinstall did not complete successfully. '
|
||||
@@ -400,6 +406,12 @@ def run(finishing_tasks=None):
|
||||
display.display_status_major('Starting macOS upgrade...')
|
||||
# set indeterminate progress bar
|
||||
munkistatus.percent(-1)
|
||||
# remove the InstallInfo.plist since it won't be valid
|
||||
# after the upgrade
|
||||
try:
|
||||
os.unlink(installinfopath)
|
||||
except (OSError, IOError):
|
||||
pass
|
||||
itempath = os.path.join(cachedir, item["installer_item"])
|
||||
success = startosinstall(
|
||||
itempath, finishing_tasks=finishing_tasks)
|
||||
|
||||
Reference in New Issue
Block a user