Skip to content

Commit

Permalink
simplify user creation by rejecting to auto level up a sys user to an
Browse files Browse the repository at this point in the history
admin user. rockstor#688
  • Loading branch information
schakrava committed Jul 6, 2015
1 parent fe2dc07 commit 538ae74
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/rockstor/storageadmin/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,9 @@ def post(self, request):
invar['group'] = g
break

user_exists = False
for u in users:
if (u.username == invar['username']):
if ((invar['uid'] is None or u.uid == invar['uid']) and
(invar['gid'] is None or u.gid == invar['gid'])):
user_exists = True
else:
handle_exception(Exception(e_msg), request)
handle_exception(Exception(e_msg), request)
elif (u.uid == invar['uid']):
e_msg = ('uid: %d already exists. Please choose a '
'different one.' % invar['uid'])
Expand All @@ -141,9 +136,8 @@ def post(self, request):
auser.save()
invar['user'] = auser

if (not user_exists):
useradd(invar['username'], invar['shell'], uid=invar['uid'],
gid=invar['gid'])
useradd(invar['username'], invar['shell'], uid=invar['uid'],
gid=invar['gid'])
pw_entries = pwd.getpwnam(invar['username'])
invar['uid'] = pw_entries[2]
invar['gid'] = pw_entries[3]
Expand Down

0 comments on commit 538ae74

Please sign in to comment.