2014-02-27 18:33:27 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
:codeauthor: :email:`Mike Place <mp@saltstack.com`
|
|
|
|
|
|
|
|
|
|
|
|
Tests to ensure that the file permissions are set correctly when
|
|
|
|
importing from the git repo.
|
|
|
|
'''
|
|
|
|
|
2014-02-27 19:58:39 +00:00
|
|
|
# Import python libs
|
2014-02-27 18:33:27 +00:00
|
|
|
import os
|
|
|
|
import stat
|
2014-03-23 18:20:42 +00:00
|
|
|
import pprint
|
2014-02-27 18:33:27 +00:00
|
|
|
|
2014-02-27 19:58:39 +00:00
|
|
|
# Import salt testing libs
|
2014-05-29 21:04:11 +00:00
|
|
|
from salttesting import TestCase, skipIf
|
2014-03-23 16:57:51 +00:00
|
|
|
from salttesting.helpers import ensure_in_syspath
|
2014-02-27 18:33:27 +00:00
|
|
|
|
2014-03-23 16:57:51 +00:00
|
|
|
ensure_in_syspath('..')
|
2014-02-27 18:33:27 +00:00
|
|
|
|
2014-03-23 16:57:51 +00:00
|
|
|
from integration import CODE_DIR
|
2014-02-27 18:33:27 +00:00
|
|
|
|
2014-03-23 18:20:42 +00:00
|
|
|
EXEMPT_DIRS = []
|
|
|
|
EXEMPT_FILES = [
|
|
|
|
'debian/rules',
|
|
|
|
'doc/.scripts/compile-translation-catalogs',
|
|
|
|
'doc/.scripts/download-translation-catalog',
|
|
|
|
'doc/.scripts/setup-transifex-config',
|
|
|
|
'doc/.scripts/update-transifex-source-translations',
|
|
|
|
'pkg/arch/Makefile',
|
|
|
|
'pkg/arch/PKGBUILD',
|
|
|
|
'pkg/arch/PKGBUILD-git',
|
|
|
|
'pkg/arch/PKGBUILD-local',
|
|
|
|
'pkg/arch/git/PKGBUILD',
|
2014-03-24 17:02:23 +00:00
|
|
|
'pkg/rpm/build.py',
|
2014-03-23 18:20:42 +00:00
|
|
|
'pkg/rpm/salt-master',
|
|
|
|
'pkg/rpm/salt-minion',
|
|
|
|
'pkg/rpm/salt-syndic',
|
2014-03-29 01:26:02 +00:00
|
|
|
'pkg/shar/build_shar.sh',
|
2014-03-23 18:20:42 +00:00
|
|
|
'pkg/smartos/esky/install.sh',
|
2014-04-16 00:23:55 +00:00
|
|
|
'salt/cloud/deploy/bootstrap-salt.sh',
|
2014-03-23 18:20:42 +00:00
|
|
|
'salt/templates/git/ssh-id-wrapper',
|
2014-04-08 12:47:26 +00:00
|
|
|
'salt/templates/lxc/salt_tarball',
|
2014-03-23 18:20:42 +00:00
|
|
|
'scripts/salt',
|
|
|
|
'scripts/salt-call',
|
|
|
|
'scripts/salt-cloud',
|
|
|
|
'scripts/salt-cp',
|
|
|
|
'scripts/salt-key',
|
|
|
|
'scripts/salt-master',
|
|
|
|
'scripts/salt-minion',
|
|
|
|
'scripts/salt-run',
|
|
|
|
'scripts/salt-ssh',
|
|
|
|
'scripts/salt-syndic',
|
|
|
|
'setup.py',
|
|
|
|
'tests/integration/mockbin/su',
|
|
|
|
'tests/runtests.py',
|
2014-03-24 17:02:23 +00:00
|
|
|
'tests/saltsh.py',
|
2014-03-23 18:20:42 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
IGNORE_PATHS = [
|
|
|
|
'.git',
|
|
|
|
'.wti',
|
|
|
|
'build',
|
|
|
|
'dist',
|
|
|
|
'salt.egg-info',
|
|
|
|
'.ropeproject',
|
|
|
|
]
|
2014-02-27 18:33:27 +00:00
|
|
|
|
2014-05-29 22:13:42 +00:00
|
|
|
|
2014-05-29 21:04:11 +00:00
|
|
|
@skipIf(True, 'Need to adjust perms')
|
2014-02-27 18:33:27 +00:00
|
|
|
class GitPermTestCase(TestCase):
|
|
|
|
def test_perms(self):
|
2014-03-23 18:20:42 +00:00
|
|
|
suspect_entries = []
|
|
|
|
for root, dirnames, filenames in os.walk(CODE_DIR, topdown=True):
|
|
|
|
for dirname in dirnames:
|
2014-05-29 21:04:11 +00:00
|
|
|
entry = os.path.join(root, dirname)
|
2014-03-23 18:20:42 +00:00
|
|
|
if entry in IGNORE_PATHS:
|
|
|
|
continue
|
|
|
|
|
|
|
|
skip_entry = False
|
|
|
|
for ignore_path in IGNORE_PATHS:
|
|
|
|
if entry.startswith(ignore_path):
|
|
|
|
skip_entry = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if skip_entry:
|
|
|
|
continue
|
|
|
|
|
|
|
|
fn_mode = stat.S_IMODE(os.stat(entry).st_mode)
|
|
|
|
if fn_mode != 493 and entry not in EXEMPT_DIRS: # In octal! 493 == 0755
|
|
|
|
suspect_entries.append(entry)
|
|
|
|
|
|
|
|
for filename in filenames:
|
2014-05-29 21:04:11 +00:00
|
|
|
entry = os.path.join(root, filename)
|
2014-03-23 18:20:42 +00:00
|
|
|
if entry in IGNORE_PATHS:
|
|
|
|
continue
|
|
|
|
|
|
|
|
skip_entry = False
|
|
|
|
for ignore_path in IGNORE_PATHS:
|
|
|
|
if entry.startswith(ignore_path):
|
|
|
|
skip_entry = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if skip_entry:
|
|
|
|
continue
|
|
|
|
|
|
|
|
fn_mode = stat.S_IMODE(os.stat(entry).st_mode)
|
|
|
|
if fn_mode != 420 and entry not in EXEMPT_FILES: # In octal! 420 == 0644
|
|
|
|
suspect_entries.append(entry)
|
|
|
|
|
|
|
|
try:
|
|
|
|
self.assertEqual(suspect_entries, [])
|
|
|
|
except AssertionError:
|
|
|
|
self.fail(
|
|
|
|
'Found file(s) with incorrect permissions:\n{0}'.format(
|
|
|
|
pprint.pformat(sorted(suspect_entries))
|
|
|
|
)
|
|
|
|
)
|
2014-03-23 16:57:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(GitPermTestCase, needs_daemon=False)
|