def add_user(username, uid, shell=nil)
      uid = Integer(uid)
      shell ||= DEFAULT_SHELLS.detect { |sh| File.exists?(sh) }

      useradd = find_sbin('useradd')

      unless shell.nil?
        dash_s = "-s #{Shellwords.escape(shell)}"
      end

      result = sudo("#{useradd} #{dash_s} -u #{uid} -p #{random_password} -m #{Shellwords.escape(username)}")

      case result.exitstatus
      when 0
        home_dir = Shellwords.escape(Etc.getpwnam(username).dir)

        # Locking account to prevent warning os SUSE(it complains on unlocking non-locked account)
        modify_user(username, true, shell)

        RightScale::Log.info("LoginUserManager created #{username} successfully")
      else
        raise RightScale::LoginManager::SystemConflict, "Failed to create user #{username}"
      end

      true
    end
def add_user(username, uid, shell=nil)
      uid = Integer(uid)
      shell ||= DEFAULT_SHELLS.detect { |sh| File.exists?(sh) }

      useradd = find_sbin('useradd')

      unless shell.nil?
        dash_s = "-s #{Shellwords.escape(shell)}"
      end

      result = sudo("#{useradd} #{dash_s} -u #{uid} -p #{random_password} -m #{Shellwords.escape(username)}")

      case result.exitstatus
      when 0
        home_dir = Shellwords.escape(Etc.getpwnam(username).dir)

        # Locking account to prevent warning os SUSE(it complains on unlocking non-locked account)
        modify_user(username, true, shell)

        RightScale::Log.info("LoginUserManager created #{username} successfully")
      else
        raise RightScale::LoginManager::SystemConflict, "Failed to create user #{username}"
      end

      true
    end
Create a Unix user with the "useradd" command.

 === Parameters
 username(String):: username
 uid(String):: account's UID
 expired_at(Time):: account's expiration date; default nil
 shell(String):: account's login shell; default nil (use systemwide default)


 === Raise
 (RightScale::LoginManager::SystemConflict):: if the user could not be created for some reason

 === Return
 true:: always returns true