Error 62529 when doing AuthorisationMBS

Follow up to My script now works in Terminal but it doesn’t work with AuthorisationMBS. The code is:

[code]dim theScript as FolderItem 'get path to the script

'write shell script to temp file
dim TempFile as FolderItem = Folderitem.TemporaryFile
dim TempBinary as BinaryStream = BinaryStream.Open(TempFile, True)
TempBinary.Write("#!/bin/sh" + EndOfLine.UNIX + “chown root:admin “”$1"”")

'set permissions for shell script
dim theShell as new Shell
theShell.Execute("chmod 777 " + TempFile.ShellPath)
if theShell.ExitCode <> 0 then Return False

'do Authorization
if theAuthorisation = nil then
theAuthorisation = new AuthorizationMBS
theAuthorisation.KeepRights = true
if not theAuthorisation.SimpleNewAuthorization then Return False
end if

dim s(-1) as string
theAuthorisation.Execute(TempFile.UnixpathMBS, s, true)
if theAuthorisation.LastError = 0 then
dim theResult as Integer = theAuthorisation.Wait
Return True
theError = Str(theAuthorisation.LastError)
Return False
end if[/code]

I get an error 62529 when running the code. What does the code mean and what am I doing wrong?

Sorry, no idea what error 62529 is.

For your problem I can only recommend two things:

  1. Perform shell script with AppleScript where you can let the AppleScript ask for admin privileges.
  2. Use AuthorisationMBS to run the script directly.

In both cases the script should not contain a sudo line.

Thanks for your reply.

  1. I’m going to investigate.
  2. Valentina-Server needs to be started with root.

Using AuthorisationMBS gets permission, that’s the point. I’ve used it, and you don’t add the sudo.

If you need to run the script again and again, you can also run one script which sets owner of the file to root and the setuid bit for the file.

e.g. like this:

chown -R root /Library/xx/Updater
chgrp -R wheel /Library/xx/Updater
chmod -R 555 /Library/xx/Updater


chmod 4555 /Library/xx/Updater/Updater

@Tim Parnell: unfortunately, no. The script needs to be run as root. It’s not really complicated:

launchctl load /Library/LaunchDaemons/com.paradigmasoft.vserver_x64.plist

If the script is not run as root then the database service is run as a user.

@Christian Schmitz: I’ll try that instead.

Which version of the macOS are you using this on. I vaguely recall that there’s something about Authorization only being do-able by using an XPC helper, but I can’t recall if that’s enforced yet or not. It is however the method that Apple wants developers to be using.

I’ve tried the code on both High Sierra and Catalina. All my other authorizations work fine.

What is an XPC Helper?

If all your other Authorizations work, then don’t worry about it. I should have asked this first, apologizes.