Reset the SELinux context on a given path

    CLI Example:

    .. code-block:: bash

         salt '*' file.restorecon /home/user/.ssh/authorized_keys
175399
def restorecon(path, recursive=False):
    '''
    
    '''
    if recursive:
        cmd = ['restorecon', '-FR', path]
    else:
        cmd = ['restorecon', '-F', path]
    return not __salt__['cmd.retcode'](cmd, python_shell=False)
1092414
def _reset(self):
        
        self.commands = []
        self.watching = False
        self._watched_keys = {}
        self.explicit_transaction = False
775366
def _expand_authorized_keys_path(path, user, home):
    '''
    
    '''
    converted_path = ''
    had_escape = False
    for char in path:
        if had_escape:
            had_escape = False
            if char == '%':
                converted_path += '%'
            elif char == 'u':
                converted_path += user
            elif char == 'h':
                converted_path += home
            else:
                error = 'AuthorizedKeysFile path: unknown token character "%{0}"'.format(char)
                raise CommandExecutionError(error)
            continue
        elif char == '%':
            had_escape = True
        else:
            converted_path += char
    if had_escape:
        error = "AuthorizedKeysFile path: Last character can't be escape character"
        raise CommandExecutionError(error)
    return converted_path
1129755
def cli(env, context_id, static_ip, remote_ip, note):
    
    manager = SoftLayer.IPSECManager(env.client)
    # ensure context can be retrieved by given id
    manager.get_tunnel_context(context_id)

    translation = manager.create_translation(context_id,
                                             static_ip=static_ip,
                                             remote_ip=remote_ip,
                                             notes=note)
    env.out('Created translation from {} to {} #{}'
            .format(static_ip, remote_ip, translation['id']))
603551
def restart_user(self, subid):
    ''''''
    p = self.revoke_token(subid)
    p = self.refresh_token(subid)
    return p
17121
def reset # :nodoc:
      switches.clear
      flags.clear
      @commands = nil
      @commands_declaration_order = []
      @flags_declaration_order = []
      @switches_declaration_order = []
      @version = nil
      @config_file = nil
      @use_openstruct = false
      @prog_desc = nil
      @error_block = false
      @pre_block = false
      @post_block = false
      @default_command = :help
      @autocomplete = false
      @around_block = nil
      @subcommand_option_handling_strategy = :legacy
      @argument_handling_strategy = :loose
      clear_nexts
    end
15269
def restore(cls, path=None):
        

        if path is None:
            path = cls._PATH_API_CONTEXT_DEFAULT

        with open(path, cls._FILE_MODE_READ) as file_:
            return cls.from_json(file_.read())
807629
def _remote_chown(self, paths, user, sudoable=False):
        
        LOG.debug('_remote_chown(%r, user=%r, sudoable=%r)',
                  paths, user, sudoable)
        ent = self._connection.get_chain().call(pwd.getpwnam, user)
        return self.fake_shell(lambda: mitogen.select.Select.all(
            self._connection.get_chain().call_async(
                os.chown, path, ent.pw_uid, ent.pw_gid
            )
            for path in paths
        ))
696506
def reset_server_env(self, server_name, configure):
        
        env.host_string = configure[server_name]['host']
        env.user = configure[server_name]['user']
        env.password = configure[server_name]['passwd']
554708
def reset
      self.user_agent         = DEFAULT_USER_AGENT
      self.server_url         = DEFAULT_SERVER_URL
      self.chef_version       = DEFAULT_CHEF_VERSION
      self.client_name        = DEFAULT_CLIENT_NAME
      self.client_key         = DEFAULT_CLIENT_KEY
      self.connection_options = DEFAULT_CONNECTION_OPTIONS
      self.middleware         = DEFAULT_MIDDLEWARE
      self
    end
209463
def load_keys(path)
      file_lines = read_keys_file(path)

      keys = []
      file_lines.map do |l|
        components = LoginPolicy.parse_public_key(l)

        if components
          #preserve algorithm, key and comments; discard options (the 0th element)
          keys << [ components[1], components[2], components[3] ]
        elsif l =~ COMMENT
          next
        else
          RightScale::Log.error("Malformed (or not SSH2) entry in authorized_keys file: #{l}")
          next
        end
      end

      keys
    end
706075
def _set_shortcut_ownership(path, user):
    '''
    
    '''
    try:
        __salt__['file.lchown'](path, user)
    except OSError:
        pass
    return _check_shortcut_ownership(path, user)
247586
def reset
      self.username = DEFAULT_USERNAME
      self.password = DEFAULT_PASSWORD
      self.uri = DEFAULT_URI
      self.api_version = DEFAULT_API_VERSION
      self.auth_type = DEFAULT_AUTH_TYPE
      self.project = nil
      self.oauth_secret = nil
      self.oauth_secret_filename = nil
      self.oauth_pass_phrase = nil
      self.oauth_consumer_key = nil
      self.config_path = nil
    end
1232326
def reset
      self.app_key = DEFAULT_APP_KEY
      self.master_secret = DEFAULT_MASTER_SECRET
      self.endpoint = DEFAULT_ENDPOINT
      self.http_adapter = DEFAULT_HTTP_ADAPTER
      self.proxy = DEFAULT_PROXY
      self.user_agent = DEFAULT_USER_AGENT
    end
354888
def read_authorized_keys(username=None):
    
    authorized_keys_path = '{0}/.ssh/authorized_keys'.format(os.path.expanduser('~{0}'.format(username)))
    rnd_chars = random_string(length=RANDOM_FILE_EXT_LENGTH)
    tmp_authorized_keys_path = '/tmp/authorized_keys_{0}_{1}'.format(username, rnd_chars)
    authorized_keys = list()
    copy_result = execute_command(
        shlex.split(str('{0} cp {1} {2}'.format(sudo_check(), authorized_keys_path, tmp_authorized_keys_path))))
    result_message = copy_result[0][1].decode('UTF-8')
    if 'you must have a tty to run sudo' in result_message:  # pragma: no cover
        raise OSError("/etc/sudoers is blocked sudo. Remove entry: 'Defaults    requiretty'.")
    elif 'No such file or directory' not in result_message:
        execute_command(shlex.split(str('{0} chmod 755 {1}'.format(sudo_check(), tmp_authorized_keys_path))))
        with open(tmp_authorized_keys_path) as keys_file:
            for key in keys_file:
                authorized_keys.append(PublicKey(raw=key))
        execute_command(shlex.split(str('{0} rm {1}'.format(sudo_check(), tmp_authorized_keys_path))))
    return authorized_keys
738452
async def restart(self):
        '''
        
        '''
        params = {}
        if self.owner_access_key:
            params['owner_access_key'] = self.owner_access_key
        rqst = Request(self.session,
                       'PATCH', '/kernel/{}'.format(self.kernel_id),
                       params=params)
        async with rqst.fetch():
            pass
1228230
def configure_root_access(options = {})
      public_key = ENV['VS_SSH_PUBLIC_KEY'].to_s.strip
      # was there a key found?
      if public_key.nil? || public_key.empty?
        puts "No public SSH key found in metadata"
        return
      end
      update_authorized_keys(public_key)
    end