Skip to content

Commit

Permalink
Add system_user_pwent function
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpvorderman committed Jun 13, 2017
1 parent e197cad commit 71cd8dd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import socket
import time
import pwd
from datetime import datetime, timedelta
from string import Template
from uuid import UUID, uuid4
Expand Down Expand Up @@ -186,6 +187,23 @@ def check_password( self, cleartext ):
"""
return galaxy.security.passwords.check_password( cleartext, self.password )

def system_user_pwent(self, real_system_username):
'''Gives the system user pwent entry based on e-mail or username depending on the value in real_system_username'''
if real_system_username == 'user_email':
try:
system_user_pwent = pwd.getpwnam(self.email.split('@')[0])
except KeyError:
pass
elif real_system_username == 'username':
try:
system_user_pwent = pwd.getpwnam(self.username)
except KeyError:
pass
else:
log.warning("invalid configuration of real_system_username")
system_user_pwent = None
return system_user_pwent

def all_roles( self ):
"""
Return a unique list of Roles associated with this user or any of their groups.
Expand Down

0 comments on commit 71cd8dd

Please sign in to comment.