saltstack/salt — pull request #2836 by UtahDave (2012-12-08 00:03:07+00:00)
Title: Fix exception thrown when symlink target is missing. Fixes #2830

Fixes #2830
os.stat() follows symlinks to their targets.
If the target is missing, os.stat() throws an exception when it tries
to stat the symlink.

Switch to using os.lstat(), which works on the actual symlink and acts
on files and directories as usual.

I believe this also closes a potential security issue where someone
could slip in a symlink to /etc/passwd, for example and change ownership.

The current behavior will cause file.directory to ONLY do work
on the directory structure specified. Symlinks to files outside the
specified directory are not followed.