Closed PicoMitchell closed 3 years ago
I can double-check these findings though since most of my testing was on a non-admin account as well as a T2 Mac which may have had its own requirements separate from non-T2 Intel Macs.
Big Sur startosinstall
behavior confirmed on both T2 and non-T2 Intel Macs:
Big Sur startosinstall
with NO arguments will prompt for password via CLI. If NOT running as admin, this always fails with Error: could not get authorization...
regardless of entering the current non-admin user password or an admin password. When running as admin, the current admin password can be entered and the installation will start.
When ONLY --agreetolicense
is specified, Big Sur startosinstall returns Error: A method of password entry is required.
Using BOTH --agreetolicense
AND --passprompt
(or --stdinpass
) solves that error, but has the same authentication behavior and same non-admin problem as running with no arguments.
The best all around solution is to always include --passprompt
or --stdinpass
WITH a known good admin user with a Secure Token in the --user
argument. If the currently running user is known to be an admin with a Secure Token, the --user
argument could be left out, but including it does not hurt anything.
PS. I have updated my code above with more specific comments based on these latest findings in the --passprompt
and --user
sections.
I haven't seen your issue on Intel Macs with Big Sur, but I'll test it in case that's come in on more recent versions of Big Sur.
I'm curious as to your preference for using passprompt
. I couldn't get this to work at all, but maybe I did not understand the required syntax. stdinpass
works fine for me though, so I went with that.
I'm not sure I see the worth of all the code associated with checking the required arguments of startosinstall
, because the erase-install script needs to check for version anyway to determine the validity of the installer. So the check is already done. It seems to take a bunch more code to do it your way. Still, it's an interesting project.
I have just run sudo erase-install.sh --reinstall
on a T1 Mac running macOS 11.2.3 and it worked. I did not supply the --user
or --stdinpass
arguments and was not asked for any credentials. I'd be curious to see your output. Are you not using sudo
?
Odd that you have not see the same "authorization" errors on Intel Macs that I was getting in Big Sur. Did you do testing in a non-admin account? I did all my testing in 11.2, so maybe something recently changed. All my testing on that was consistent and reproducible.
For our uses in refurbishment, this tool would generally be run in Recovery OS and would not need the eraseinstall
option. But, in the case that someone did already set up a Mac manually for some reason with an arbitrary user account, or our Tech Support department wanted to use this tool to do a re-install on a customer computer, it could launched in the full OS by a technician. In this case, the admin username and password may not be known in advance and the technician would be in front of the computer when the installation starts. In this scenario, using passprompt
so that the password prompt comes up within Terminal when needed was the most straight forward approach.
For erase-install
, which is more intended to be run unattended, passprompt
does not seems like it would be useful since it would wait for user input.
As I said originally, I think checking the version and applying the known correct arguments is a fine way to go. Using grep in this way mostly came about because, other than your script, it was hard to find a definitive source for which arguments applied to which versions of startosinstall
. So, I kind of built my investigation into the code. I also though this way would be good for some future-proofing. If thing change, this code makes no assumptions about "this version or newer", it is all about what is actually available in the startosinstall
binary that is being used. Of course that doesn't replace actual testing and updating when new versions of macOS come out, but it may help notice subtle changes that could be easy to miss otherwise.
It's fair that each other these conditions take a bit more code than simply checking the version. If this resulted in a noticeable slowness at runtime, I would not have gone with this approach. I also find it nice that each condition makes it absolutely clear which argument each block of code is for. In term of brevity and clarity, I was a bit curious why you repeated bash string manipulations such as ${installer_build:0:2}
over and over rather than creating a new more obvious argument such as installer_darwin_major_version="${installer_build:0:2}"
. Probably doesn't make a noticeable difference at runtime though.
All in all, I just thought it may be interesting for you to see another approach to a similar problem.
I have just run
sudo erase-install.sh --reinstall
on a T1 Mac running macOS 11.2.3 and it worked. I did not supply the--user
or--stdinpass
arguments and was not asked for any credentials. I'd be curious to see your output. Are you not usingsudo
?
No, I am not running startosinstall
as sudo
since that would not be useful when running within a non-admin account. That is probably the difference. If erase-install
will always be run as root or with sudo
, then maybe it is a non-issue for this project.
For sure it was interesting, so thanks for sharing!
I've been testing most versions of Big Sur since they came out, so I would be surprised if 11.2 specifically had asked for the user and passprompt and I missed it. I've had that code in the script since testing on our DTK probably before the main Big Sur release.
I suppose I normally test with an admin account rather than a standard account. I think the only standard account testing I have done is on Apple Silicon Macs. But I've had no reports that startosinstall requires user/pass on Intel other than yours. Indeed, many people are still using the EraseInstall application (not related to my script) successfully on Intel Big Sur Macs, and that does not include the prompts.
No, I am not running startosinstall as sudo since that would not be useful when running within a non-admin account. That is probably the difference. If erase-install will always be run as root or with sudo, then maybe it is a non-issue for this project.
Aha. Yes, erase-install.sh
is envisaged for the main part as a management script that you deploy with your management software, e.g. Jamf Pro or Munki. It is not designed to be run as a standard user.
I am working on a script to be used with macOS refurbishment, and your
startosinstall
argument was an invaluable reference. I wanted to share back the related work that I did.Instead of using OS version checks in my code to determine supported
startosinstall
arguments, I wanted to use the output ofstartosinstall --usage
. Sadly, I found thatstartosinstall --usage
can take a VERY long time so I went about finding another similar solution. I landed on grepping the binary contents to check for supported arguments. This feels a bit unconventional but its effective and MUCH faster than loading the--usage
.Checking the Darwin major version, as
erase-install
is doing, is a perfectly valid solution but I thought this alternate solution may interest you.Also, while I was working on this, I noticed that you have CORRECT code but an INCORRECT comment at https://github.com/grahampugh/erase-install/blob/0e5c38bdb052d270fd8f3c07040adcea408d1d86/erase-install.sh#L1101 This comment is incorrect, although the code correctly only adds the
--allowremoval
argument on macOS 10.15 Catalina. You can see my comments in the included code for more info on this argument (which also reference your blog post about it).And lastly, I see that your code in
erase-install
only sets--stdinpass
and--user
when running on Apple Silicon. This does not sync with my findings during my own testing. I found that Big Sur requires--stdinpass
or--passprompt
when on Intel Macs as well. I believe an error is returned stating that specifying form of authentication is required. And if not running as an admin user the--user
argument is required to specify which admin to authenticate with (or else it will try to authenticate with the currently running non-admin and fail). I can double-check these findings though since most of my testing was on a non-admin account as well as a T2 Mac which may have had its own requirements separate from non-T2 Intel Macs.Here is my
startosinstall
code with the intelligent argument selection based around grepping thestartosinstall
binary: