HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/sdb.cpython-310.pyc
o

�N�g$�@sRdZddlZddlZddlmZddd�Zddd�Zdd	d
�Z			dd
d�Z	dS)zt
Basic functions for accessing the SDB interface

For configuration options, see the docs for specific sdb
modules.
�N)�SaltInvocationErrorFc
Cst|t�r
|�d�s|rtd��|S|durtj�|�}td�}|�d|�}|dks2||dd�s:|r8td��|S|�	|||�i�}|sT|�	di��	|||�i�}d	|vrg|retd
�
|||����|Sd�
|d	�}||dd�}tjj|||d�}	|	|||d
�S)z�
    Get a value from a db, using a uri in the form of ``sdb://<profile>/<key>``. If
    the uri provided is not valid, then it will be returned as-is, unless ``strict=True`` was passed.
    �sdb://z SDB uri must start with "sdb://"N�/����zHSDB uri must have a profile name as a first part of the uri before the /�pillar�driverz8SDB profile "{}" wasnt found in the minion configurationz{}.get��utils��profile)�
isinstance�str�
startswithr�salt�loaderr
�len�find�get�format�sdb)
�uri�optsr
�strict�sdlen�indxr�fun�query�	loaded_db�r�B/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/sdb.py�sdb_gets:�
��r!c
Cs�t|t�r
|�d�sdS|durtj�|�}td�}|�d|�}|dks,||dd�s.dS|�|||�i�}|sH|�di��|||�i�}d|vrNdSd	�	|d�}||dd�}tjj
|||d
�}	|	||||d�S)z�
    Set a value in a db, using a uri in the form of ``sdb://<profile>/<key>``.
    If the uri provided does not start with ``sdb://`` or the value is not
    successfully set, return ``False``.
    rFNrrrrrz{}.setr	r�r
rrrrr
rrrrr)
r�valuerr
rrrrrrrrr �sdb_set<s"r$c	Cs�t|t�r
|�d�sdS|durtj�|�}td�}|�d|�}|dks,||dd�s.dS|�|||�i�}|sH|�di��|||�i�}d|vrNdSd	�	|d�}||dd�}tjj
|||d
�}||||d�S)z�
    Delete a value from a db, using a uri in the form of ``sdb://<profile>/<key>``. If
    the uri provided does not start with ``sdb://`` or the value is not successfully
    deleted, return ``False``.
    rFNrrrrrz	{}.deleter	rr")	rrr
rrrrrrrrr �
sdb_delete[s"r%��2abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)cstt|t�r
|�d�sdS|durtj�|�}t|||d�}|dur6d��fdd�t|�D��}t	||||�|p9|S)z�
    Check if value exists in sdb.  If it does, return, otherwise generate a
    random string and store it.  This can be used for storing secrets in a
    centralized place.
    rFNr	�csg|]	}t������qSr)�random�SystemRandom�choice)�.0�_��charsrr �
<listcomp>�sz'sdb_get_or_set_hash.<locals>.<listcomp>)
r
rrrrr
r!�join�ranger$)rr�lengthr/r
�ret�valrr.r �sdb_get_or_set_hashzsr6)NF)N)r&r'N)
�__doc__r)Zsalt.loaderrZsalt.exceptionsrr!r$r%r6rrrr �<module>s

.
"�