aspose file tools*
The moose likes Linux / UNIX and the fly likes create a file in a directory where I don't have write permission (linux) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "create a file in a directory where I don Watch "create a file in a directory where I don New topic
Author

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

Santiago Hernandez
Greenhorn

Joined: Dec 01, 2009
Posts: 3
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
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
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 ;)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
Welcome to JavaRanch

That sounds like something which would sit better in our Linux forum. Moving.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Dec 01, 2009
Posts: 3
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

Joined: Dec 01, 2009
Posts: 3
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
 
Don't get me started about those stupid light bulbs.
 
subject: create a file in a directory where I don't have write permission (linux)