[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mkdir when target exists and is a broken symlink
From: |
Paul Eggert |
Subject: |
Re: mkdir when target exists and is a broken symlink |
Date: |
Tue, 17 May 2005 20:56:19 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
"Avis, Ed" <address@hidden> writes:
> There could be some kind of -f, --follow option so that mkdir will
> create the directory pointed to.
There is a potential security problem there, if the symbolic link
is in a directory writable by an attacker.
> You'd probably use it together with -p. Then 'mkdir -fp' would be a
> way to try everything sensible to make sure the destination exists
> and can be used as a directory (ie, is a directory itself or a
> symlink to one).
Perhaps "mkdir -F -p" would also remove files that got in the way? :-)
> Is this a sensible thing to put in mkdir or is there some existing Unix
> idiom that does what I want?
Not in POSIX/Unix, but in coreutils 5.3.0 and later: either "mkdir -p
$(readlink -f file)" or "mkdir -p $(readlink -m file)", depending on
the exact semantics that you want. But think about the security
problems.
ftp://alpha.gnu.org/gnu/coreutils/coreutils-5.3.0.tar.gz
> I note that 'touch foo' when foo is a broken symlink will create the
> link destination if possible (though without making any directories,
> obviously).
POSIX requires this, but it is arguably a misfeature, due to the
security issues mentioned. Perhaps we should add an option to "touch"
to disable it?
- mkdir when target exists and is a broken symlink, Avis, Ed, 2005/05/17
- Re: mkdir when target exists and is a broken symlink,
Paul Eggert <=
- Re: mkdir when target exists and is a broken symlink, Eric Blake, 2005/05/17
- RE: mkdir when target exists and is a broken symlink, Avis, Ed, 2005/05/18
- Re: mkdir when target exists and is a broken symlink, Eric Blake, 2005/05/18
- RE: mkdir when target exists and is a broken symlink, Avis, Ed, 2005/05/20