cluster-env variables are prefixed, which may trigger safety problems

This commit is contained in:
tanjinbo 2022-06-18 10:16:24 +08:00 committed by lkf67640
parent cb28877b0e
commit ebcfeae3f8
3 changed files with 38 additions and 10 deletions

View File

@ -428,8 +428,15 @@ class PostUninstallImpl:
# clean local node environment variable # clean local node environment variable
cmd = "(if [ -s '%s' ]; then " % PROFILE_FILE cmd = "(if [ -s '%s' ]; then " % PROFILE_FILE
cmd += "sed -i -e '/^export PATH=\/root\/gauss_om\/%s\/script:" \ cmd += "sed -i -e '/^export PATH=\$PATH:\/root\/gauss_om\/%s\/" \
"\$PATH$/d' %s; fi)" % (self.user, PROFILE_FILE) "script$/d' %s " % (self.user, PROFILE_FILE)
cmd += "-e '/^export PATH=\$PATH:\$GPHOME\/script\/gspylib\/pssh\/bin:" \
"\$GPHOME\/script$/d' %s " % PROFILE_FILE
cmd += "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/script\/gspylib\/clib:" \
"\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE
cmd += "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/lib:" \
"\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE
cmd +="-e '/^export PYTHONPATH=\$GPHOME\/lib$/d' %s; fi) " % PROFILE_FILE
self.logger.debug( self.logger.debug(
"Command for deleting environment variable: %s" % cmd) "Command for deleting environment variable: %s" % cmd)
(status, output) = subprocess.getstatusoutput(cmd) (status, output) = subprocess.getstatusoutput(cmd)

View File

@ -1447,6 +1447,16 @@ Common options:
"Deleting crash LD_LIBRARY_PATH in user environment variables.") "Deleting crash LD_LIBRARY_PATH in user environment variables.")
# clean PATH # clean PATH
if userProfile is ClusterConstants.ETC_PROFILE:
FileUtil.deleteLine(userProfile,
"^\\s*export\\s*PATH=\\$PATH:\\$GPHOME\\/pssh-2.3.1\\/bin:"
"\\$GPHOME\\/script$")
FileUtil.deleteLine(userProfile,
"^\\s*export\\s*PATH=\\$PATH:\\$GPHOME\\/script\\/gspylib\\"
"/pssh\\/bin:\\$GPHOME\\/script$")
FileUtil.deleteLine(userProfile,
"^\\s*export\\s*PATH=\\$PATH:\\/root\\/gauss_om\\/%s\\"
"/script$" % self.user)
FileUtil.deleteLine(userProfile, FileUtil.deleteLine(userProfile,
"^\\s*export\\s*PATH=\\$GPHOME\\/pssh-2.3.1\\/bin:" "^\\s*export\\s*PATH=\\$GPHOME\\/pssh-2.3.1\\/bin:"
"\\$GPHOME\\/script:\\$PATH$") "\\$GPHOME\\/script:\\$PATH$")
@ -1480,9 +1490,14 @@ Common options:
FileUtil.writeFile(userProfile, FileUtil.writeFile(userProfile,
["export GPHOME=%s" % self.clusterToolPath]) ["export GPHOME=%s" % self.clusterToolPath])
# set PATH # set PATH
FileUtil.writeFile(userProfile, [ if userProfile is ClusterConstants.ETC_PROFILE:
"export PATH=$GPHOME/script/gspylib/pssh/bin:" FileUtil.writeFile(userProfile, [
"$GPHOME/script:$PATH"]) "export PATH=$PATH:$GPHOME/script/gspylib/pssh/bin:"
"$GPHOME/script"])
else:
FileUtil.writeFile(userProfile, [
"export PATH=$GPHOME/script/gspylib/pssh/bin:"
"$GPHOME/script:$PATH"])
# set LD_LIBRARY_PATH # set LD_LIBRARY_PATH
FileUtil.writeFile(userProfile, [ FileUtil.writeFile(userProfile, [
"export LD_LIBRARY_PATH=" "export LD_LIBRARY_PATH="
@ -2455,7 +2470,10 @@ Common options:
# set om root script path # set om root script path
userProfile = self.getUserProfile() userProfile = self.getUserProfile()
FileUtil.writeFile(userProfile, ["export PATH=%s:$PATH" % om_root_path]) if userProfile is ClusterConstants.ETC_PROFILE:
FileUtil.writeFile(userProfile, ["export PATH=$PATH:%s" % om_root_path])
else:
FileUtil.writeFile(userProfile, ["export PATH=%s:$PATH" % om_root_path])
# delete root scripts in GPHOME # delete root scripts in GPHOME
om_user_path = os.path.join(self.clusterToolPath, "script") om_user_path = os.path.join(self.clusterToolPath, "script")
user_om_files = os.listdir(om_user_path) user_om_files = os.listdir(om_user_path)

View File

@ -379,11 +379,14 @@ class Postuninstall(LocalBaseOM):
cmd += "sed -i -e '/^export GPHOME=%s$/d' %s " % ( cmd += "sed -i -e '/^export GPHOME=%s$/d' %s " % (
self.clusterToolPath.replace('/', '\/'), PROFILE_FILE) self.clusterToolPath.replace('/', '\/'), PROFILE_FILE)
cmd += \ cmd += \
"-e '/^export PATH=\$GPHOME\/pssh-2.3.1\/bin:" \ "-e '/^export PATH=\$PATH:\$GPHOME\/pssh-2.3.1\/bin:" \
"\$GPHOME\/script:\$PATH$/d' %s " % PROFILE_FILE "\$GPHOME\/script$/d' %s " % PROFILE_FILE
cmd += \ cmd += \
"-e '/^export PATH=\$GPHOME\/script\/gspylib\/pssh\/bin:" \ "-e '/^export PATH=\$PATH:\$GPHOME\/script\/gspylib\/pssh\/bin:" \
"\$GPHOME\/script:\$PATH$/d' %s " % PROFILE_FILE "\$GPHOME\/script$/d' %s " % PROFILE_FILE
cmd += \
"-e '/^export LD_LIBRARY_PATH=\$GPHOME\/script\/gspylib\/clib:" \
"\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE
cmd += \ cmd += \
"-e '/^export LD_LIBRARY_PATH=\$GPHOME\/lib:" \ "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/lib:" \
"\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE "\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE