Really odd AuthorizationMBS problem

  1. 6 months ago

    Beatrix W

    4 Jun 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    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:

    '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 file.sh")
    
    dim tempFile as FolderItem '= SpecialFolder.Temporary.Child(theRegisterFile.Name)
    tempFile = GetTemporaryFolderItem
    tempFile.Name = theRegisterFile.Name
    try
      dim theBinStream as BinaryStream = BinaryStream.Open(tempFile, true)
      
      theBinStream.Write theText
      theBinStream.Close
    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
    s.Append(tempFile.UnixpathMBS)
    s.Append(theRegisterFile.Parent.UnixpathMBS)
    theAuthorisation.Execute(InternalFolder.UnixpathMBS, s, true)
    if theAuthorisation.LastError = 0 then
      dim theResult as Integer = theAuthorisation.Wait
      Return True
    else
      Return False
    end if
  2. Michael D

    4 Jun 2019 Pre-Release Testers, Xojo Pro

    Could this be App translocation?

  3. Tim P

    4 Jun 2019 Pre-Release Testers Rochester, NY

    @Michael D 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 Console.app? I think the permissions denying messages do appear in one of those logs.

  4. Michael D

    4 Jun 2019 Pre-Release Testers, Xojo Pro

    @Tim P What macOS is the customer running, Beatrix?

    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. :-)

  5. Beatrix W

    4 Jun 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    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.

  6. Beatrix W

    4 Jun 2019 Pre-Release Testers, Third Party Store Europe (Germany)

    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:

    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 X.app/Contents/Library/LoginItems/Mail 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

  7. Michael D

    4 Jun 2019 Pre-Release Testers, Xojo Pro

    I sometimes see patterns like this with Antivirus software malfunctioning.

or Sign Up to reply!