From 4febf114b83de8b5411e542e80d670cbb78eb5de Mon Sep 17 00:00:00 2001 From: sharatbala Date: Fri, 24 Dec 2021 18:01:00 -0500 Subject: [PATCH 1/2] Improved generated glauth config file - Using new uidnumber and gidnumber instead of "unixid" - added IgnoreCapabilities=true behaviour so that service users can do LDAP search --- app/glauth.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/glauth.py b/app/glauth.py index ae86a2c..dce15b7 100644 --- a/app/glauth.py +++ b/app/glauth.py @@ -32,7 +32,9 @@ def create_glauth_config(): if settings.groupformat and (settings.groupformat != ""): new_config += " groupformat = \"{}\"\n".format(settings.groupformat) if settings.sshkeyattr and (settings.sshkeyattr != ""): - new_config += " sshkeyattr = \"{}\"\n".format(settings.sshkeyattr) + new_config += " sshkeyattr = \"{}\"\n".format(settings.sshkeyattr) + new_config += "[behaviors]\n IgnoreCapabilities = true\n" + new_config += "\n\n## LDAP Users configuration\n" for user in users: new_config += "[[users]]\n" @@ -43,7 +45,7 @@ def create_glauth_config(): new_config += " sn = \"{}\"\n".format(user.surname) if user.mail: new_config += " mail = \"{}\"\n".format(user.mail) - new_config += " unixid = {}\n".format(user.unixid) + new_config += " uidnumber = {}\n".format(user.unixid) new_config += " primarygroup = {}\n".format(user.primarygroup) new_config += " passsha256 = \"{}\"\n".format(user.password_hash) if len(user.othergroups) > 0: @@ -56,7 +58,7 @@ def create_glauth_config(): for group in groups: new_config += "[[groups]]\n" new_config += " name = \"{}\"\n".format(group.name) - new_config += " unixid = {}\n".format(group.unixid) + new_config += " gidnumber = {}\n".format(group.unixid) # Need to count the query results as len() is not working here. if group.included_in.count() > 0: new_config += " includegroups = [ {} ]\n".format(",".join(str(group.unixid) for group in group.included_in)) @@ -68,10 +70,8 @@ def create_glauth_config(): try: f = open(app.config['GLAUTH_CFG_PATH'], "w") except: - return False + return False else: f.write(new_config) f.close() return True - - From 4442abbb306f097a69a9a045c8e9a93e67d409dd Mon Sep 17 00:00:00 2001 From: sharatbala Date: Fri, 24 Dec 2021 18:02:55 -0500 Subject: [PATCH 2/2] Reverted deleted newlines --- app/glauth.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/glauth.py b/app/glauth.py index dce15b7..c7366a4 100644 --- a/app/glauth.py +++ b/app/glauth.py @@ -75,3 +75,5 @@ def create_glauth_config(): f.write(new_config) f.close() return True + +