403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/sysfs.py
"""
Configuration of the kernel using sysfs
=======================================

Control the kernel object attributes exported by sysfs

.. code-block:: yaml

  kernel/mm/transparent_hugepage/enabled
    sysfs.present:
      - value: never

.. versionadded:: 3006.0
"""

import re


def __virtual__():
    """
    This state is only available on Minions which support sysctl
    """
    if "sysfs.attr" in __salt__:
        return True
    return (False, "sysfs module could not be loaded")


def present(name, value, config=None):
    """
    Ensure that the named sysfs attribute is set with the defined value

    name
        The name of the sysfs attribute to edit

    value
        The sysfs value to apply

    """
    ret = {"name": name, "result": True, "changes": {}, "comment": ""}

    current = __salt__["sysfs.read"](name)
    if current is False:
        ret["result"] = False
        ret["comment"] = f"SysFS attribute {name} doesn't exist."
    else:
        # if the return is a dict, the "name" is an object not an attribute
        if isinstance(current, dict):
            ret["result"] = False
            ret["comment"] = f"{name} is not a SysFS attribute."
        else:
            # some attribute files lists all available options and the selected one between []
            if isinstance(current, str):
                current = re.sub(r"(.*\[|\].*)", "", current)
            if value == current:
                ret["result"] = True
                ret["comment"] = f"SysFS attribute {name} is already set."
            else:
                ret["result"] = None

    if ret["result"] is None:
        if __opts__["test"]:
            ret["comment"] = f"SysFS attribute {name} set to be changed."
        else:
            update = __salt__["sysfs.write"](name, value)
            if not update:
                ret["result"] = False
                ret["comment"] = f"Failed to set {name} to {value}"
            else:
                ret["result"] = True
                ret["changes"] = {name: value}
                ret["comment"] = f"Updated SysFS attribute {name} to {value}"

    return ret

Youez - 2016 - github.com/yon3zu
LinuXploit