Beispiel #1
0
 def __init__(self, main_win, screen=None):
     super(NSDomain, self).__init__(main_win)
     self.intro = \
             _("Specify the domain for the NIS or LDAP name server. "
               "Use the domain name's exact capitalization and "
               "punctuation.")
     self.title = _("Domain Name:")
Beispiel #2
0
 def _show(self):
     ''' called upon display of a screen '''
     super(NSDNSChooser, self)._show()
     y_loc = self._paint_opening()
     LOGGER.debug(self.nameservice)
     # allow the user to choose DNS or not
     ynlist = [_('Configure DNS'), _('Do not configure DNS')]
     area = WindowArea(x_loc=0,
                       y_loc=y_loc,
                       scrollable_lines=len(ynlist) + 1)
     area.lines = self.win_size_y - (y_loc + 1)
     area.columns = self.win_size_x
     self.scroll_region_dns = ScrollWindow(area, window=self.center_win)
     # add the entries to the screen
     for idx, yon in enumerate(ynlist):
         win_area = WindowArea(1, textwidth(yon) + 1, idx, INDENT)
         ListItem(win_area,
                  window=self.scroll_region_dns,
                  text=yon,
                  data_obj=yon)
     # finalize positioning
     self.main_win.do_update()
     self.center_win.activate_object(self.scroll_region_dns)
     self.scroll_region_dns.activate_object_force(self.cur_dnschoice_idx,
                                                  force_to_top=True)
def validate_username(user_str, blank_ok=True):
    '''Ensure username complies with following rules
       - username can contain characters from set of alphabetic characters,
         numeric characters, period (.), underscore (_), and hyphen (-).
       - username starts with a letter.

    Raises UsernameInvalid if provided user name is not valid,
    otherwise returns True'''

    #
    # consider empty string as a valid value, since it serves
    # as an indicator that user account will not be created
    #
    if blank_ok and not user_str:
        return True

    if not user_str:
        raise UsernameInvalid(_("Username must not be blank"))

    # verify that username starts with alphabetic character
    if not user_str[0].isalpha():
        raise UsernameInvalid(_("Username must start with a letter"))

    # verify that username contains only allowed characters
    if re.search(r"^[a-zA-Z][\w\-.]*$", user_str) is None:
        raise UsernameInvalid(_("Invalid character"))
    return True
Beispiel #4
0
 def _show(self):
     super(NSNISAuto, self)._show()
     if self.nameservice.nameservice != 'NIS':
         raise SkipException
     y_loc = self._paint_opening()
     y_loc += self.center_win.add_paragraph(self.intro2, y_loc)
     y_loc += 1
     ynlist = [_('Find one'),
               _('Specify one')]
     area = WindowArea(x_loc=0, y_loc=y_loc,
                       scrollable_lines=len(ynlist) + 1)
     area.lines = self.win_size_y - (y_loc + 1)
     area.columns = self.win_size_x
     self.scroll_region = ScrollWindow(area, window=self.center_win)
     y_loc += 1  # blank line
     # add the entries to the screen
     for idx, yon in enumerate(ynlist):
         y_loc += 1
         win_area = WindowArea(lines=1, columns=textwidth(yon) + 1,
                               y_loc=idx, x_loc=INDENT)
         ListItem(win_area, window=self.scroll_region, text=yon,
                  data_obj=yon)
         self.main_win.do_update()
     self.center_win.activate_object(self.scroll_region)
     self.scroll_region.activate_object_force(self.cur_nisnschoice_idx,
                                              force_to_top=True)
     y_loc += 1  # blank line
     self.center_win.add_paragraph(self.intro3, y_loc)
def validate_password(password):
    '''validates the password entered'''
    # check the length
    if not password or len(password) <= 0:
        raise PasswordInvalid(_('Password must be entered.'))
    elif len(password) < 6:
        raise PasswordInvalid(_('Password must contain at least 6 '
                                'characters.'))
    else:
        # check that the password contains characters
        # and digit or special characters
        has_char = has_digit = has_special = False
        for char in password:
            if char.isalpha():
                has_char = True
            elif char.isdigit():
                has_digit = True
            else:
                has_special = True
        if not has_char:
            raise PasswordInvalid(_('Password must contain 1 alphabetical '
                                    'character.'))
        elif not has_digit and not has_special:
            raise PasswordInvalid(_('Password must contain 1 digit/special '
                                    'character.'))

    return True
Beispiel #6
0
 def __init__(self, main_win, screen=None):
     super(NSDNSSearch, self).__init__(main_win)
     self.intro = \
             _("Enter a list of domains to be searched when a DNS "
               "query is made. If no domain is entered, only the "
               "DNS domain chosen for this system will be searched.")
     self.title = _("Search domain:")
Beispiel #7
0
 def __init__(self, main_win, screen=None):
     super(NSLDAPProxyBindInfo, self).__init__(main_win)
     self.intro = \
             _("Specify the LDAP proxy bind distinguished name and the "
               "LDAP proxy bind password.  The network administrator "
               "can provide this information.")
     self.title = _("Proxy bind distinguished name:")
     self.title2 = _("Proxy bind password:")
Beispiel #8
0
def minute_valid(minute_edit):
    '''Check validity of minute as each char entered'''
    minute_str = minute_edit.get_text()
    LOGGER.log(LOG_LEVEL_INPUT, "validating minute, text=%s=", minute_str)
    if minute_str and not minute_str.isdigit():
        raise UIMessage(_("Minute must be numeric"))
    if len(minute_str) >= 2 and (int(minute_str) > 59):
        raise UIMessage(_("Minute out of range"))
    return True
def minute_valid(minute_edit):
    '''Check validity of minute as each char entered'''
    minute_str = minute_edit.get_text()
    LOGGER.log(LOG_LEVEL_INPUT, "validating minute, text=%s=", minute_str)
    if minute_str and not minute_str.isdigit():
        raise UIMessage(_("Minute must be numeric"))
    if len(minute_str) >= 2 and (int(minute_str) > 59):
        raise UIMessage(_("Minute out of range"))
    return True
Beispiel #10
0
def hour_valid(hour_edit):
    '''Check validity of hour as each char entered'''
    hour_str = hour_edit.get_text()
    LOGGER.log(LOG_LEVEL_INPUT, "validating hour, text=%s=", hour_str)
    if hour_str and not hour_str.isdigit():
        raise UIMessage(_("Hour must be numeric"))
    if len(hour_str) >= 2 and (int(hour_str) > 23):
        LOGGER.debug("hour out of range, =%s", hour_str)
        raise UIMessage(_("Hour out of range"))
    return True
Beispiel #11
0
 def __init__(self, main_win, screen=None):
     super(NSNISAuto, self).__init__(main_win)
     self.intro = \
             _("Specify how to find a name server for this system.")
     self.intro2 = \
             _("Either let the software search for a name server, "
               "or specify a name server in the following screen.  ")
     self.intro3 = \
             _("The software can find a name server only if that "
               "server is on the local subnet.")
def hour_valid(hour_edit): 
    '''Check validity of hour as each char entered'''
    hour_str = hour_edit.get_text()
    LOGGER.log(LOG_LEVEL_INPUT, "validating hour, text=%s=", hour_str)
    if hour_str and not hour_str.isdigit():
        raise UIMessage(_("Hour must be numeric"))
    if len(hour_str) >= 2 and (int(hour_str) > 23):
        LOGGER.debug("hour out of range, =%s", hour_str)
        raise UIMessage(_("Hour out of range"))
    return True
 def __init__(self, main_win, screen=None):
     global LOGGER
     if LOGGER is None:
         LOGGER = logging.getLogger(INSTALL_LOGGER_NAME + ".sysconfig")
     
     super(TimeZone, self).__init__(main_win)
     self.sys_info = None
     if screen is None:
         self.screen = TimeZone.TIMEZONE
     else:
         self.screen = screen
     self.tz_tuples = None
     self.tz_list = None
     self.cur_timezone_idx = 0
     self.cur_timezone_parent = None
     self.last_timezone_parent = None
     self.cur_continent = None
     self.cur_country = None
     self.scroll_region = None
     self.last_country = None
     self.last_continent = None
     if self.screen == TimeZone.TIMEZONE:
         self.header_text = _("Time Zone")
         self.intro = _("Select your time zone.")
         self.title = _("Time Zones")
     elif self.screen == TimeZone.LOCATIONS:
         self.header_text = _("Time Zone: Locations")
         self.intro = _("Select the location that contains your time zone.")
         self.title = _("Locations")
         self.help_data = (None, None)
     else:
         self.header_text = _("Time Zone: Regions")
         self.intro = _("Select the region that contains your time zone.")
         self.title = _("Regions")
         self.help_data = (None, None)
Beispiel #14
0
    def __init__(self, main_win, screen=None):
        global LOGGER
        if LOGGER is None:
            LOGGER = logging.getLogger(INSTALL_LOGGER_NAME + ".sysconfig")

        super(TimeZone, self).__init__(main_win)
        self.sys_info = None
        if screen is None:
            self.screen = TimeZone.TIMEZONE
        else:
            self.screen = screen
        self.tz_tuples = None
        self.tz_list = None
        self.cur_timezone_idx = 0
        self.cur_timezone_parent = None
        self.last_timezone_parent = None
        self.cur_continent = None
        self.cur_country = None
        self.scroll_region = None
        self.last_country = None
        self.last_continent = None
        if self.screen == TimeZone.TIMEZONE:
            self.header_text = _("Time Zone")
            self.intro = _("Select your time zone.")
            self.title = _("Time Zones")
        elif self.screen == TimeZone.LOCATIONS:
            self.header_text = _("Time Zone: Locations")
            self.intro = _("Select the location that contains your time zone.")
            self.title = _("Locations")
            self.help_data = (None, None)
        else:
            self.header_text = _("Time Zone: Regions")
            self.intro = _("Select the region that contains your time zone.")
            self.title = _("Regions")
            self.help_data = (None, None)
Beispiel #15
0
 def validate(self):
     validate_ldap_profile(self.ldap_profile.get_text())
     ldap_ip = self.ldap_ip.get_text()
     if self.nameservice.dns:
         validate_host_or_ip(ldap_ip)
     else:
         validate_ip(ldap_ip)
     if not self.ldap_profile.get_text():
         raise UIMessage(_("The LDAP profile name cannot be blank."))
     if not ldap_ip:
         raise UIMessage(_("The LDAP server IP address cannot be blank."))
Beispiel #16
0
 def __init__(self, main_win, screen=None):
     super(NSLDAPProxyBindInfo, self).__init__(main_win)
     self.intro = \
             _("Specify the LDAP proxy bind distinguished name and the "
               "LDAP proxy bind password.  The network administrator "
               "can provide this information.")
     self.title = _("Proxy bind distinguished name:")
     # temporary code until ns1_convert method is integrated
     if hasattr(nss.nssscf, 'ns1_convert'):
         self.title2 = _("Proxy bind password:"******"Encrypted proxy bind password:")
Beispiel #17
0
def validate_ldap_profile(profile):
    ''' given an LDAP profile string, validate it
    Arg: profile - LDAP profile string
    Raises: UIMessage on failure
    '''
    if not profile:
        raise UIMessage(_("The LDAP profile name cannot be blank."))
    emsg = _("Whitespace characters and quotation marks are not allowed in "
             "LDAP profile names.")
    for cha in profile:
        if cha in string.whitespace or cha in "'\"":
            raise UIMessage(emsg)
Beispiel #18
0
    def validate(self):
        '''Check for mismatched passwords, bad login names, etc.'''
        # Note: the Root and User password fields may be filled with
        # asterisks if the user previously invoked this screen.  Therefore,
        # if not empty we check their modified flags before validating the
        # contents.

        if self.root_pass_edit.modified:
            root_pass_set = bool(self.root_pass_edit.get_text())
        else:
            root_pass_set = (self.root.passlen != 0)

        # Root password is mandatory and, if modified, must be valid
        if not root_pass_set or self.root_pass_edit.modified:
            pass_valid(self.root_pass_edit,
                       msg_prefix=UserScreen.ROOT_LABEL + " ")
        # Root password confirmation must match original Root password
        if not self.root_pass_edit.compare(self.root_confirm_edit):
            raise UIMessage(_("Root passwords don't match"))

        # User account disabled, skip related validation steps.
        if not self.show_user_account:
            return

        if self.user_pass_edit.modified:
            user_pass_set = bool(self.user_pass_edit.get_text())
        else:
            user_pass_set = (self.user.passlen != 0)

        login_name = self.username_edit.get_text()
        LOGGER.debug("login_name=%s", login_name)
        real_name = self.real_name_edit.get_text()
        LOGGER.debug("real_name=%s", real_name)

        # Username (if specified) must be valid
        login_valid(self.username_edit)

        if login_name:
            # If Username was entered then:
            # - User password is mandatory and, if modified, must be valid
            # - User password confirmation must match original User password
            if not user_pass_set or self.user_pass_edit.modified:
                pass_valid(self.user_pass_edit,
                           msg_prefix=UserScreen.USER_PASS_LABEL + " ")
            if not self.user_pass_edit.compare(self.user_confirm_edit):
                raise UIMessage(_("User passwords don't match"))
        else:
            # If either Real name or User password are specified then
            # Username must also be specified
            if real_name or user_pass_set:
                raise UIMessage(
                    _("Enter username or clear all user "
                      "account fields"))
    def validate(self):
        '''Check for mismatched passwords, bad login names, etc.'''
        # Note: the Root and User password fields may be filled with
        # asterisks if the user previously invoked this screen.  Therefore,
        # if not empty we check their modified flags before validating the
        # contents.

        if self.root_pass_edit.modified:
            root_pass_set = bool(self.root_pass_edit.get_text())
        else:
            root_pass_set = (self.root.passlen != 0)      

        # Root password is mandatory and, if modified, must be valid
        if not root_pass_set or self.root_pass_edit.modified:
            pass_valid(self.root_pass_edit,
                msg_prefix=UserScreen.ROOT_LABEL + " ")
        # Root password confirmation must match original Root password
        if not self.root_pass_edit.compare(self.root_confirm_edit):
            raise UIMessage(_("Root passwords don't match"))

        # User account disabled, skip related validation steps.
        if not self.show_user_account:
            return

        if self.user_pass_edit.modified:
            user_pass_set = bool(self.user_pass_edit.get_text())
        else:
            user_pass_set = (self.user.passlen != 0)
        
        login_name = self.username_edit.get_text()
        LOGGER.debug("login_name=%s", login_name)
        real_name = self.real_name_edit.get_text()
        LOGGER.debug("real_name=%s", real_name)
        
        # Username (if specified) must be valid
        login_valid(self.username_edit)

        if login_name:
            # If Username was entered then:
            # - User password is mandatory and, if modified, must be valid
            # - User password confirmation must match original User password
            if not user_pass_set or self.user_pass_edit.modified:
                pass_valid(self.user_pass_edit,
                    msg_prefix=UserScreen.USER_PASS_LABEL + " ")
            if not self.user_pass_edit.compare(self.user_confirm_edit):
                raise UIMessage(_("User passwords don't match"))
        else:
            # If either Real name or User password are specified then
            # Username must also be specified
            if real_name or user_pass_set:
                raise UIMessage(_("Enter username or clear all user "
                                  "account fields"))
Beispiel #20
0
def inc_validate_nowhite_nospecial(edit_field, etext='<empty>'):
    '''Incrementally validate EditField as the user enters it
    Args: edit_field - EditField object for validation
          etext - text to paste upon error
    Raises: UIMessage upon finding whitespace and special characters other than
            hyphens and underscores
    '''
    profile = edit_field.get_text()
    if not profile:
        raise UIMessage(_("The %s cannot be blank.") % etext)
    global NO_WHITE_NO_SPECIAL_PATTERN
    if not NO_WHITE_NO_SPECIAL_PATTERN.match(profile.upper()):
        raise UIMessage(_('Invalid character for %s.') % etext)
    def get_networks(self):
        '''Build a summary of the networks in the install_profile,
        returned as a list of strings

        '''
        network_summary = []

        # hostname belongs to 'identity' group
        if configure_group(SC_GROUP_IDENTITY):
            network_summary.append(_("  Computer name: %s") %
                                   self.sysconfig.system.hostname)

        if not configure_group(SC_GROUP_NETWORK):
            return network_summary

        nic = self.sysconfig.nic       
        if nic.type == NetworkInfo.AUTOMATIC:
            network_summary.append(_("  Network Configuration: Automatic"))
        elif nic.type == NetworkInfo.NONE:
            network_summary.append(_("  Network Configuration: None"))
        elif nic.type == NetworkInfo.FROMGZ:
            network_summary.append(_("  Network Configuration:"
                                     " Mandated from global zone"))
        elif nic.type == NetworkInfo.MANUAL:
            network_summary.append(_("  Manual Configuration: %s")
                                   % NetworkInfo.get_nic_desc(nic.nic_iface))
            network_summary.append(_("IP Address: %s") % nic.ip_address)
            network_summary.append(_("Netmask: %s") % nic.netmask)
            if nic.gateway:
                network_summary.append(_("Router: %s") % nic.gateway)
        return network_summary
Beispiel #22
0
    def get_networks(self):
        '''Build a summary of the networks in the install_profile,
        returned as a list of strings

        '''
        network_summary = []

        # hostname belongs to 'identity' group
        if configure_group(SC_GROUP_IDENTITY):
            network_summary.append(_("  Computer name: %s") %
                                   self.sysconfig.system.hostname)

        if not configure_group(SC_GROUP_NETWORK):
            return network_summary

        nic = self.sysconfig.nic
        if nic.type == NetworkInfo.AUTOMATIC:
            network_summary.append(_("  Network Configuration: Automatic"))
        elif nic.type == NetworkInfo.NONE:
            network_summary.append(_("  Network Configuration: None"))
        elif nic.type == NetworkInfo.FROMGZ:
            network_summary.append(_("  Network Configuration:"
                                     " Mandated from global zone"))
        elif nic.type == NetworkInfo.MANUAL:
            network_summary.append(_("  Manual Configuration: %s")
                                   % NetworkInfo.get_nic_desc(nic.nic_iface))
            network_summary.append(_("IP Address: %s") % nic.ip_address)
            network_summary.append(_("Netmask: %s") % nic.netmask)
            if nic.gateway:
                network_summary.append(_("Router: %s") % nic.gateway)
        return network_summary
Beispiel #23
0
def validate_ldap_proxy_bind_psw(proxy_psw):
    ''' given an LDAP proxy bind password string, validate it
    Arg: profile - LDAP proxy bind password
    Raises: UIMessage on failure
    '''
    if not proxy_psw:
        raise UIMessage(_("The LDAP proxy bind password may not be blank."))
    for cha in proxy_psw:
        if cha in string.whitespace:
            raise UIMessage(_("The LDAP proxy bind password may not contain "
                              "whitespace characters."))
        if cha in "'\"":
            raise UIMessage(_("The LDAP proxy bind password may not contain "
                              "quotation marks."))
Beispiel #24
0
def incremental_validate_domain(edit_field):
    '''Incrementally validate EditField as a domain as the user enters it
    Arg: edit_field - EditField object with domain to validate
    Raises: UIMessage if invalid character typed
    '''
    domain = edit_field.get_text()
    for label in domain.split('.'):
        if len(label) > 63:
            raise UIMessage(
                          _("Domain labels must have less than 64 characters"))
        if label.startswith('-'):
            raise UIMessage(_('A domain label may not begin with a hyphen.'))
        global INCREMENTAL_DOMAIN_LABEL_PATTERN
        if not INCREMENTAL_DOMAIN_LABEL_PATTERN.match(label.upper()):
            raise UIMessage(_('Invalid character for domain name.'))
Beispiel #25
0
    def get_users(self):
        '''Build a summary of the user information, and return it as a list
        of strings

        '''
        root = self.sysconfig.users.root
        primary = self.sysconfig.users.user
        user_summary = []
        if not root.password:
            user_summary.append(_("  Warning: No root password set"))
        if primary.login_name:
            user_summary.append(_("  Username: %s") % primary.login_name)
        else:
            user_summary.append(_("  No user account"))
        return user_summary
 def validate(self):
     '''Ensure hostname is set and a network type is chosen (unless no
     NICs are present)
     
     '''
     hostname_text = self.hostname.get_text()
     if not hostname_text:
         raise UIMessage(_("A Hostname is required."))
     if len(hostname_text) < 2:
         raise UIMessage(_("A Hostname must be at least two characters."))
     if self.configure_network and self.have_nic and self.nic_info.type is None:
         item_key = self.center_win.get_active_object().item_key
         if item_key not in self.net_type_dict:
             raise UIMessage(_("Select the wired network configuration: "
                                "Automatically, Manually, or None."))
Beispiel #27
0
def validate_ldap_proxy_dn(proxy_dn):
    ''' given an LDAP proxy distinguished name string, validate it
    Arg: profile - LDAP proxy distinguished name
    Raises: UIMessage on failure
    '''
    if not proxy_dn:
        raise UIMessage(_(
                   "The LDAP proxy bind distinguished name may not be blank."))
    for cha in proxy_dn:
        if cha in string.whitespace:
            raise UIMessage(_("The LDAP proxy bind distinguished name may not "
                              "contain whitespace characters."))
        if cha in "'\"":
            raise UIMessage(_("The LDAP proxy bind distinguished name may not "
                              "contain quotation marks."))
Beispiel #28
0
 def validate(self):
     '''Ensure hostname is set and a network type is chosen (unless no
     NICs are present)
     
     '''
     hostname_text = self.hostname.get_text()
     if not hostname_text:
         raise UIMessage(_("A Hostname is required."))
     if len(hostname_text) < 2:
         raise UIMessage(_("A Hostname must be at least two characters."))
     if self.configure_network and self.have_nic:
         item_key = self.center_win.get_active_object().item_key
         if item_key not in self.net_type_dict:
             raise UIMessage(_("Select the wired network configuration: "
                                "Automatically, Manually, or None."))
    def get_users(self):
        '''Build a summary of the user information, and return it as a list
        of strings

        '''
        root = self.sysconfig.users.root
        primary = self.sysconfig.users.user
        user_summary = []
        if not root.password:
            user_summary.append(_("  Warning: No root password set"))
        if primary.login_name:
            user_summary.append(_("  Username: %s") % primary.login_name)
        else:
            user_summary.append(_("  No user account"))
        return user_summary
 def validate(self):
     '''Verify each of the edit fields'''
     year_value = self.year_edit.get_text()
     month_value = self.month_edit.get_text()
     day_value = self.day_edit.get_text()
     hour_value = self.hour_edit.get_text()
     minute_value = self.minute_edit.get_text()
     LOGGER.debug("year_value=%s", year_value)
     LOGGER.debug("month_value=%s", month_value)
     LOGGER.debug("day_value=%s", day_value)
     LOGGER.debug("hour_value=%s", hour_value)
     LOGGER.debug("minute_value=%s", minute_value)
     had_err = False
     if not self.year_edit.run_on_exit(): 
         had_err = True
     if not self.month_edit.run_on_exit(): 
         had_err = True
     if not self.day_edit.run_on_exit(): 
         had_err = True
     if not self.hour_edit.run_on_exit(): 
         had_err = True
     if not self.minute_edit.run_on_exit(): 
         had_err = True
     if had_err:
         raise UIMessage(_("Invalid date/time. See errors above."))
Beispiel #31
0
 def _show(self):
     super(NSLDAPProxyBindInfo, self)._show()
     if self.nameservice.nameservice != 'LDAP':
         raise SkipException
     if self.nameservice.ldap_proxy_bind == \
             NameServiceInfo.LDAP_CHOICE_NO_PROXY_BIND:
         raise SkipException
     y_loc = self._paint_opening()
     y_loc += 1  # blank line
     self.center_win.add_text(self.title, y_loc, INDENT)
     y_loc += 1  # edit field on following line since it should be big
     cols = self.win_size_x - INDENT - 2
     area = WindowArea(1, cols, y_loc, INDENT + 2,
                       scrollable_columns=MAXDNLEN + 1)
     self.ldap_pb_dn = EditField(area, window=self.center_win,
                                 text=self.nameservice.ldap_pb_dn,
                                 error_win=self.main_win.error_line)
     # in case of error, tell user what is being validated
     self.ldap_pb_dn.validate_kwargs['etext'] = _('distinguished name')
     y_loc += 2  # blank line
     titlelen = textwidth(self.title2)
     self.center_win.add_text(self.title2, y_loc, NameService.SCROLL_SIZE)
     cols = self.win_size_x - titlelen - INDENT - 1
     area = WindowArea(1, cols, y_loc, titlelen + INDENT + 1)
     self.ldap_pb_psw = EditField(area, window=self.center_win,
                                  text=self.nameservice.ldap_pb_psw,
                                  error_win=self.main_win.error_line,
                                  masked=True)
     self.main_win.do_update()
     self.center_win.activate_object(self.ldap_pb_dn)
Beispiel #32
0
 def validate(self):
     '''Verify each of the edit fields'''
     year_value = self.year_edit.get_text()
     month_value = self.month_edit.get_text()
     day_value = self.day_edit.get_text()
     hour_value = self.hour_edit.get_text()
     minute_value = self.minute_edit.get_text()
     LOGGER.debug("year_value=%s", year_value)
     LOGGER.debug("month_value=%s", month_value)
     LOGGER.debug("day_value=%s", day_value)
     LOGGER.debug("hour_value=%s", hour_value)
     LOGGER.debug("minute_value=%s", minute_value)
     had_err = False
     if not self.year_edit.run_on_exit():
         had_err = True
     if not self.month_edit.run_on_exit():
         had_err = True
     if not self.day_edit.run_on_exit():
         had_err = True
     if not self.hour_edit.run_on_exit():
         had_err = True
     if not self.minute_edit.run_on_exit():
         had_err = True
     if had_err:
         raise UIMessage(_("Invalid date/time. See errors above."))
Beispiel #33
0
 def __init__(self, main_win):
     super(NSAltChooser, self).__init__(main_win)
     self.intro = \
             _("From the list below, select one name service to be "
               "used by this system. If the desired name service is not "
               "listed, select None. The selected name service may be "
               "used in conjunction with DNS.")
Beispiel #34
0
class NSNISIP(NameService):

    HEADER_TEXT = _("NIS Name Server Information")
    HELP_DATA = (SCI_HELP + "/%s/nis.txt", HEADER_TEXT)

    def __init__(self, main_win):
        super(NSNISIP, self).__init__(main_win)

    def _show(self):
        super(NSNISIP, self)._show()
        LOGGER.info("self.nameservice: %s" % self.nameservice)
        if self.nameservice.nameservice != 'NIS':
            raise SkipException
        if self.nameservice.nis_auto == NameServiceInfo.NIS_CHOICE_AUTO:
            raise SkipException
        if self.nameservice.dns:
            self.intro = \
                _("Enter the host name or IP address of the name server.  "
                  "A host name must have at least 2 characters and can be "
                  "alphanumeric and can contain hyphens.  IP "
                  "addresses must contain four sets of numbers separated "
                  "by periods (for example, 129.200.9.1).")
            self.title = _("Server's host name or IP address:")
        else:
            self.intro = \
                _("Enter the IP address of the name server.  IP "
                  "addresses must contain four sets of numbers separated "
                  "by periods (for example, 129.200.9.1).")
            self.title = _("Server's IP address:")
        y_loc = self._paint_opening()
        self.center_win.add_text(self.title, y_loc, INDENT)
        aligned_x_loc = textwidth(self.title) + INDENT + 1
        cols = self.win_size_x - aligned_x_loc
        area = WindowArea(1, cols, y_loc, aligned_x_loc)
        self.center_win.add_text(self.title, y_loc, INDENT)
        area = WindowArea(1, cols, y_loc, aligned_x_loc,
                        scrollable_columns=NameService.HOSTNAME_SCREEN_LEN + 1)
        # create edit field, validating for host name or IP address depending
        # on whether DNS was selected
        self.nis_ip = EditField(area, window=self.center_win,
                                text=self.nameservice.nis_ip,
                                error_win=self.main_win.error_line,
                                validate=(incremental_validate_host
                                          if self.nameservice.dns
                                          else incremental_validate_ip))
        self.main_win.do_update()
        self.center_win.activate_object(self.nis_ip)

    def validate(self):
        nis_ip = self.nis_ip.get_text()
        if self.nameservice.dns:
            validate_host_or_ip(nis_ip)
        else:
            validate_ip(nis_ip)
        if not nis_ip:
            raise UIMessage(_("The NIS server IP address cannot be blank."))

    def on_change_screen(self):
        self.nameservice.nis_ip = self.nis_ip.get_text()
Beispiel #35
0
    def build_summary(self):
        '''Build a textual summary from solaris_install.sysconfig profile'''

        if self.sysconfig is None:
            return ""
        else:
            summary_text = []

            # display summary only for configured areas
            # locale and timezone belong to SC_GROUP_LOCATION group
            if configure_group(SC_GROUP_LOCATION):
                summary_text.append(self.get_tz_summary())

                summary_text.append("")
                summary_text.append(_("Language: *The following can be changed"
                                      " when logging in."))
                if self.sysconfig.system.locale is None:
                    self.sysconfig.system.determine_locale()
                summary_text.append(_("  Default language: %s") %
                                    self.sysconfig.system.actual_lang)

            # keyboard layout belongs to SC_GROUP_KBD group
            if configure_group(SC_GROUP_KBD):
                summary_text.append("")
                summary_text.append(_("Keyboard layout: *The following can be "
                                      "changed when logging in."))
                summary_text.append(_("  Default keyboard layout: %s") %
                                    self.sysconfig.system.keyboard)
                summary_text.append("")

            if hasattr(self.sysconfig.system, 'terminal_type'):
                summary_text.append(_("Terminal type: %s") %
                                    self.sysconfig.system.terminal_type)

            # user/root accounts belong to SC_GROUP_USERS group
            if configure_group(SC_GROUP_USERS):
                summary_text.append("")
                summary_text.append(_("Users:"))
                summary_text.extend(self.get_users())

            # network belongs to SC_GROUP_IDENTITY and SC_GROUP_NETWORK groups
            if configure_group(SC_GROUP_NETWORK) or \
               configure_group(SC_GROUP_IDENTITY):
                summary_text.append("")
                summary_text.append(_("Network:"))
                summary_text.extend(self.get_networks())
            if configure_group(SC_GROUP_NS):
                self._get_nameservice(summary_text)

            # support configuration
            if configure_group(SC_GROUP_SUPPORT):
                summary_text.append("")
                summary_text.append(_("Support configuration:"))
                summary_text.extend(self.get_support())

            return "\n".join(summary_text)
Beispiel #36
0
def hour_on_exit(hour_edit):
    '''Check hour when exiting field'''
    hour_str = hour_edit.get_text()
    LOGGER.debug("hour_on_exit, =%s=", hour_str)
    if not hour_str:
        raise UIMessage(_("Hour out of range"))
    hour_valid(hour_edit)
    return True
Beispiel #37
0
def minute_on_exit(minute_edit):
    '''Check minute when exiting field'''
    minute_str = minute_edit.get_text()
    LOGGER.debug("minute_on_exit, =%s=", minute_str)
    if not minute_str:
        raise UIMessage(_("Minute out of range"))
    minute_valid(minute_edit)
    return True
def pass_match(pw_field, linked_win=None):
    '''Make sure passwords match'''
    if linked_win is None or pw_field.compare(linked_win):
        return True
    else:
        pw_field.clear_text()
        linked_win.clear_text()
        raise UIMessage(_("Passwords don't match"))
Beispiel #39
0
 def validate(self):
     found = False
     for field in self.dns_server_list:
         validate_ip(field.get_text())
         if field.get_text():
             found = True
     if not found:
         raise UIMessage(_("At least one name server must be specified."))
def minute_on_exit(minute_edit):
    '''Check minute when exiting field'''
    minute_str = minute_edit.get_text()
    LOGGER.debug("minute_on_exit, =%s=", minute_str)
    if not minute_str:
        raise UIMessage(_("Minute out of range"))
    minute_valid(minute_edit)
    return True
def hour_on_exit(hour_edit):
    '''Check hour when exiting field'''
    hour_str = hour_edit.get_text()
    LOGGER.debug("hour_on_exit, =%s=", hour_str)
    if not hour_str:
        raise UIMessage(_("Hour out of range"))
    hour_valid(hour_edit)
    return True
Beispiel #42
0
def pass_match(pw_field, linked_win=None):
    '''Make sure passwords match'''
    if linked_win is None or pw_field.compare(linked_win):
        return True
    else:
        pw_field.clear_text()
        linked_win.clear_text()
        raise UIMessage(_("Passwords don't match"))
Beispiel #43
0
 def validate(self):
     nis_ip = self.nis_ip.get_text()
     if self.nameservice.dns:
         validate_host_or_ip(nis_ip)
     else:
         validate_ip(nis_ip)
     if not nis_ip:
         raise UIMessage(_("The NIS server IP address cannot be blank."))
def hostname_is_valid(edit_field):
    '''Check hostname for characters other than a-zA-Z0-9 and hyphens'''
    user_str = edit_field.get_text()
    if not user_str:
        return True
    test_str = user_str.replace(u"-", "a")
    if not test_str.isalnum():
        raise UIMessage(_("The Hostname can only contain letters, numbers, "
                            "and minus signs (-)."))
def year_on_exit(year_edit):
    '''Check year when exiting field'''
    year_str = year_edit.get_text()
    LOGGER.debug("year_on_exit, =%s=", year_str)
    year_valid(year_edit)
    if (len(year_str) != 4):
        LOGGER.debug("on exit year out of range=%s", input)
        raise UIMessage(_("Year out of range"))
    return True
def month_on_exit(month_edit):
    '''Check month when exiting field'''
    month_str = month_edit.get_text() 
    LOGGER.debug("month_on_exit, =%s=", month_str)
    month_valid(month_edit)
    if (len(month_str) == 0 or int(month_str) == 0):
        LOGGER.debug("on exit month out of range=%s", month_str)
        raise UIMessage(_("Month out of range"))
    return True
def day_on_exit(day_edit):
    '''Check day when exiting field'''
    day_str = day_edit.get_text()
    LOGGER.debug("day_on_exit, =%s=", day_str)
    day_valid(day_edit)
    if (len(day_str) == 0 or int(day_str) == 0):
        LOGGER.debug("on exit day out of range=%s", day_str)
        raise UIMessage(_("Day out of range"))
    return True
def day_valid(day_edit, month_edit=None, year_edit=None, date_time=None):
    '''Check validity of day as each char entered'''
    day_str = day_edit.get_text()
    LOGGER.log(LOG_LEVEL_INPUT, "validating day, text=%s=", day_str)
    if not day_str:
        return True
    if not day_str.isdigit():
        raise UIMessage(_("Day must be numeric"))
    LOGGER.log(LOG_LEVEL_INPUT, "len = %s, text=%s ", len(day_str), day_str)
    
    # When screen first comes up, there is no month/year_edit
    if (month_edit is None or year_edit is None):
        return True
    
    days_in_month = get_days_in_month(month_edit, year_edit, date_time)
    if (len(day_str) >= 2):
        if (int(day_str) > days_in_month or int(day_str) == 0):
            LOGGER.debug("day out of range, =%s", day_str)
            raise UIMessage(_("Day out of range"))
    return True
def month_valid(month_edit, day_edit=None, year_edit=None, date_time=None):
    '''Check validity of month as each char entered'''
    if date_time:
        date_time.month_is_valid = False
    month_str = month_edit.get_text()
    LOGGER.log(LOG_LEVEL_INPUT, "validating month, text=%s=", month_str)
    if not month_str:
        return True
    if not month_str.isdigit():
        raise UIMessage(_("Month must be numeric"))
    LOGGER.debug("len = %s, text=%s ", len(month_str), month_str)
    if len(month_str) >= 2:
        if (int(month_str) > 12 or int(month_str) == 0):
            LOGGER.log(LOG_LEVEL_INPUT, "month out of range, =%s", month_str)
            raise UIMessage(_("Month out of range"))
    if date_time:
        date_time.month_is_valid = True
        if int(month_str) > 0:
            check_day_range(month_edit, day_edit, year_edit, date_time)
    return True
 def validate(self):
     '''Verify the syntactical validity of the IP Address fields'''
     ip_fields = [self.ip_field,
                  self.netmask_field,
                  self.gateway_field]
     for field in ip_fields:
         validate_ip(field)
     
     if not self.ip_field.get_text():
         raise UIMessage(_("IP Address must not be empty"))
     if not self.netmask_field.get_text():
         raise UIMessage(_("Netmask must not be empty"))
     else:
         try:
             netmask = self.netmask_field.get_text()
             IPAddress.convert_address(netmask, check_netmask=True)
         except ValueError as err:
             if err[0] == IPAddress.MSG_NO_LEADING_ZEROS:
                 raise UIMessage(NICConfigure.MSG_NO_LEADING_ZEROS %
                                 self.netmask_field.data_obj)
             raise UIMessage(_("'%s' is not a valid netmask") % netmask)
def incremental_validate_ip(edit_field):
    '''Incrementally validate the IP Address as the user enters it'''
    ip_address = edit_field.get_text()
    if not ip_address:
        return True
    try:
        IPAddress.incremental_check(ip_address)
    except ValueError as err:
        if err[0] == IPAddress.MSG_NO_LEADING_ZEROS:
            raise UIMessage(NICConfigure.MSG_NO_LEADING_ZEROS %
                            edit_field.data_obj)
        raise UIMessage(_("%s must be of the form xxx.xxx.xxx.xxx") %
                        edit_field.data_obj)
    return True
def year_valid(year_edit, month_edit=None, day_edit=None,
               date_time=None):
    '''Check validity of year as each char entered'''
    if date_time:
        date_time.year_is_valid = False
    year_str = year_edit.get_text()
    if not year_str:
        return True
    now = datetime.datetime.now()
    LOGGER.log(LOG_LEVEL_INPUT, "validating year, text=%s=", year_str)
    if not year_str.isdigit():
        raise UIMessage(_("Year must be numeric"))
    if year_str[0] != now.strftime("%Y")[0]:
        LOGGER.debug("year doesn't start with 2, text=%s", year_str)
        raise UIMessage(_("Year out of range"))
    if len(year_str) > 1 and year_str[1] != now.strftime("%Y")[1]:
        LOGGER.debug("year out of range=%s", year_str)
        raise UIMessage(_("Year out of range"))
    if date_time:
        date_time.year_is_valid = True
        if len(year_str) == 4:
            check_day_range(month_edit, day_edit, year_edit, date_time)
    return True
    def build_summary(self):
        '''Build a textual summary from solaris_install.sysconfig profile'''

        if self.sysconfig is None:
            return ""
        else:
            summary_text = []
        
            # display summary only for configured areas
            # locale and timezone belong to SC_GROUP_LOCATION group
            if configure_group(SC_GROUP_LOCATION):
                summary_text.append(self.get_tz_summary())

                summary_text.append("")
                summary_text.append(_("Language: *The following can be changed"
                                      " when logging in."))
                if self.sysconfig.system.locale is None:
                    self.sysconfig.system.determine_locale()
                summary_text.append(_("  Default language: %s") %
                                    self.sysconfig.system.actual_lang)

            # keyboard layout belongs to SC_GROUP_KBD group
            if configure_group(SC_GROUP_KBD):
                summary_text.append("")
                summary_text.append(_("Keyboard layout: *The following can be "
                                      "changed when logging in."))
                summary_text.append(_("  Default keyboard layout: %s") %
                                    self.sysconfig.system.keyboard)
                summary_text.append("")

            if hasattr(self.sysconfig.system, 'terminal_type'):
                summary_text.append(_("Terminal type: %s") %
                                    self.sysconfig.system.terminal_type)

            # user/root accounts belong to SC_GROUP_USERS group
            if configure_group(SC_GROUP_USERS):
                summary_text.append("")
                summary_text.append(_("Users:"))
                summary_text.extend(self.get_users())

            # network belongs to SC_GROUP_IDENTITY and SC_GROUP_NETWORK groups
            if configure_group(SC_GROUP_NETWORK) or \
               configure_group(SC_GROUP_IDENTITY):
                summary_text.append("")
                summary_text.append(_("Network:"))
                summary_text.extend(self.get_networks())
            if configure_group(SC_GROUP_NS):
                self._get_nameservice(summary_text)
        
            return "\n".join(summary_text)
def validate_ip(edit_field):
    '''Wrap a call to IPAddress.check_address and raise a UIMessage with
    appropriate message text
    
    '''
    ip_address = edit_field.get_text()
    if not ip_address:
        return True
    try:
        IPAddress.convert_address(ip_address)
    except ValueError as err:
        if err[0] == IPAddress.MSG_NO_LEADING_ZEROS:
            raise UIMessage(NICConfigure.MSG_NO_LEADING_ZEROS %
                            edit_field.data_obj)
        raise UIMessage(_("%s must be of the form xxx.xxx.xxx.xxx") %
                        edit_field.data_obj)
    return True
 def _show(self):
     '''Display the static paragraph WELCOME_TEXT and all
        applicable bullet items'''
     sc_options = get_sc_options_from_doc()
     max_width = self.win_size_x - WelcomeScreen.INDENT - 1
     text = convert_paragraph(WelcomeScreen.WELCOME_TEXT, max_width)
     # list configuration groups in a comma-separated list with
     # bullet on first line and indentation on subsequent lines
     grouplist = list()
     if configure_group(SC_GROUP_NETWORK):
         grouplist.append(_("network"))
     elif configure_group(SC_GROUP_IDENTITY):
         grouplist.append(_("system hostname"))
     if configure_group(SC_GROUP_LOCATION):
         grouplist.append(_("time zone"))
     if configure_group(SC_GROUP_DATETIME):
         grouplist.append(_("date and time"))
     if configure_group(SC_GROUP_USERS):
         grouplist.append(_("user and root accounts"))
     if configure_group(SC_GROUP_NS):
         grouplist.append(_("name services"))
     grouplist = ", ".join(grouplist)
     grouplist = convert_paragraph(grouplist,
                                   max_width - len(WelcomeScreen.BULLET))
     for ln in range(len(grouplist)):
         if ln == 0:
             text.append(WelcomeScreen.BULLET + grouplist[ln])
         else:
             text.append(WelcomeScreen.BULLET_INDENT + grouplist[ln])
     # display navigation instructions and profile path
     fmt = {"scprof": sc_options.profile}
     text.extend(convert_paragraph(WelcomeScreen.NAVIPRO_TEXT % fmt,
                                   max_width))
     # indent and align while bulletting
     for bullet in WelcomeScreen.BULLET_ITEMS:
         btext = convert_paragraph(bullet,
                                   max_width - len(WelcomeScreen.BULLET))
         for ln in range(len(btext)):
             if ln == 0:
                 text.append(WelcomeScreen.BULLET + btext[ln])
             else:
                 text.append(WelcomeScreen.BULLET_INDENT + btext[ln])
     # prepare welcome text in entire window for scrolling
     area = WindowArea(x_loc=0, y_loc=1, scrollable_lines=(len(text) + 1))
     area.lines = self.win_size_y - 1
     area.columns = self.win_size_x
     scroll_region = ScrollWindow(area, window=self.center_win)
     scroll_region.add_paragraph(text, start_x=WelcomeScreen.INDENT)
     self.center_win.activate_object(scroll_region)
 def get_tz_summary(self):
     '''Return a string summary of the timezone selection'''
     timezone = self.sysconfig.system.tz_timezone
     return _("Time Zone: %s") % timezone
 def set_actions(self):
     '''Replace the default F2_Continue with F2_Apply'''
     install_action = Action(curses.KEY_F2, _("Apply"),
                             self.main_win.screen_list.get_next)
     self.main_win.actions[install_action.key] = install_action
def nameservice_summary(nameservice, summary):
    '''sppend name service summary information
    Args: nameservice - name service info
        summary - list of summary lines to append to
    '''
    if not nameservice:
        return
    if not nameservice.dns and not nameservice.nameservice:
        return
    # fetch localized name for name service
    if nameservice.dns:
        summary.append(_("Name service: %s") % NameService.USER_CHOICE_DNS)
        # strip empty list entries
        dnslist = [ln for ln in nameservice.dns_server if ln]
        summary.append(_("DNS servers: ") + " ".join(dnslist))
        dnslist = [ln for ln in nameservice.dns_search if ln]
        summary.append(_("DNS Domain search list: ") + " ".join(dnslist))
    if nameservice.nameservice == 'LDAP':
        ns_idx = NameService.CHOICE_LIST.index(nameservice.nameservice)
        summary.append(_("Name service: %s") %
                       NameService.USER_CHOICE_LIST[ns_idx])
        summary.append(_("Domain: %s") % nameservice.domain)
        summary.append(_("LDAP profile: ") + nameservice.ldap_profile)
        summary.append(_("LDAP server's IP: ") + nameservice.ldap_ip)
        summary.append(_("LDAP search base: ") + 
                       nameservice.ldap_search_base)
        if nameservice.ldap_proxy_bind == \
                NameServiceInfo.LDAP_CHOICE_PROXY_BIND:
            summary.append(_("LDAP proxy bind distinguished name: ") +
                           nameservice.ldap_pb_dn)
            summary.append(_("LDAP proxy bind password: [concealed]"))
    elif nameservice.nameservice == 'NIS':
        ns_idx = NameService.CHOICE_LIST.index(nameservice.nameservice)
        summary.append(_("Name service: %s") %
                       NameService.USER_CHOICE_LIST[ns_idx])
        summary.append(_("Domain: %s") % nameservice.domain)
        if nameservice.nis_auto == NameServiceInfo.NIS_CHOICE_AUTO:
            summary.append(_("NIS server: broadcast"))
        elif nameservice.nis_ip:
            summary.append(_("NIS server's IP: ") + nameservice.nis_ip)
        # offer user help for modifying name service sources
        if nameservice.dns:
            summary.append(_("Note: DNS will be configured to resolve "
                             "host and IP node names."))
            summary.append(_("This setting can be modified upon "
                             "rebooting. For example:"))
            summary.append("# svccfg -s svc:/system/name-service/switch")
            summary.append("svc:/system/name-service/switch> "
                           "setprop config/host=\"files nis dns\"")
            summary.append("svc:/system/name-service/switch> quit")
            summary.append("# svcadm refresh svc:/system/name-service/switch")
            summary.append(_("See nsswitch.conf(4), svccfg(1M) and "
                             "nscfg(1M)."))