HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__pycache__/sqlcipher.cpython-310.pyc
o

�N�g�
�@s~dZddlZddlmZddlmZe�e�Zz
ddl	m
ZdZWne
y,dZYnwdd	�ZGd
d�de�Zdd
�ZdS)a
Retrieve Pillar data by running a SQLCipher query

.. versionadded:: 2016.3.0

Python SQLCipher support is provided by the pysqlcipher
Python package. You need this module installed to query
Pillar data from a SQLCipher database.

This module is a concrete implementation of the sql_base
ext_pillar for SQLCipher.

:maturity: new
:depends: pysqlcipher (for py2) or pysqlcipher3 (for py3)
:platform: all

Configuring the sqlcipher ext_pillar
====================================

Use the 'sqlcipher' key under ext_pillar for configuration of queries.

SQLCipher database connection configuration requires the following values
configured in the master config:

   * ``sqlcipher.database`` - The SQLCipher database to connect to.
     Defaults to ``'/var/lib/salt/pillar-sqlcipher.db'``.
   * ``sqlcipher.pass`` - The SQLCipher database decryption password.
   * ``sqlcipher.timeout`` - The connection timeout in seconds.

Example configuration

.. code-block:: yaml

    sqlcipher:
      database: /var/lib/salt/pillar-sqlcipher.db
      pass: strong_pass_phrase
      timeout: 5.0

Complete Example
================

.. code-block:: yaml

    sqlcipher:
      database: '/var/lib/salt/pillar-sqlcipher.db'
      pass: strong_pass_phrase
      timeout: 5.0

    ext_pillar:
      - sqlcipher:
          fromdb:
            query: 'SELECT col1,col2,col3,col4,col5,col6,col7
                      FROM some_random_table
                     WHERE minion_pattern LIKE ?'
            depth: 5
            as_list: True
            with_lists: [1,3]
�N)�contextmanager)�SqlBaseExtPillar)�dbapi2TFcCstsdSdS)NFT)�
HAS_SQLCIPHER�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/sqlcipher.py�__virtual__Lsrc@s0eZdZdZedd��Zdd�Zedd��ZdS)	�SQLCipherExtPillarzM
    This class receives and processes the database rows from SQLCipher.
    cCsdS)NZ	SQLCipherr)�clsrrr�_db_nameWszSQLCipherExtPillar._db_namecCsXdddd�}i}t�di�}|D]}||vr#t�d|�||||<q||||<q|S)zD
        Returns options used for the SQLCipher connection.
        z!/var/lib/salt/pillar-sqlcipher.dbZstrong_pass_phraseg@)�database�pass�timeout�	sqlcipherz%Using default for SQLCipher pillar %s)Z__opts__�get�log�debug)�self�defaults�_optionsZ_opts�attrrrr�_get_options[s�zSQLCipherExtPillar._get_optionsc
cs��|��}tj|�d�t|�d��d�}|�d�|�d���|��}z.z|VWntjyC}z
t	�
d|j�WYd}~nd}~wwW|��dSW|��dS|��w)z*
        Yield a SQLCipher cursor
        rr)rzpragma key="{}"r
z!Error in ext_pillar SQLCipher: %sN)
rr�connectr�floatZexecute�format�cursor�Errorr�	exception�args�close)rr�connr�errrrr�_get_cursoros"��
����zSQLCipherExtPillar._get_cursorN)	�__name__�
__module__�__qualname__�__doc__�classmethodrrrr"rrrrr	Rs
r	cOst�j||g|�Ri|��S)zG
    Execute queries against SQLCipher, merge and return as a dict
    )r	Zfetch)Z	minion_idZpillarr�kwargsrrr�
ext_pillar�sr))r&�logging�
contextlibrZsalt.pillar.sql_baser�	getLoggerr#rZpysqlcipherrrr�ImportErrorrr	r)rrrr�<module>s;
�0