Revert "Set permissions when writing files, log less data"

This reverts commit e2f8951940.
This commit is contained in:
VirtuBox
2024-05-29 02:07:08 +02:00
parent 7411c3f387
commit 36aa70fb52
3 changed files with 11 additions and 7 deletions

View File

@@ -903,6 +903,7 @@ else
echo echo
wo_lib_echo "WordOps Documentation : https://docs.wordops.net" wo_lib_echo "WordOps Documentation : https://docs.wordops.net"
wo_lib_echo "WordOps Community Forum : https://community.wordops.net" wo_lib_echo "WordOps Community Forum : https://community.wordops.net"
wo_lib_echo "WordOps Community Chat : https://chat.wordops.net"
echo echo
wo_lib_echo "Give WordOps a GitHub star : https://github.com/WordOps/WordOps/" wo_lib_echo "Give WordOps a GitHub star : https://github.com/WordOps/WordOps/"
echo echo

View File

@@ -1,6 +1,8 @@
import csv import csv
import os import os
import requests
from wo.core.fileutils import WOFileUtils from wo.core.fileutils import WOFileUtils
from wo.core.git import WOGit from wo.core.git import WOGit
from wo.core.logging import Log from wo.core.logging import Log
@@ -53,9 +55,10 @@ class WOAcme:
WOAcme.check_acme(self) WOAcme.check_acme(self)
acme_list = WOShellExec.cmd_exec_stdout( acme_list = WOShellExec.cmd_exec_stdout(
self, "{0} ".format(WOAcme.wo_acme_exec) + self, "{0} ".format(WOAcme.wo_acme_exec) +
"--list --listraw", log=False) "--list --listraw")
if acme_list: if acme_list:
WOFileUtils.textwrite(self, '/var/lib/wo/cert.csv', acme_list, perm="0o600") WOFileUtils.textwrite(self, '/var/lib/wo/cert.csv', acme_list)
WOFileUtils.chmod(self, '/var/lib/wo/cert.csv', 0o600)
else: else:
Log.error(self, "Unable to export certs list") Log.error(self, "Unable to export certs list")
@@ -91,7 +94,7 @@ class WOAcme:
if not WOShellExec.cmd_exec( if not WOShellExec.cmd_exec(
self, "{0} ".format(WOAcme.wo_acme_exec) + self, "{0} ".format(WOAcme.wo_acme_exec) +
"--issue -d '{0}' {1} -k {2} -f" "--issue -d '{0}' {1} -k {2} -f"
.format(all_domains, acme_mode, keylenght), log=False): .format(all_domains, acme_mode, keylenght)):
Log.failed(self, "Issuing SSL cert with acme.sh") Log.failed(self, "Issuing SSL cert with acme.sh")
if acmedata['dns'] is True: if acmedata['dns'] is True:
Log.error( Log.error(
@@ -171,7 +174,7 @@ class WOAcme:
try: try:
WOShellExec.cmd_exec( WOShellExec.cmd_exec(
self, "{0} ".format(WOAcme.wo_acme_exec) + self, "{0} ".format(WOAcme.wo_acme_exec) +
"--renew -d {0} --ecc --force".format(domain), log=False) "--renew -d {0} --ecc --force".format(domain))
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.error(self, 'Unable to renew certificate') Log.error(self, 'Unable to renew certificate')

View File

@@ -342,14 +342,14 @@ class WOFileUtils():
continue continue
return True return True
def textwrite(self, path, content, perm="0o644"): def textwrite(self, path, content):
""" """
Write content into a file Write content into a file
""" """
Log.debug(self, "Writing content in {0}".format(path)) Log.debug(self, "Writing content in {0}".format(path))
try: try:
with os.fdopen(os.open(path, os.O_WRONLY | os.O_CREAT, perm), with open("{0}".format(path),
'w', encoding='utf-8') as final_file: encoding='utf-8', mode='w') as final_file:
final_file.write('{0}'.format(content)) final_file.write('{0}'.format(content))
except IOError as e: except IOError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))