Really odd AuthorizationMBS problem

I’m using AuthorizationMBS to write a file if the user can’t write to a specific location. The executed script is just a ditto to copy a file from the temporary folder to the final location. I now got a user who can’t create the temporary file. The code

dim tempFile as FolderItem = SpecialFolder.Temporary.Child(theRegisterFile.Name) dim theBinStream as BinaryStream = BinaryStream.Open(tempFile, true)

makes an exception. Therefore, I tried to make the temp file in a different way

dim tempFile as FolderItem = GetTemporaryFolderItem tempFile.Name = theRegisterFile.Name

That the file doesn’t have the correct name is a minor problem. But now the AuthorizationMBS writes a file with 0 bytes. What am I doing wrong? Full code below with error handling omitted:

[code]'get script
dim InternalFolder as FolderItem = app.ExecutableFile.Parent.Parent
if InternalFolder <> nil and InternalFolder.Exists then InternalFolder = InternalFolder.Child(“Resources”)
if InternalFolder <> nil and InternalFolder.Exists then InternalFolder = InternalFolder.Child(“write launch agent”)

dim tempFile as FolderItem '= SpecialFolder.Temporary.Child(theRegisterFile.Name)
tempFile = GetTemporaryFolderItem
tempFile.Name = theRegisterFile.Name
dim theBinStream as BinaryStream = BinaryStream.Open(tempFile, true)

theBinStream.Write theText
catch err as IOException
Return False
end try

'do Authorization
dim theAuthorisation as new AuthorizationMBS
if not theAuthorisation.SimpleNewAuthorization thenReturn False

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

Could this be App translocation?

Could be. It might depend on what the InternalFolder script/executable does.

What macOS is the customer running, Beatrix? Are they able to find / send you error messages from I think the permissions denying messages do appear in one of those logs.

Good question - given that Catalina 10.15 beta 1 was released yesterday, it’s possible that you will have customers testing your software there with “interesting” results. :slight_smile:

No to Catalina. The user is on High Sierra. Also no to Translocation. I have a check in the app and would see the dialog in the session log.

I had a look again at the session log. The user can write to the Application Support folder on startup. Then he wants to register and only this fails. The fallback solution for this is the AuthorizationMBS which fails because of the problem with the temp file:

[quote]2019-06-04, 10:07:29 Registrator.writeRegisterFile create file
2019-06-04, 10:07:29 Registrator.writeRegisterFile write successfull
2019-06-04, 10:07:29 MaxModel.Constructor
2019-06-04, 10:07:29 MaxModel.Constructor done
2019-06-04, 10:07:29 MainWindowController.Constructor
2019-06-04, 10:07:29 MainWindowController.Constructor done
2019-06-04, 10:07:29 DBWindow.Constructor
2019-06-04, 10:07:30 DBWindow.Constructor done
2019-06-04, 10:07:30 Show MainWindow done
2019-06-04, 10:07:30 ErrorReportManager.CheckForCrashes No Logs found.
2019-06-04, 10:07:30 Scheduler: /Applications/Mail Archiver X/Mail Archiver Archiver X .app
2019-06-04, 10:07:30 App.Open
2019-06-04, 10:07:30 Startup finished
2019-06-04, 10:07:33 App.FileAbout
2019-06-04, 10:07:33 AboutWindow.Constructor
2019-06-04, 10:07:33 AboutWindow.Open
2019-06-04, 10:07:33 AboutWindow.Open done
2019-06-04, 10:07:33 AboutWindow.Constructor done
2019-06-04, 10:07:39 App.FileAbout done
2019-06-04, 10:07:46 App.FileRegister
2019-06-04, 10:07:46 App.FileRegister done
2019-06-04, 10:08:05 Registrator.writeRegisterFile binstream is nil
2019-06-04, 10:08:05 Buffer:
2019-06-04, 10:08:05 --------------------------
2019-06-04, 10:08:05 An error happened:
2019-06-04, 10:08:05 Class/Method: Registrator.WriteRegisterFileWithShell
2019-06-04, 10:08:05 Time: Dienstag, 4. Juni 2019 10:08:05 20821517
2019-06-04, 10:08:05 Type of Error: IOException
2019-06-04, 10:08:05 --------------------------
2019-06-04, 10:08:05 Stack:
2019-06-04, 10:08:05
Function BinaryStream.!Open(FolderItem, boolean) as BinaryStream
Function Registrator.WriteRegisterFileWithShell(string) as boolean
Function Registrator.writeRegisterFile(string, boolean) as boolean
Sub Registrator.RegisterApplication(Window, FolderItem, boolean)
Sub PreferencesWindow.PreferencesWindow.PBRegister_Action(PreferencesWindow.PreferencesWindow, PushButton)
Sub Delegate.IM_Invoke(PushButton)
Sub AddHandler.Stub.15()
Sub Application._CallFunctionWithExceptionHandling()
2019-06-04, 10:08:05 Stack done
2019-06-04, 10:08:05 ErrorReportWindow.Constructor
2019-06-04, 10:08:06 ErrorReportWindow.Constructor done[/quote]

I sometimes see patterns like this with Antivirus software malfunctioning.