Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow missing rhn.conf file #7455

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python/spacewalk/common/rhnConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def is_initialized(self):
def modifiedYN(self):
"""returns last modified time diff if rhn.conf has changed."""

if not os.path.exists(self.filename):
return 0

try:
si = os.stat(self.filename)
except OSError:
Expand Down Expand Up @@ -142,7 +145,8 @@ def parse(self):

# Now that we parsed the defaults, we parse the multi-key
# self.filename configuration (ie, /etc/rhn/rhn.conf)
self.__parsedConfig = parse_file(self.filename)
if os.path.exists(self.filename):
self.__parsedConfig = parse_file(self.filename)

# And now generate and cache the current component
self.__merge()
Expand Down
4 changes: 2 additions & 2 deletions python/spacewalk/common/rhnLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def initLOG(log_file="stderr", level=0, component=""):

# fetch uid, gid so we can do a "chown ..."
with cfg_component(component=None) as CFG:
apache_uid, apache_gid = getUidGid(CFG.httpd_user, CFG.httpd_group)
apache_uid, apache_gid = getUidGid(CFG.get('httpd_user', 'wwwrun'), CFG.get('httpd_group', 'www'))

try:
os.makedirs(log_path)
Expand Down Expand Up @@ -187,7 +187,7 @@ def __init__(self, log_file, level, component):
set_close_on_exec(self.fd)
if newfileYN:
with cfg_component(component=None) as CFG:
apache_uid, apache_gid = getUidGid(CFG.httpd_user, CFG.httpd_group)
apache_uid, apache_gid = getUidGid(CFG.get('httpd_user', 'wwwrun'), CFG.get('httpd_group', 'www'))
os.chown(self.file, apache_uid, apache_gid)
os.chmod(self.file, int('0660', 8))
except:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Accept missing rhn.conf file
6 changes: 3 additions & 3 deletions python/uyuni/common/fileutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def createPath(path, user=None, group=None, chmod=int('0755', 8)):
"""
with cfg_component(component=None) as CFG:
if user is None:
user = CFG.httpd_user
user = CFG.get('httpd_user', 'wwwrun')
if group is None:
group = CFG.httpd_group
group = CFG.get('httpd_group', 'www')

path = cleanupAbsPath(path)
if not os.path.exists(path):
Expand All @@ -324,7 +324,7 @@ def setPermsPath(path, user=None, group='root', chmod=int('0750', 8)):
"""chown user.group and set permissions to chmod"""
if user is None:
with cfg_component(component=None) as CFG:
user = CFG.httpd_user
user = CFG.get('httpd_user', 'wwwrun')

if not os.path.exists(path):
raise OSError("*** ERROR: Path doesn't exist (can't set permissions): %s" % path)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Accept missing rhn.conf file