1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-08-04 18:22:26 +00:00

add support function to display user/group radicale is running

This commit is contained in:
Peter Bieringer 2025-06-29 08:33:55 +02:00
parent 003235b117
commit 704ff23ddf

View file

@ -17,6 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
import getpass
import grp
import os
import pwd
import ssl
import sys
from importlib import import_module, metadata
@ -214,3 +218,23 @@ def ssl_get_protocols(context):
if (context.minimum_version <= ssl.TLSVersion.TLSv1_3) and (context.maximum_version >= ssl.TLSVersion.TLSv1_3):
protocols.append("TLSv1.3")
return protocols
def user_groups_as_string():
if sys.platform != "win32":
euid = os.geteuid()
egid = os.getegid()
username = pwd.getpwuid(euid)[0]
gids = os.getgrouplist(username, egid)
groups = []
for gid in gids:
try:
gi = grp.getgrgid(gid)
groups.append("%s(%d)" % (gi.gr_name, gid))
except Exception:
groups.append("%s(%d)" % (gid, gid))
s = "user=%s(%d) groups=%s" % (username, euid, ','.join(groups))
else:
username = getpass.getuser()
s = "user=%s" % (username)
return s