<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="https://tanguy.ortolo.eu/blog/feed/rss/commentaires/" />
	<link>https://tanguy.ortolo.eu/blog/article113/test-symlink</link>
	<language>en</language>
	<description>a blog about Debian and self-hosting</description>
	<lastBuildDate>Thu, 07 Nov 2013 19:28:00 +0000</lastBuildDate>
	<generator>PluXml</generator>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by Victor Nițu @ thursday 07 november 2013, 19:28</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383852486-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383852486-1</guid>
		<description>If I may add, I guess any other option than `ln -sf` would end up being more expensive than simply forcing the symlinking. I wonder now if there are any reasons for *not* doing the &amp;#039;-sf&amp;#039; move, other than not looking like a hackish script.</description>
		<pubDate>Thu, 07 Nov 2013 19:28:00 +0000</pubDate>
		<dc:creator>Victor Nițu</dc:creator>
	</item>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by Tanguy @ thursday 31 october 2013, 08:47</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383209230-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383209230-1</guid>
		<description>@russ : Right, thanks for that information. I do not like it, since it may require to spawn additional processes, but most shells have test built-in, fortunately.</description>
		<pubDate>Thu, 31 Oct 2013 08:47:00 +0000</pubDate>
		<dc:creator>Tanguy</dc:creator>
	</item>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by russ @ wednesday 30 october 2013, 23:47</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383176840-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383176840-1</guid>
		<description>POSIX marks the &amp;quot;-a&amp;quot; option of test obsolescent; it would be better written as &amp;quot;] &amp;amp;&amp;amp; [&amp;quot;.</description>
		<pubDate>Wed, 30 Oct 2013 23:47:00 +0000</pubDate>
		<dc:creator>russ</dc:creator>
	</item>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by Guto @ wednesday 30 october 2013, 20:34</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383165251-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383165251-1</guid>
		<description>I use readlink to do this kind of verfication:

if ! readlink -e /target/file &amp;gt;/dev/null 2&amp;gt;&amp;amp;1
then
    ln -s /orig/file /target/file
fi</description>
		<pubDate>Wed, 30 Oct 2013 20:34:00 +0000</pubDate>
		<dc:creator>Guto</dc:creator>
	</item>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by Tanguy @ wednesday 30 october 2013, 16:04</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383149075-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383149075-1</guid>
		<description>@Patrick, @Zack Weinberg : Yes, in fact I forgot to mention the context. It is not in writing a generic piece of software, but a Debian package maintainer script, the symlink being to configure a web server for a web-based software. Here, it is not a matter of security, but only of avoiding a failure case if the user already put that link himself with a previous release.

The user may indeed very well find a hard and tricky way to make the installation script fail, but that possibility is not relevant here, because there are already plenty of ways of doing that, the first one being to interrupt the installation with a ^C, a SIGTERM or a SIGKILL.</description>
		<pubDate>Wed, 30 Oct 2013 16:04:00 +0000</pubDate>
		<dc:creator>Tanguy</dc:creator>
	</item>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by Zack Weinberg @ wednesday 30 october 2013, 15:53</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383148424-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383148424-1</guid>
		<description>... that should have been

&amp;lt;code&amp;gt;perl -e &amp;#039;symlink($ARGV[0], $ARGV[1]) or $!{EEXIST} or die &amp;quot;$ARGV[1]: $!\n&amp;quot;&amp;#039; /some/file /the/destination&amp;lt;/code&amp;gt;</description>
		<pubDate>Wed, 30 Oct 2013 15:53:00 +0000</pubDate>
		<dc:creator>Zack Weinberg</dc:creator>
	</item>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by Zack Weinberg @ wednesday 30 october 2013, 15:52</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383148370-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383148370-1</guid>
		<description>Your &amp;quot;improved&amp;quot; code still has a bug: there&amp;#039;s a gap between the check and the link creation, where another process could come in and create the file.  Better to just create the link but allow it to fail:

    ln -s /some/file /the/destination 2&amp;gt; /dev/null || :

or if you want the script to stop when some *other* kind of error pops up

    perl -e &amp;#039;symlink($ARGV[0], $ARGV[1]) or $!{EEXIST} or die &amp;quot;$ARGV[1]: $!\n&amp;quot;&amp;#039;</description>
		<pubDate>Wed, 30 Oct 2013 15:52:00 +0000</pubDate>
		<dc:creator>Zack Weinberg</dc:creator>
	</item>
	<item>
		<title>Beware of symlinks when testing a file existence - Written by Patrick @ wednesday 30 october 2013, 15:50</title> 
		<link>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383148250-1</link>
		<guid>https://tanguy.ortolo.eu/blog/article113/test-symlink/#c1383148250-1</guid>
		<description>Please note, that the latter code is still incorrect, as it contains a race condition. It is triggered when externally creating the link after the check failed and before the script creates the link.

As so often, it&amp;#039;s really hard to get this right with a shell. Depending on your use case, &amp;quot;ln -sf&amp;quot; might be an option.</description>
		<pubDate>Wed, 30 Oct 2013 15:50:00 +0000</pubDate>
		<dc:creator>Patrick</dc:creator>
	</item>
		<title>Tanguy Ortolo - Beware of symlinks when testing a file existence - Comments</title> 
</channel>
</rss>