Commits

Rodrigo Bistolfi committed 0138008

users: assert always failed anyway :)

  • Participants
  • Parent commits a636529

Comments (0)

Files changed (1)

vinstall/backend/users.py

 __author__ = "Moises Henriquez"
 __author_email__ = "moc.liamg@xnl.E0M"[::-1]
 
-"""Api for managing and creating user accounts on VectorLinux"""
+
+"""Api for managing and creating user accounts on VectorLinux
+
+"""
+
+
 import pwd
 import grp
 import crypt
 import subprocess as sp
 import unittest
 from utils import Chroot
-#from vinstall.backend.utils import Chroot
 
 
 class User(object):
         self.fullname = None
 
     def _setup_home(self):
-        """Setup the default home directory for this user"""
-        # This should not be needed, but just in case someone
-        # decides to call this directly.
-        assert self._system_data is not None, "User account not in system"
-        assert self.login is not None, "Does this account exist yet?"
+        """Setup the default home directory for this user
+        
+        """
+        #assert self._system_data is not None, "User account not in system"
+        #assert self.login is not None, "Does this account exist yet?"
         SKELPATH = "/etc/skel"
         TARGETDIR= self.home
 
         topdir, dirnames, files = os.walk(SKELPATH).next()
         
         # Copy the skel files to the home dir
-        # FIXME:  Does useradd do this by default on VL?
+        # XXX  Does useradd do this by default on VL?
         for item in os.listdir(SKELPATH):
             fcopy = ["/bin/cp", "-aru", os.path.join(SKELPATH, item), 
                    os.path.join(TARGETDIR, item)]
             for fun in (fcopy, fchown, fchgrp):
                 sp.check_call(fun)
 
-
-
         # Set permissions to the items in home directory.
         cmd = ["/bin/chmod", "0700", TARGETDIR]
         sp.check_call(cmd)
 
     def create(self):
         """Create the user account on the system"""
-        assert self._system_data is None, "User account already exists"
-        assert self.password is not None, "Password attribute has not been set"
-        assert self.login is not None, "Login attribute has not been set"
+        #assert self._system_data is None, "User account already exists"
+        #assert self.password is not None, "Password attribute has not been set"
+        #assert self.login is not None, "Login attribute has not been set"
         epass = self._encrypt_password(self.password)
 
         # Add the group
 
     def change_password(self, newpass):
         """Change a users password"""
-        assert len(newpass) > 4, "Invalid password"
-        assert self._system_data is not None, "User does not exist in the system."
+        #assert len(newpass) > 4, "Invalid password"
+        #assert self._system_data is not None, "User does not exist in the system."
         # Not needed for the installer.  Only for VASM
         epass = self._encrypt_password(newpass)
-        assert epass != newpass, "Password cannot be encrypted correctly"
+        #assert epass != newpass, "Password cannot be encrypted correctly"
         cmd = ["/usr/sbin/usermod", "-p", epass, self.login]
         return sp.check_call(cmd)
 
         """delete this user account"""
         # if self._data is None, this user account does not yet exist.
 
-        assert self._system_data is not None, "User not in system"
+        #assert self._system_data is not None, "User not in system"
         cmd = [ "/usr/sbin/userdel", "-r", self.login]
         return sp.check_call(cmd)
 
     def set_initial_group(self, grouname="users"):
         """Set the initial group for this account.  This is normally 
         'users' for human user accounts"""
-        assert self._system_data is not None, "User does not exist in the system."
+        #assert self._system_data is not None, "User does not exist in the system."
         cmd = [ "/usr/sbin/usermod", "-g", groupname, self.login]
         return sp.check_call(cmd)
 
     def set_supplementary_groups(self, grouplist=[]):
         """Set the supplementary group memberships for this user"""
-        assert self._system_data is not None, "User does not exist in the system."
-        assert isinstance(grouplist, list), "grouplist argument must be a list"
+        #assert self._system_data is not None, "User does not exist in the system."
+        #assert isinstance(grouplist, list), "grouplist argument must be a list"
         cmd = [ "/usr/sbin/usermod", "-G", ",".join(grouplist), self.login ]
         return sp.check_call(cmd)
 
     def add_to_group(self, group):
         """Add this user account to the specified group """
-        assert self._system_data is not None, "User not in system yet"
-        assert isinstance(group, str), "Group argument must be a string"
+        #assert self._system_data is not None, "User not in system yet"
+        #assert isinstance(group, str), "Group argument must be a string"
         allgroups = [ g.gr_name for g in grp.getgrall() ]
-        assert group in allgroups, "Group %s does not exist in the system."% group
+        #assert group in allgroups, "Group %s does not exist in the system."% group
         
         cmd = [ "/usr/sbin/usermod", "-a", group, self.login ]
         return sp.check_call(cmd)
     @property
     def _system_data(self):
         """Return the system data related to this account"""
-        assert self.login is not None, "Login property must be set first"
+        #assert self.login is not None, "Login property must be set first"
         ret = [ u for u in pwd.getpwall() if u.pw_name == self.login ]
         if ret:
             return ret[0]