Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

Java reporting incorrect directory permission under Windows XP?

Thread view: 
howachen@gmail.com - 16 Jul 2006 13:15 GMT
For the following codes:
//---------------------------------
import java.io.File;

public class Test {

    /**
    * @param args
    */
    public static void main(String[] args) {

        File file = new File("c:\\temp");

        System.out.println(file.canWrite());

    }

}
//---------------------------------
It return true, even in the "security" tab, I removed all the users
(i.e. i can't click into the folder using the windows explorer)

why Java return true?
John W. Kennedy - 16 Jul 2006 18:04 GMT
> For the following codes:
> //---------------------------------
[quoted text clipped - 19 lines]
>
> why Java return true?

In Windows, marking a directory "read-only" means only that it cannot be
rmdir'd. Java canWrite==false on a directory means that you can't create
a file in the directory, which Windows won't stop you from doing.

Windows Explorer has its own set of rules, which the operating system
does not enforce, so they don't apply to programs in general, Java or
otherwise.

(In other words, in this, as in so many other areas, Windows is a big,
fat security hole.)

If you had a C program, it would tell you the same thing.

Signature

John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
 -- Charles Williams.  "Taliessin through Logres: Prelude"

howachen@gmail.com - 16 Jul 2006 19:08 GMT
John W. Kennedy

> > For the following codes:
> > //---------------------------------
[quoted text clipped - 38 lines]
> Nourished the land on a fallacy of rational virtue."
>   -- Charles Williams.  "Taliessin through Logres: Prelude"

well, i SUPPOSE Java is a cross-platform language, so the builder of
JVM should take care this, not the responbility of M$, isn't ?

anyway, on Windows XP, how can I tell if I really have the permission
to create new files insides a specific folder?

since canWrite didn't work as above...

thanks....
howachen@gmail.com - 16 Jul 2006 19:22 GMT
John W. Kennedy

> > For the following codes:
> > //---------------------------------
[quoted text clipped - 23 lines]
> rmdir'd. Java canWrite==false on a directory means that you can't create
> a file in the directory, which Windows won't stop you from doing.

in Windows XP (NTFS file system), when you remove all owners in the
security tab, it REALLY means you can't write to the directory, no just
can't rmdir'd
Brandon McCombs - 16 Jul 2006 19:57 GMT
> John W. Kennedy 寫道:
>
[quoted text clipped - 28 lines]
> security tab, it REALLY means you can't write to the directory, no just
> can't rmdir'd

If you are referring to what I think you are your terminology is a bit off.

The groups/users listed in the box on the Security tab are not owners
but just a list of groups/users who have varying levels of access to the
file/folder. You have to click on Advanced button on the Security tab
and click on the Owner tab (on the new popup dialog) in order to
actually see the list of owners and from what I've seen you can't have
more than 1 owner at a time for a folder/file but more than 1 *possible*
owner is listed that you can switch to.
howachen@gmail.com - 17 Jul 2006 03:25 GMT
Brandon McCombs

> > John W. Kennedy
> >
[quoted text clipped - 38 lines]
> more than 1 owner at a time for a folder/file but more than 1 *possible*
> owner is listed that you can switch to.

okay, get to the job...

the main point is:

1.  I cannot create new file inside the folder when i removed all users
in the security tab

i.e. File file = new File("c:\\temp\\test.txt");
file.createNewFile(); // exception - permission denied

2. Java return true when calling
file.canWrite();

is this a contradiction?

thanks...
John W. Kennedy - 17 Jul 2006 04:27 GMT
> John W. Kennedy 寫道:
>
[quoted text clipped - 28 lines]
> security tab, it REALLY means you can't write to the directory, no just
> can't rmdir'd

Silly Java is depending on what Windows tells it (always a mistake),
using a Windows API that was documented as answering the question "can I
write in this directory?", but which in fact reports only on the old
ATTRIB bits. With NTFS you have to go and mess with another whole new
set of API's to get an answer to the question. Because it involves a
large design change, it's been tied up in Java Specification Request
#203, also known as "NIO.2". Unfortunately, this is targeted  for Java
7.0, so it won't be fixed soon.

Signature

John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
  -- Charles Williams.  "Taliessin through Logres: Prelude"



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.