Skip to content

Commit

Permalink
Do not modify the kickstart user data until apply()
Browse files Browse the repository at this point in the history
The UserData object is handy for sharing data across the two windows
used by the user spoke, but ksdata should not be modified until Done is
clicked.
  • Loading branch information
dashea committed Oct 8, 2015
1 parent 6366f7e commit 7c677c7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pyanaconda/ui/gui/spokes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import re
import os
import copy
from pyanaconda.flags import flags
from pyanaconda.i18n import _, CN_
from pyanaconda.users import cryptPassword, validatePassword, guess_username
Expand Down Expand Up @@ -248,8 +249,10 @@ def __init__(self, *args):
def initialize(self):
NormalSpoke.initialize(self)

# Create a new UserData object to store this spoke's state
# as well as the state of the advanced user dialog.
if self.data.user.userList:
self._user = self.data.user.userList[0]
self._user = copy.copy(self.data.user.userList[0])
else:
self._user = self.data.UserData()

Expand Down Expand Up @@ -378,13 +381,17 @@ def apply(self):
self._user.name = self.username.get_text()
self._user.gecos = self.fullname.get_text()

# the user will be created only if the username is set
# Copy the spoke data back to kickstart
# If the user name is not set, no user will be created.
if self._user.name:
if self._user not in self.data.user.userList:
self.data.user.userList.append(self._user)
ksuser = copy.copy(self._user)

elif self._user in self.data.user.userList:
self.data.user.userList.remove(self._user)
if not self.data.user.userList:
self.data.user.userList.append(ksuser)
else:
self.data.user.userList[0] = ksuser
elif self.data.user.userList:
self.data.user.userList.pop(0)

@property
def sensitive(self):
Expand Down

0 comments on commit 7c677c7

Please sign in to comment.