Re: How to set Permissions on New File
From: Hal Vaughan (hal_at_thresholddigital.com)
Date: 10/28/03
- Next message: Phil...: "Re: char to string ????"
- Previous message: Matt Smith: "Re: ICMP packets"
- In reply to: Anthony Borla: "Re: How to set Permissions on New File"
- Next in thread: Anthony Borla: "Re: How to set Permissions on New File"
- Reply: Anthony Borla: "Re: How to set Permissions on New File"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Oct 2003 15:16:53 GMT
Thanks! It helps a lot.
I was looking at using native commands, since I couldn't find anything else.
For me, that is a last resort, since it means writing a special
implementation for each OS the installer works on, and I was hoping to keep
it as multi-platform as possible (part of the reason I'm using Java). At
least using chmod will work for most OSs out there and I have a book on
Windows scripting to take care of that.
You also provide a lot of useful and clear information. Your comments are a
big help and greatly appreciated.
Hal
Anthony Borla wrote:
> Hal,
>
> "Hal Vaughan" <hal@thresholddigital.com> wrote in message
> news:GTmnb.46726$HS4.219485@attbi_s01...
>>
>> I've been reading up on file permissions (including FilePermission,
>> Permission, and Permissions). From what I see, these are
>> temporary and forgotten when a program exits (if I'm wrong, tell
>> me, please).
>>
>
> They represent the access the current process and its children [i.e. your
> running program] has to the specified files. In other words, they make
> sense only in context of the current program, and, yes, do not actually
> alter any system-level, file-specific attributes.
>
>>
>> I'm installing a program on a computer and that includes
>> configuration files that change regularly. When I create the
>> configuration files, I want them to be readable and writable by
>> any user running the program, otherwise my
>> program won't be able to function.
>>
>
> This is easily achieved using the relevant operating system utility which
> is nothing more than an interface to the relevant operating system
> function(s) / call(s) which actually perform such tasks. A system
> administrator would normally call such utilities from a script file, or
> perhaps use a friendly graphical interface to execute them.
>
> For instance, on Windows-family systems the 'attrib' and 'cacls' utilities
> would likely be used, while on *NIX and Linux systems the relevant
> utilities are 'chmod' and 'chown'. In both cases, however, 'friendlier'
> utilities may well exist.
>
>>
>> So how can I, from Java, find a way to set the permissions
>> on a file I create (from within Java) so all users can read and
>> write that file whenever they run the program?
>>
>
> The simplest approach is to launch the relevant operating system utilities
> from within your application via 'Runtime.exec'. Dig out the applicable
> operating system manuals and start experimenting :)
>
> A much cleaner approach is to use JNI routines which tap into the relevant
> operating system functionality. A web search may help discover a suitable
> library if this approach is preferred.
>
>>
>> My first thought was to have the program itself, whenever it
>> was started, set the permissions with a FilePermission object,
>> but that doesn't make sense -- if files are not readable or writable
>> by a user, it wouldn't make sense to allow that user to change the
>> permissions.
>>
>
> Correct.
>
>>
>> Thanks for any info.
>>
>
> I hope this helps.
>
> Anthony Borla
- Next message: Phil...: "Re: char to string ????"
- Previous message: Matt Smith: "Re: ICMP packets"
- In reply to: Anthony Borla: "Re: How to set Permissions on New File"
- Next in thread: Anthony Borla: "Re: How to set Permissions on New File"
- Reply: Anthony Borla: "Re: How to set Permissions on New File"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|