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

ShellAgent should catch java.security.AccessControlException as well when handling file access requests #225

Open
notthetup opened this issue Sep 20, 2021 · 0 comments
Assignees
Labels

Comments

@notthetup
Copy link
Collaborator

notthetup commented Sep 20, 2021

Currently, the ShellAgent specifically catches IOExceptions when handling file access requests (GetFileReq, PutFileReq).

 try {
      if (f.isDirectory()) {
      ....
    } catch (IOException ex) {
      log.warning(ex.toString());
    } finally {
     ...

However, accessing files can also throw AccessControlException if a Java Security Policy is in place. If those aren't caught at this level, the MessageBehaviour crashes and is removed from the ShellAgent. So the Agent can't respond to any more messages.

1632115867860|WARNING|org.arl.fjage.shell.ShellAgent/yoda@33:executeBehavior|Exception in agent: websh

For example, doing a GetFileReq on a file file-without-permissions.txt to which JVM doesn't have permissions based on the security policy will return this error.

1632115867860|WARNING|org.arl.fjage.shell.ShellAgent/yoda@33:executeBehavior|Exception in agent: websh

java.security.AccessControlException: access denied ("java.io.FilePermission" "file-without-permissions.txt" "read")
Stack trace: ...
   org.arl.fjage.shell.ShellAgent.handleGetFileReq(ShellAgent.java:551)
   org.arl.fjage.shell.ShellAgent.access$500(ShellAgent.java:26)
   org.arl.fjage.shell.ShellAgent$3.onReceive(ShellAgent.java:251)
   org.arl.fjage.MessageBehavior.action(MessageBehavior.java:142)
   org.arl.fjage.Agent.executeBehavior(Agent.java:781)
   org.arl.fjage.Agent.run(Agent.java:818) ...

After this error, no other GetFileReq/PutFileReq get any responses.

@notthetup notthetup added the bug label Sep 20, 2021
@notthetup notthetup changed the title ShellAgent should catch java.security.AccessControlException as well as IOException when handling file access requests ShellAgent should catch java.security.AccessControlException as well when handling file access requests Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants