mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
851 B
Python
32 lines
851 B
Python
![]()
5 years ago
|
from __future__ import (absolute_import, division, print_function)
|
||
|
__metaclass__ = type
|
||
![]()
6 years ago
|
|
||
|
import os
|
||
![]()
5 years ago
|
import sys
|
||
![]()
6 years ago
|
|
||
|
|
||
|
def main():
|
||
![]()
5 years ago
|
root_dir = os.getcwd() + os.path.sep
|
||
|
|
||
![]()
5 years ago
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
||
|
if not os.path.islink(path.rstrip(os.path.sep)):
|
||
|
continue
|
||
![]()
6 years ago
|
|
||
![]()
5 years ago
|
if not os.path.exists(path):
|
||
|
print('%s: broken symlinks are not allowed' % path)
|
||
![]()
5 years ago
|
continue
|
||
![]()
6 years ago
|
|
||
![]()
5 years ago
|
if path.endswith(os.path.sep):
|
||
|
print('%s: symlinks to directories are not allowed' % path)
|
||
![]()
5 years ago
|
continue
|
||
|
|
||
|
real_path = os.path.realpath(path)
|
||
|
|
||
|
if not real_path.startswith(root_dir):
|
||
|
print('%s: symlinks outside content tree are not allowed: %s' % (path, os.path.relpath(real_path, os.path.dirname(path))))
|
||
|
continue
|
||
![]()
6 years ago
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|