mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 17:59:04 +00:00
Replace INSTALL_LIB on installation.
This restores code removed in r28342, which rewrites sys.path to include the directory in which the Zenmap modules are installed. This is needed to run the program without changes to PYTHONPATH when the installation directory is not among the Python interpreter's default search paths. (/usr/local/lib/python2.7/site-packages/ or a user's home directory are common cases.) A difference is that now we make sure that the directory we are adding is not writable by any other users, to avoid installation mistakes like Debian bug #663217.
This commit is contained in:
@@ -205,6 +205,7 @@ class my_install(install):
|
||||
install.run(self)
|
||||
|
||||
self.set_perms()
|
||||
self.set_modules_path()
|
||||
self.fix_paths()
|
||||
self.create_uninstaller()
|
||||
self.write_installed_files()
|
||||
@@ -306,6 +307,30 @@ 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_dir = self.install_lib
|
||||
if self.root is not None:
|
||||
modules_dir = path_strip_prefix(modules, self.root)
|
||||
|
||||
app_file = open(app_file_name, "r")
|
||||
lines = app_file.readlines()
|
||||
app_file.close()
|
||||
|
||||
for i in range(len(lines)):
|
||||
if re.match(r'^INSTALL_LIB =', lines[i]):
|
||||
lines[i] = "INSTALL_LIB = %s\n" % repr(modules_dir)
|
||||
break
|
||||
else:
|
||||
raise ValueError("INSTALL_LIB replacement not found in %s" % app_file_name)
|
||||
|
||||
app_file = open(app_file_name, "w")
|
||||
app_file.writelines(lines)
|
||||
app_file.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