Browse Source

prevent password logging

bugfixes
harshadyeola 10 years ago
parent
commit
73f8f6971c
  1. 44
      ee/cli/plugins/site_functions.py
  2. 31
      ee/core/aptget.py
  3. 5
      ee/core/shellexec.py

44
ee/cli/plugins/site_functions.py

@ -177,6 +177,15 @@ def setupwordpress(self, data):
Log.debug(self, "Setting up wp-config file") Log.debug(self, "Setting up wp-config file")
if not data['multisite']: if not data['multisite']:
Log.debug(self, "Generating wp-config for WordPress Single site") Log.debug(self, "Generating wp-config for WordPress Single site")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname={0} --dbprefix={1} --dbuser={2} "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_user'])
+ "--dbpass= "
"--extra-php<<PHP \n {1}\nPHP\""
.format(data['ee_db_pass'],
"\n\ndefine(\'WP_DEBUG\', false);"))
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root " EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config " + "core config "
+ "--dbname={0} --dbprefix={1} --dbuser={2} " + "--dbname={0} --dbprefix={1} --dbuser={2} "
@ -185,10 +194,23 @@ def setupwordpress(self, data):
+ "--dbpass={0} " + "--dbpass={0} "
"--extra-php<<PHP \n {1}\nPHP\"" "--extra-php<<PHP \n {1}\nPHP\""
.format(data['ee_db_pass'], .format(data['ee_db_pass'],
"\n\ndefine(\'WP_DEBUG\', false);") "\n\ndefine(\'WP_DEBUG\', false);"),
log=False
) )
else: else:
Log.debug(self, "Generating wp-config for WordPress multisite") Log.debug(self, "Generating wp-config for WordPress multisite")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname={0} --dbprefix={1} "
.format(data['ee_db_name'], ee_wp_prefix)
+ "--dbuser={0} --dbpass= "
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
.format(data['ee_db_user'], data['ee_db_pass'],
"\ndefine(\'WP_ALLOW_MULTISITE\', "
"true);",
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
" true);",
"\n\ndefine(\'WP_DEBUG\', false);"))
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root " EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config " + "core config "
+ "--dbname={0} --dbprefix={1} " + "--dbname={0} --dbprefix={1} "
@ -200,7 +222,8 @@ def setupwordpress(self, data):
"true);", "true);",
"\ndefine(\'WPMU_ACCEL_REDIRECT\'," "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
" true);", " true);",
"\n\ndefine(\'WP_DEBUG\', false);") "\n\ndefine(\'WP_DEBUG\', false);"),
log=False
) )
EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php', EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
os.path.abspath(os.path.join(os.getcwd(), os.pardir))) os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
@ -233,14 +256,29 @@ def setupwordpress(self, data):
if not data['multisite']: if not data['multisite']:
Log.debug(self, "Creating tables for WordPress Single site") Log.debug(self, "Creating tables for WordPress Single site")
Log.debug(self, "php /usr/bin/wp --allow-root core install "
"--url={0} --title={0} --admin_name={1} "
.format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email={1}"
.format(ee_wp_pass, ee_wp_email))
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install " EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install "
"--url={0} --title={0} --admin_name={1} " "--url={0} --title={0} --admin_name={1} "
.format(data['www_domain'], ee_wp_user) .format(data['www_domain'], ee_wp_user)
+ "--admin_password={0} --admin_email={1}" + "--admin_password={0} --admin_email={1}"
.format(ee_wp_pass, ee_wp_email), .format(ee_wp_pass, ee_wp_email),
errormsg="Unable to setup WordPress Tables") errormsg="Unable to setup WordPress Tables",
log=False)
else: else:
Log.debug(self, "Creating tables for WordPress multisite") Log.debug(self, "Creating tables for WordPress multisite")
Log.debug(self, "php /usr/bin/wp --allow-root "
"core multisite-install "
"--url={0} --title={0} --admin_name={1} "
.format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email={1} "
"{subdomains}"
.format(ee_wp_pass, ee_wp_email,
subdomains='--subdomains'
if not data['wpsubdir'] else ''))
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root " EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root "
"core multisite-install " "core multisite-install "
"--url={0} --title={0} --admin_name={1} " "--url={0} --title={0} --admin_name={1} "

31
ee/core/aptget.py

@ -23,20 +23,29 @@ class EEAptGet():
return success return success
except AttributeError as e: except AttributeError as e:
Log.error(self, 'AttributeError: ' + str(e)) Log.error(self, 'AttributeError: ' + str(e))
except FetchFailedException as e:
Log.debug(self, 'SystemError: ' + str(e))
Log.error(self, 'Unable to Fetch update')
def dist_upgrade(): def dist_upgrade():
""" """
Similar to `apt-get upgrade` Similar to `apt-get upgrade`
""" """
apt_cache = apt.cache.Cache() try:
apt_cache.update() apt_cache = apt.cache.Cache()
apt_cache.open(None) apt_cache.update()
apt_cache.upgrade(True) apt_cache.open(None)
success = (apt_cache.commit( apt_cache.upgrade(True)
apt.progress.text.AcquireProgress(), success = (apt_cache.commit(
apt.progress.base.InstallProgress())) apt.progress.text.AcquireProgress(),
#apt_cache.close() apt.progress.base.InstallProgress()))
return success #apt_cache.close()
return success
except AttributeError as e:
Log.error(self, 'AttributeError: ' + str(e))
except FetchFailedException as e:
Log.debug(self, 'SystemError: ' + str(e))
Log.error(self, 'Unable to Fetch update')
def install(self, packages): def install(self, packages):
""" """
@ -59,7 +68,7 @@ class EEAptGet():
return False return False
else: else:
try: try:
print(pkg.name) # print(pkg.name)
pkg.mark_install() pkg.mark_install()
except Exception as e: except Exception as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
@ -108,7 +117,7 @@ class EEAptGet():
return False return False
else: else:
try: try:
print(pkg.name) # print(pkg.name)
pkg.mark_delete(purge) pkg.mark_delete(purge)
except SystemError as e: except SystemError as e:
Log.debug(self, 'SystemError: ' + str(e)) Log.debug(self, 'SystemError: ' + str(e))

5
ee/core/shellexec.py

@ -11,10 +11,11 @@ class EEShellExec():
def __init__(): def __init__():
pass pass
def cmd_exec(self, command, errormsg=''): def cmd_exec(self, command, errormsg='', log=True):
"""Run shell command from Python""" """Run shell command from Python"""
try: try:
Log.debug(self, "Running command: {0}".format(command)) if log:
Log.debug(self, "Running command: {0}".format(command))
retcode = subprocess.getstatusoutput(command) retcode = subprocess.getstatusoutput(command)
if retcode[0] == 0: if retcode[0] == 0:
return True return True

Loading…
Cancel
Save