mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Don't add install_lib to sys.path in setup.py.
Remove the code from setup.py which augments the module search path with install directories such as /usr/local/lib/python2.7/dist-packages/ because doing so is unnecessary, and can also be a potential security risk if distributors do the initial install in world writeable directories such as /tmp and then copy the resultant zenmap to non-writeable dirs for installation on other systems.
This commit is contained in:
@@ -205,7 +205,6 @@ class my_install(install):
|
||||
install.run(self)
|
||||
|
||||
self.set_perms()
|
||||
self.set_modules_path()
|
||||
self.fix_paths()
|
||||
self.create_uninstaller()
|
||||
self.write_installed_files()
|
||||
@@ -307,32 +306,6 @@ for dir in dirs:
|
||||
mode = ((os.stat(uninstaller_filename)[ST_MODE]) | 0555) & 07777
|
||||
os.chmod(uninstaller_filename, mode)
|
||||
|
||||
def set_modules_path(self):
|
||||
app_file_name = os.path.join(self.install_scripts, APP_NAME)
|
||||
# Find where the modules are installed. distutils will put them in
|
||||
# self.install_lib, but that path can contain the root (DESTDIR), so we
|
||||
# must strip it off if necessary.
|
||||
modules = self.install_lib
|
||||
if self.root is not None:
|
||||
modules = path_strip_prefix(modules, self.root)
|
||||
|
||||
ufile = open(app_file_name, "r")
|
||||
ucontent = ufile.readlines()
|
||||
ufile.close()
|
||||
|
||||
# Insert our custom import after the first non-comment line.
|
||||
re_sys = re.compile("^#")
|
||||
uline = 0
|
||||
for line in ucontent:
|
||||
if not re_sys.match(line):
|
||||
break
|
||||
uline += 1
|
||||
ucontent.insert(uline, "\nimport sys\nsys.path.append(%s)\n" % repr(modules))
|
||||
|
||||
ufile = open(app_file_name, "w")
|
||||
ufile.writelines(ucontent)
|
||||
ufile.close()
|
||||
|
||||
def set_perms(self):
|
||||
re_bin = re.compile("(bin|\.sh)")
|
||||
for output in self.get_installed_files():
|
||||
|
||||
Reference in New Issue
Block a user