Home directory not seen as writable in Vista

D

David Sudlow

I came across this problem whilst trying to get started with the
OpenOffice::OODoc module, but I have reduced it to the simple script below:

if (-w ".") {print "writable\n"} else {print "Not writeable\n"}

This gives 'writable' in xp or linux, but 'not writable' in vista, when
run from a folder in my home directory.

Same result for:
perl -e "if (-w qq{.}) {print qq{writable\n}} else {print qq{Not
writeable\n}}"

from the command line.

Is this a perl on vista issue or something funny with my machine's set-up?

Dave
 
S

Sisyphus

..
..
This gives 'writable' in xp or linux, but 'not writable' in vista, when
run from a folder in my home directory.

Same result for:
writeable\n}}"

from the command line.

Is this a perl on vista issue or something funny with my machine's set-up?

It's more likely something with your machine's set-up, rather than anything
to do with perl.

The only directories I could find where that one liner reported "Not
writable" were "Program Files" and "Program Files (x86)" - running from a
user account on Vista Business 64, with perl-5.8.8.

Which version of perl are you running ?
What is the full path to your home directory ?

Cheers,
Rob
 
D

David Sudlow

Sisyphus said:
.
.

It's more likely something with your machine's set-up, rather than
anything to do with perl.

The only directories I could find where that one liner reported "Not
writable" were "Program Files" and "Program Files (x86)" - running from
a user account on Vista Business 64, with perl-5.8.8.

Which version of perl are you running ?
What is the full path to your home directory ?

Cheers,
Rob

ActiveState Perl 5.8.8 build 820

My home directory is c:/Users/dave and I have tried running from various
sub-directories therein.

The problem is not permissions as such but the result of the -w test
when applied to a directory.

The following script:

use Cwd;
print "Current directory: " . getcwd() . "\n";
if (-w ".") {print "writable\n"} else {print "Not writeable\n"}
open (LOG, ">", "logfile") or die "Can't create logfile";
print "Opened logfile\n";
if (-w "./logfile") {print "writable\n"} else {print "Not writeable\n"}
print LOG "Log\n" or die "Unable to print to logfile\n";
close LOG or die "Unable to close logfile\n";

gives me this result (!):

C:\Users\dave\Desktop\Test_ooDoc>perl write.pl
Current directory: C:/Users/dave/Desktop/Test_ooDoc
Not writeable
Opened logfile
writable

So I can write to the directory from perl despite the negative test.

This leads to the problem using OpenOffice::OODoc as it performs the
test and believes the false result.
 
D

David Sudlow

David said:
ActiveState Perl 5.8.8 build 820

My home directory is c:/Users/dave and I have tried running from various
sub-directories therein.

The problem is not permissions as such but the result of the -w test
when applied to a directory.

The following script:

use Cwd;
print "Current directory: " . getcwd() . "\n";
if (-w ".") {print "writable\n"} else {print "Not writeable\n"}
open (LOG, ">", "logfile") or die "Can't create logfile";
print "Opened logfile\n";
if (-w "./logfile") {print "writable\n"} else {print "Not writeable\n"}
print LOG "Log\n" or die "Unable to print to logfile\n";
close LOG or die "Unable to close logfile\n";

gives me this result (!):

C:\Users\dave\Desktop\Test_ooDoc>perl write.pl
Current directory: C:/Users/dave/Desktop/Test_ooDoc
Not writeable
Opened logfile
writable

So I can write to the directory from perl despite the negative test.

This leads to the problem using OpenOffice::OODoc as it performs the
test and believes the false result.

This is a weird Vista thing (or a weird interaction between vista's new
version of ntfs and the perl code). I have created a new subfolder in
the above folder and in there it all works as expected. Both folders
have apparently the same permissions and both are writable from perl but
they produce different results for the -w test.
 
S

Sisyphus

..
..
The problem is not permissions as such but the result of the -w test when
applied to a directory. ..
..
This leads to the problem using OpenOffice::OODoc as it performs the test
and believes the false result.

I didn't test the Users tree as rigorously as I should have:

---------------------------------------------------
C:\Users>perl -e "if (-w qq{.}) {print qq{writable\n}} else {print qq{Not
writea
ble\n}}"
Not writeable

C:\Users>cd Rob

C:\Users\Rob>perl -e "if (-w qq{.}) {print qq{writable\n}} else {print
qq{Not wr
iteable\n}}"
writable

C:\Users\Rob>cd Desktop

C:\Users\Rob\Desktop>perl -e "if (-w qq{.}) {print qq{writable\n}} else
{print q
q{Not writeable\n}}"
Not writeable

C:\Users\Rob\Desktop>mkdir Test

C:\Users\Rob\Desktop>cd Test

C:\Users\Rob\Desktop\Test>perl -e "if (-w qq{.}) {print qq{writable\n}} else
{pr
int qq{Not writeable\n}}"
writable

C:\Users\Rob\Desktop\Test>
---------------------------------------------------

Sorry, I don't know why the -w test should determine that your "Test_ooDoc"
directory is "Not writable".

I think there will be people here who can provide a good explanation and
sound advice .... if not try the perl-win32-users mailing list (hosted by
ActiveState) or Perlmonks.

Cheers,
Rob
 
S

Sisyphus

..
..
This is a weird Vista thing (or a weird interaction between vista's new
version of ntfs and the perl code). I have created a new subfolder in the
above folder and in there it all works as expected. Both folders have
apparently the same permissions and both are writable from perl but they
produce different results for the -w test.

What is the difference between the way this "new subfolder" was created,
compared to the way that the "Test_ooDoc" subfolder was created.

I, too, find that there's no correlation between folder permissions (which
seem to invariably be Readonly) and what the -w test returns.

Cheers,
Rob
 
D

David Sudlow

Sisyphus said:
.
.

I didn't test the Users tree as rigorously as I should have:

---------------------------------------------------
C:\Users>perl -e "if (-w qq{.}) {print qq{writable\n}} else {print
qq{Not writea
ble\n}}"
Not writeable

C:\Users>cd Rob

C:\Users\Rob>perl -e "if (-w qq{.}) {print qq{writable\n}} else {print
qq{Not wr
iteable\n}}"
writable

C:\Users\Rob>cd Desktop

C:\Users\Rob\Desktop>perl -e "if (-w qq{.}) {print qq{writable\n}} else
{print q
q{Not writeable\n}}"
Not writeable

C:\Users\Rob\Desktop>mkdir Test

C:\Users\Rob\Desktop>cd Test

C:\Users\Rob\Desktop\Test>perl -e "if (-w qq{.}) {print qq{writable\n}}
else {pr
int qq{Not writeable\n}}"
writable

C:\Users\Rob\Desktop\Test>
---------------------------------------------------

Sorry, I don't know why the -w test should determine that your
"Test_ooDoc" directory is "Not writable".

I think there will be people here who can provide a good explanation and
sound advice .... if not try the perl-win32-users mailing list (hosted
by ActiveState) or Perlmonks.

Cheers,
Rob

I created another folder on the Desktop in the same way as the original
(right click new folder). This one gives 'writeable'.

I noticed that in your tests Users was not writable which is correct,
but that your Desktop wasn't either which is not. So you are seeing the
same symptom (some folders that should test as writable failing the
test). This is a bug either in Vista or perl as far as I can see.
 
D

David Sudlow

David said:
I created another folder on the Desktop in the same way as the original
(right click new folder). This one gives 'writeable'.

I noticed that in your tests Users was not writable which is correct,
but that your Desktop wasn't either which is not. So you are seeing the
same symptom (some folders that should test as writable failing the
test). This is a bug either in Vista or perl as far as I can see.

Even weirder: (based in limited testing) a folder is seen as writable
when created but becomes seen as unwritable if a shortcut to an
executable is created in it (or copied into it). I had a shortcut to
cmd.exe in the original folder to speed up opening a command window
pointing to the right folder. Removing the shortcut does not change the
status of the test back however.
 
S

Sisyphus

..
..
Even weirder: (based in limited testing) a folder is seen as writable when
created but becomes seen as unwritable if a shortcut to an executable is
created in it (or copied into it). I had a shortcut to cmd.exe in the
original folder to speed up opening a command window pointing to the right
folder. Removing the shortcut does not change the status of the test back
however.

I placed a shortcut to cmd.exe into C:\Users\Rob\Desktop\Test and the -w
test still says that folder is writable.

There might be a little more to it. (It's certainly the case that my
C:\Users\Rob\Desktop contains some shortcuts to various executables.)

Cheers,
Rob
 
C

Clenna Lumina

Sisyphus said:
.
.

It's more likely something with your machine's set-up, rather than
anything to do with perl.

The only directories I could find where that one liner reported "Not
writable" were "Program Files" and "Program Files (x86)" - running
from a user account on Vista Business 64, with perl-5.8.8.

Which version of perl are you running ?
What is the full path to your home directory ?

Cheers,
Rob

Vista is also rather badly broken "out of the box"
 
C

Clenna Lumina

Sisyphus said:
.
.

I placed a shortcut to cmd.exe into C:\Users\Rob\Desktop\Test and the
-w test still says that folder is writable.

There might be a little more to it. (It's certainly the case that my
C:\Users\Rob\Desktop contains some shortcuts to various executables.)

Cheers,
Rob

The answer is rather simple: In trying to "protect" users from
themselves (a la self installing malware and such), they ended up
breaking many MANY mechanisms, with absolutely no regard for the
ramifications. IMHO, Vista is a badly broken OS that is best buried in
the mud. Stick with XP or lower, Linux, and such. Vista really should be
avoided.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top