Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Can I use a java policy file to safely run an un-trusted app with sudo

I'm running a J2SE application that is somewhat trusted (Minecraft) but will likely contain completely un-trusted (and likely even some hostile) plugins.

I'd like to create a plugin that can access the GPIO pins on the Raspberry PI.

Every solution I've seen requires that such an app be given sudo-superpowers because gpio is accessed through direct memory access.

It looks like the correct solution is to supply a command-line option like this:

-Djava.security.policy=java.policy

which seems to default you to no permissions (even access to files and high ports), then add the ones your app needs back in with the policy file.

In effect you seem to be giving Java "sudo" powers and then trusting java's security model to only give appropriate powers out to various classes. I'm guessing this makes the app safe to run with sudo--is this correct?

Funny that I've been using Java pretty much daily since 1.0 and never needed this before... You learn something new every day.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

[Disclaimer: I'm not very convinced by the Java security model.]

The way I would solve this is to have the code that needs to access the hardware run as a separate privileged process, then have your Java application run as an unprivileged process and connect to the privileged process to have it perform certain actions on its behalf.

In the privileged process, you should check with maximum distrust each request whether it is safe to execute. If you are afraid that other unprivileged processes might connect to the daemon too and make it execute commands it shouldn't, you could make its socket owned by a special group and setgid() the Java application to that group by a tiny wrapper written in C before it is started.

Unix domain sockets are probably the best choice but if you want to chroot() the Java application, a TCP/IP socket might be needed.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!