Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 71651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:55:16+00:00 2026-05-10T19:55:16+00:00

We have a Java program run as root on Unix, that therefore can read

  • 0

We have a Java program run as root on Unix, that therefore can read for example the content of the folders /home/user1 and /home/user2. However, if the Unix user ‘user1’ is logged in in our application, he should not be able to access ‘/home/user2’ data. We would like to use directly the Unix rights and not recreate all the permissions in our application ! So, could we…

  1. try to change the UID of our program depending on the user logged in ? Sounds difficult, and each file access is in different threads so the UID would be different on each thread of our program…
  2. use JNI to read permissions of ‘/home/user2‘…And then determine if user1 has sufficient permissions on ‘/home/user2‘ ? (how ?).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:55:17+00:00Added an answer on May 10, 2026 at 7:55 pm

    Use SecurityManager!

    1. Put current unix user id into ThreadLocal
    2. Create your own SecurityManager that checks unix user permissions on checkRead() and checkWrite()
    3. System.setSecurityManager(new MySecurityManager())
    4. Enjoy

    Update

    There is no, of course, standard library to read unix file permissions. It’s not WORA.

    But I have tried briefly to find a ready to use library, and found this one: http://jan.newmarch.name/java/posix/ It uses JNI, but you don’t need to write your own JNI code, which is a big relief. 🙂 I’m sure there must also be others.

    Class Stat from there gives you all required access information: http://jan.newmarch.name/java/posix/posix.Stat.html

    Update 2

    As folks mentioned, this approach fails to check for ‘non-standard’ unix security features, such as ACL or Posix Capabilities (may be; not sure if they apply to files). But if the goal of being totally in sync with host OS security is set, then we even more need to use SecurityManager, because it’s a JVM-wide protection mechanism! Yes, we can start a child SUID-process to verify the permissions (and keep it running, talking to it via pipe running while the user is logged in), but we need to do so from SecurityManager!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to send a LIST command. You'll need to… May 12, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer Best C# Telnet Lib I've found is called Minimalistic Telnet.… May 12, 2026 at 3:47 pm
  • Editorial Team
    Editorial Team added an answer Looks like a 1px gap between the top border PNG… May 12, 2026 at 3:47 pm

Related Questions

I have a java program that runs a bunch of queries against an sql
I'm looking to invoke a Java program from RPG running on Iseries V5r4. The
We've been debugging this JBoss server problem for quite a while. After about 10
I need assistance finding a delivery method that best fulfills the following requirements: We

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.