Skip to content

Commit

Permalink
protect from making / absent
Browse files Browse the repository at this point in the history
  • Loading branch information
thatch45 committed Mar 26, 2013
1 parent 037edd5 commit 7a3adf5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions salt/states/file.py
Expand Up @@ -529,6 +529,8 @@ def absent(name):
return _error(
ret, 'Specified file {0} is not an absolute path'.format(name)
)
if name == '/':

This comment has been minimized.

Copy link
@SEJeff

SEJeff Mar 26, 2013

Contributor

How about:

if name in ('.', '..', '/'):

There is likely never ever a time you'd want to on purpose do that. Especially seeing how . by default is normally root's homedir aka /root and .. is by default /

This comment has been minimized.

Copy link
@thatch45

thatch45 Mar 26, 2013

Author Member

No need, there is an absolute path check right above

This comment has been minimized.

Copy link
@SEJeff

SEJeff Mar 26, 2013

Contributor

Fair enough. We can never be too paranoid about doing the equiv of rm -rf / though. I like the extra belt and suspenders because it is only a matter of time before that code gets shuffled around.

return _error(ret, 'Refusing to make "/" absent')
if os.path.isfile(name) or os.path.islink(name):
if __opts__['test']:
ret['result'] = None
Expand Down

0 comments on commit 7a3adf5

Please sign in to comment.