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:
parent
003235b117
commit
704ff23ddf
1 changed files with 24 additions and 0 deletions
|
@ -17,6 +17,10 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
|
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import getpass
|
||||||
|
import grp
|
||||||
|
import os
|
||||||
|
import pwd
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
from importlib import import_module, metadata
|
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):
|
if (context.minimum_version <= ssl.TLSVersion.TLSv1_3) and (context.maximum_version >= ssl.TLSVersion.TLSv1_3):
|
||||||
protocols.append("TLSv1.3")
|
protocols.append("TLSv1.3")
|
||||||
return protocols
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue