public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* ln -f changes permissions on NT
@ 2000-09-18 12:53 Tweedy, Laura
  2000-09-18 15:48 ` Chris Faylor
  0 siblings, 1 reply; 2+ messages in thread
From: Tweedy, Laura @ 2000-09-18 12:53 UTC (permalink / raw)
  To: 'cygwin@sourceware.cygnus.com'

Hello...

I am running into permission problems with ln -f.  I have a file that
is read-only and I want it to remain so.  I am making a hard link to
it in another location.  This link is done in a makefile which uses
ln -f to make the link.  The link works fine, but if making the target
requires that it be removed first, the permissions become read-write.

I believe this is the result of the target being forcibly removed
before it is linked again.  I saw in the source (for ln or _unlink, I
can't remember) that when files are read-only but are being removed
anyway, their permissions are changed and the remove is tried again.
I think this "transient" permission for the file is sticking around
longer than intended.

On Unix (I tried Solaris and Linux), ln -f keeps the permissions of
the source file, even if the target has to be removed.  On NT, the
permissions necessary to removed the target stay around.

This problem of transient permissions is evident in rm -f too.  On
Unix, rm -f keeps the permissions on the other links while removing
one of the links.  On NT, the permissions for removing stay around.

Below is a transcript showing NT vs. Solaris and their behaviours.
I am looking for a work-around, but I thought I would report it
anyway in case it hasn't been reported.  I'm running with the 1.1.2
cygwin DLL (I think).  I didn't see in the changes for 1.1.4 that this
was fixed, but I haven't tried it.  My apologies if it's fixed there.

Thanks!
laura

NT:
d:\>ls -l foo
-r--r--r--   1 tweedy   Administ       13 Sep 18 15:35 foo

d:\>ln -f foo bar

d:\>ls -l foo bar
-r--r--r--   2 tweedy   Administ       13 Sep 18 15:35 bar
-r--r--r--   2 tweedy   Administ       13 Sep 18 15:35 foo

d:\>ln -f foo bar

d:\>ls -l foo bar
-rw-r--r--   2 tweedy   Administ       13 Sep 18 15:35 bar
-rw-r--r--   2 tweedy   Administ       13 Sep 18 15:35 foo

d:\>

Solaris:
quadsun: ~ 20 > ls -l foo
-r--r--r--   1 tweedy   users         12 Sep 14 16:06 foo
quadsun: ~ 21 > ln -f foo bar
quadsun: ~ 22 > ls -l foo bar
-r--r--r--   2 tweedy   users         12 Sep 14 16:06 bar
-r--r--r--   2 tweedy   users         12 Sep 14 16:06 foo
quadsun: ~ 23 > ln -f foo bar
ln: foo and bar are identical
quadsun: ~ 24 > ls -l foo bar
-r--r--r--   2 tweedy   users         12 Sep 14 16:06 bar
-r--r--r--   2 tweedy   users         12 Sep 14 16:06 foo
quadsun: ~ 25 > 



NT:
d:\>ls -l foo bar
-r--r--r--   2 tweedy   Administ       13 Sep 18 15:35 bar
-r--r--r--   2 tweedy   Administ       13 Sep 18 15:35 foo

d:\>rm -f bar

d:\>ls -l foo
-rw-r--r--   1 tweedy   Administ       13 Sep 18 15:35 foo

d:\>

Solaris:
quadsun: ~ 29 > ls -l foo bar
-r--r--r--   2 tweedy   users         12 Sep 14 16:06 bar
-r--r--r--   2 tweedy   users         12 Sep 14 16:06 foo
quadsun: ~ 30 > rm -f bar
quadsun: ~ 31 > ls -l foo
-r--r--r--   1 tweedy   users         12 Sep 14 16:06 foo
quadsun: ~ 32 > 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ln -f changes permissions on NT
  2000-09-18 12:53 ln -f changes permissions on NT Tweedy, Laura
@ 2000-09-18 15:48 ` Chris Faylor
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Faylor @ 2000-09-18 15:48 UTC (permalink / raw)
  To: 'cygwin@sourceware.cygnus.com'

On Mon, Sep 18, 2000 at 03:53:43PM -0400, Tweedy, Laura wrote:
>I am running into permission problems with ln -f.  I have a file that
>is read-only and I want it to remain so.  I am making a hard link to
>it in another location.  This link is done in a makefile which uses
>ln -f to make the link.  The link works fine, but if making the target
>requires that it be removed first, the permissions become read-write.

I don't see an easy way around this.  The file system semantics for
Windows are different from UNIX.  On UNIX, you can unlink a file which
has read only permission.  AFAIK, you can't do that on Windows without
first changing the permissions of the file.

So, if you change the permissions to unlink a file you also change the
permissions of any files hard linked to that file, just like UNIX.  The
problem is that there is no way of knowing (or at least I don't know how
to find out) which files are linked to the file that you're deleting.

Like I said, I don't see any easy way around this problem but if someone
has a solution, please post it here.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-09-18 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-18 12:53 ln -f changes permissions on NT Tweedy, Laura
2000-09-18 15:48 ` Chris Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).