Skip to content

Commit 1a189df

Browse files
committed
corrected issue where user where 'group' didnt exist of same name caused web-ui to not give any group options
1 parent 22ac141 commit 1a189df

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mounts.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ def loadavg(self):
158158
@cherrypy.expose
159159
def dashboard(self):
160160
from procfs_reader import entries, proc_uptime, disk_free, git_hash
161-
from grp import getgrall, getgrnam, getgrgid
161+
from grp import getgrall, getgrgid
162+
from pwd import getpwnam
162163
from stock_profiles import STOCK_PROFILES
163164

164165
kb_free = dict(entries('', 'meminfo'))['MemFree']
@@ -174,16 +175,16 @@ def dashboard(self):
174175
finally:
175176
st = os.stat(pc_path)
176177
pc_group = getgrgid(st.st_gid).gr_name
178+
179+
primary_group = getgrgid(getpwnam(self.login).pw_gid).gr_name
177180

178181
return dumps({
179182
'uptime': str(proc_uptime()[0]),
180183
'memfree': mb_free,
181184
'whoami': self.login,
182-
'group': getgrnam(self.login).gr_name,
185+
'group': primary_group,
183186
'df': dict(disk_free('/')._asdict()),
184-
'groups': [i.gr_name for i in getgrall()
185-
if self.login in i.gr_mem or \
186-
self.login in [i.gr_name, 'root']],
187+
'groups': [i.gr_name for i in getgrall() if self.login in i.gr_mem or self.login == 'root'] + [primary_group],
187188
'pc_permissions': profile_editable,
188189
'pc_group': pc_group,
189190
'git_hash': git_hash(os.path.dirname(os.path.abspath(__file__))),

0 commit comments

Comments
 (0)