Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After turning on administrator Required, there is no response after entering the password when starting under mac. #398

Open
3 tasks
futurecad opened this issue Mar 30, 2024 · 22 comments
Labels
bug Something isn't working working on Work in progress on this issue

Comments

@futurecad
Copy link

I'm submitting a…

  • [ ✅] bug report
  • feature request
  • other

Short description of the issue/suggestion:

Steps to reproduce the issue/enhancement:

  1. [First Step]
  2. [Second Step]
  3. [Other Steps...]

What is the expected behavior?
After turning on administrator Required, there is no response after entering the password when starting under mac.

What is the current behavior?
Turn on administrator Required and then double-click the package program but it cannot run after entering the password.

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

What is the motivation / use case for changing the behavior?
I need to start this app as administrator

Please tell us about your environment:
macos14.4 jdk21 javapackager1.7.5

  • JavaPackager version:
  • OS version:macos14.4
  • JDK version:21
  • Build tool:
    • [✅ ] Maven
    • Gradle

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

@fvarrui
Copy link
Owner

fvarrui commented Mar 30, 2024

Hi @futurecad!
I've just try it and managed to reproduce your issue. Not sure why, but it seems that universalJavaApplicationStub script it's not being copied in Contents/MacOS, just the auxiliary script startup, used to run as administrator.
I'll try to figure out whats happening asap.
Thanks for taking your time posting this issue.

@fvarrui fvarrui added the bug Something isn't working label Mar 30, 2024
@fvarrui
Copy link
Owner

fvarrui commented Mar 30, 2024

Ok, I've just found where's the bug:

private void processStartupScript() throws Exception {
if (this.administratorRequired) {
// We need a helper script ("startup") in this case,
// which invokes the launcher script/ executable with administrator rights.
// TODO: admin script depends on launcher file name 'universalJavaApplicationStub'
// sets startup file
this.executable = new File(macOSFolder, "startup");
// creates startup file to boot java app
VelocityUtils.render("mac/startup.vtl", executable, this);
} else {
File launcher = macConfig.getCustomLauncher();
if (launcher != null && launcher.canRead() && launcher.isFile()){
FileUtils.copyFileToFolder(launcher, macOSFolder);
this.executable = new File(macOSFolder, launcher.getName());
} else {
this.executable = preparePrecompiledStartupStub();
}
}
executable.setExecutable(true, false);
Logger.info("Startup script file created in " + executable.getAbsolutePath());
}

Some time ago a new feature which let use a custom launcher script was introduced ... creating this side effect. As you can see here, the startup script should be an extension, not an alternative to universalJavaApplicationScript or the custom one.

@fvarrui
Copy link
Owner

fvarrui commented Mar 30, 2024

Just released a SNAPHOT version to Maven Central: 1.7.6-20240330.174335-4. Please, test it and give me some feedback.
Thanks!

You can take a look about how to use snapshot versions.

@fvarrui fvarrui added the feedback Waiting for feedback label Mar 30, 2024
@futurecad
Copy link
Author

I used 1.7.6 - SNAPSHOT version and still have the same problem. After double-clicking the package to run and entering the password, there is still no prompt.
macos version: 14.4.1 (23 E224)

@fvarrui
Copy link
Owner

fvarrui commented Mar 31, 2024

I used 1.7.6 - SNAPSHOT version and still have the same problem. After double-clicking the package to run and entering the password, there is still no prompt. macos version: 14.4.1 (23 E224)

Ok, I'm not sure what's happening right now.

Please, could you try to run your app from the terminal using $ ./Your.app/Contents/MacOS/startup and universalJavaApplicationStub?

@futurecad
Copy link
Author

Also doesn't work. How can I show you the relevant logs?

@futurecad
Copy link
Author

Are you solving this problem now?

@fvarrui
Copy link
Owner

fvarrui commented Apr 17, 2024

Hi @futurecad!

Yes, but I haven't found a solution yet. I'll tell you something if figure out what's happening.

You can find some logs in Console.app

@fvarrui fvarrui added working on Work in progress on this issue and removed feedback Waiting for feedback labels Apr 17, 2024
@fvarrui
Copy link
Owner

fvarrui commented Apr 21, 2024

Hi @futurecad!
Sorry, I can't figure out what's happening since this was working fine some time ago.
Let me know if you find a different way than calling osascript to run something as admin on macOS.
I'll keep researching about this issue.

@futurecad
Copy link
Author

1.7.6 - SNAPSHOT Another problem

Null reference [template 'mac/startup.vtl', line 4, column 48]: $SCRIPTPATH cannot be resolved.
[DEBUG] ResourceManager: found mac/Info.plist.vtl with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader
[DEBUG] Null reference [template 'mac/Info.plist.vtl', line 47, column 33]: $APP_PACKAGE cannot be resolved.

@futurecad
Copy link
Author

I received printouts in my in-application logs but did not successfully start the gui interface.

@futurecad
Copy link
Author

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false
Launched via app without any logs

@fvarrui
Copy link
Owner

fvarrui commented Jun 30, 2024

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false Launched via app without any logs

Hi @futurecad!
Did you find a solution?

@futurecad
Copy link
Author

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false Launched via app without any logs

Hi @futurecad! Did you find a solution?

not yet

@AridanWarlock
Copy link

AridanWarlock commented Aug 30, 2024

Hi, i have same problem. I tried download "issue-398" branch in mavenLocal, but "javapackager" plugin in Gradle doesn`t work. Also i tried SNAPSHOT-1.7.6-20240330.174335-4, but i have same reaction on "isAdministratorRequired = true".

Can you load this in another SNAPSHOT please?

@fvarrui
Copy link
Owner

fvarrui commented Sep 1, 2024

Hi @futurecad and @AridanWarlock!
Sorry, but my availability has been very limited lately and I no longer have a Mac to be able to do tests.

Hi, i have same problem. I tried download "issue-398" branch in mavenLocal, but "javapackager" plugin in Gradle doesn`t work.

Do you mean it cannot be built? Which tool versions are you using?

Also i tried SNAPSHOT-1.7.6-20240330.174335-4, but i have same reaction on "isAdministratorRequired = true".
Can you load this in another SNAPSHOT please?

I'm sorry, snapshot versions are not available forever, but just released a new one for this issue: 1.7.6-20240901.181942-1

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false Launched via app without any logs

I wonder if that the app finally starts with administrator privileges using -Djava.awt.headless=false. If so, you can use vmArgs property to set this argument at runtime by default.

@AridanWarlock
Copy link

Hi @fvarrui!
I set new SNAPSHOT and add -Djava.awt.headless=false. Now I have both scripts created, but still "startup" immediately closes without waiting for the password to be entered.

Снимок экрана 2024-09-04 в 13 51 30

@AridanWarlock
Copy link

Hi, @fvarrui!
Any ideas what went wrong? What should I try to do?

@fvarrui
Copy link
Owner

fvarrui commented Sep 9, 2024

Hi, @fvarrui! Any ideas what went wrong? What should I try to do?

Hi @futurecad!
Do you know any way to call a script on MacOS as admin without using osascript?

@fvarrui
Copy link
Owner

fvarrui commented Sep 9, 2024

Maybe it would be posible to create a native launcher (for x86 and/or aarch64) which asks for user credentials and runs universalJavaAplicationScript as admin?

@futurecad
Copy link
Author

@AridanWarlock @fvarrui
I couldn't find a better startup solution, so I had to change the program to pop up the user password to temporarily circumvent this problem.

@fvarrui
Copy link
Owner

fvarrui commented Sep 28, 2024

Not sure if it's related to this, but, it seems there's an issue starting MacOS apps using a BASH script. Does your app start if administratorRequired=false?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working working on Work in progress on this issue
Projects
None yet
Development

No branches or pull requests

3 participants