• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

create a file in a directory where I don't have write permission (linux)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I wonder whether it is possible to change the permission of the user running the jvm. I working on a swing application, that should save some application defaults, that should be valid for all users. So I would like to write SystemPreferences. But as an ordinary user I'm not allowed to do that.
I read about java security, but as far as I understood those readings, it is only possible to reduce the permissions in the running jvm.

I tried several things, one of wich was to ask the user for a sudo password and than use Runtime.exec to do the writing via sudo.
That failed.
I hope that you don't laugh too loud about my question.

Is it possible to perform such tasks and if so, could you please explain me, how to do it right?
Please don't tell me to change the linux permission of the directory. I know this way, but (for me) it is the last and least way of doing it, as I don't want that preferences be user writable.

kind regards
Santi
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I wonder whether it is possible to change the permission of the user running the jvm. I working on a swing application, that should save some application defaults, that should be valid for all users. So I would like to write SystemPreferences. But as an ordinary user I'm not allowed to do that.
I read about java security, but as far as I understood those readings, it is only possible to reduce the permissions in the running jvm.



I hope that's not possible at all! I don't want any Java (or whatever) program I install in my Linux to be able to change permissions of folders I don't want to be written in, for that I have a small partition with Windows

I tried several things, one of wich was to ask the user for a sudo password and than use Runtime.exec to do the writing via sudo.
That failed.



Should be possible to do something like this but I have no idea so I cannot help you, anyway as Linux user I wouldn't let an external program to write in my directories so easily. There is a subforum of Linux/Unix in this forum, I don't know if your question would find a better answer there.

Buena suerte ;)
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

That sounds like something which would sit better in our Linux forum. Moving.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course you can't break security so easily as that. And questions which ask how to break operating system security are not approved of here.

But are you saying that the java.util.prefs classes for saving preferences are not allowed to be used in your Linux system? Or just that you can't create a file in a directory where you aren't allowed to create a file?
 
Santiago Hernandez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

thank you for your attention and answers.

for that I have a small partition with Windows


I expected that reply - Gracias

That sounds like something which would sit better in our Linux forum.


I don't mind the moving, but I'm not interested in answers regarding to linux.
I'm using Linux/Unix for over 20 years and working with security - so you can take for granted, that I'm not a kidding window user.

The point is, that I'm working on an installer for a Swing application.
My first try was to write an installer with bash and dialog (which works fine), but that's not portable to windows.
Now some windows-guys are interested in using my app, so I'd like to create a installer, that fit's for both worlds.

Users on windows-machines are used to install apps being admin. For me (and I think most other linux users) it's not usual at all. So I'd like to work on a compromise, where the installer can be startet as ordinary user and for system tasks it asks for a password.

I don't like the idea to ask the user to open i.e. java system preferences base for installation. That directory is not popular and that's fine.

The SystemPreferences was an example, where Permission come into the play.
When I'm root, writing SystemPreferences works from my java app. Being ordinary user, that Preferences can't be written. That's totally fine and I don't wonna break that for application run.

Only for installation task

So it does not need to be easy for me, but it should be easy for the installers user and it should be clean and transparent for those guys looking at my code, cause my installer will be open source, when it is working.

I hope, that you can shine me a light on how to progress, or what to research for.

kind regards
Santi
 
Santiago Hernandez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it

Thanks to you all, cause your questions guided me to find my error.
(I did a mistake with ProcessBuilder).

Now everything works fine
 
Are you here to take over the surface world? Because this tiny ad will stop you!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic