PK���ȼRY��������€��� �v3.phpUT �øŽg‰gñ“gux �õ��õ��½T]kÛ0}߯pEhìâÙM7X‰çv%”v0֐µ{)Aå:6S$!ÉMJèߕ?R÷!>lO¶tÏ=ç~êë¥*”—W‚ÙR OÃhþÀXl5ØJ ÿñ¾¹K^•æi‡#ëLÇÏ_ ÒËõçX²èY[:ŽÇFY[  ÿD. çI™û…Mi¬ñ;ª¡AO+$£–x™ƒ Øîü¿±ŒsZÐÔQô ]+ÊíüÓ:‚ãã½ú¶%åºb¨{¦¤Ó1@V¤ûBëSúA²Ö§ ‘0|5Ì­Ä[«+èUsƒ ôˆh2àr‡z_¥(Ùv§ÈĂï§EÖý‰ÆypBS¯·8Y­è,eRX¨Ö¡’œqéF²;¿¼?Ø?Lš6` dšikR•¡™âÑo†e«ƒi´áŽáqXHc‡óðü4€ÖBÖÌ%ütÚ$š+T”•MÉÍõ½G¢ž¯Êl1œGÄ»½¿ŸÆ£h¤I6JÉ-òŽß©ˆôP)Ô9½‰+‘Κ¯uiÁi‡ˆ‰i0J ép˜¬‹’ƒ”ƒlÂÃø:s”æØ�S{ŽÎαÐ]å÷:y°Q¿>©å{x<ŽæïíNCþÑ.Mf?¨«2ý}=ûõýî'=£§ÿu•Ü(—¾IIa­"éþ@¶�¿ä9?^-qìÇÞôvŠeÈc ðlacã®xèÄ'®âd¶ çˆSEæódP/ÍÆv{Ô)Ó ?>…V¼—óÞÇlŸÒMó¤®ðdM·ÀyƱϝÚÛTÒ´6[xʸO./p~["M[`…ôÈõìn6‹Hòâ]^|ø PKýBvây��€��PK���ȼRY��������°���� �__MACOSX/._v3.phpUT �øŽg‰gþ“gux �õ��õ��c`cg`b`ðMLVðVˆP€'qƒøˆŽ!!AP&HÇ %PDF-1.7 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R ] /Count 1 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R /F2 9 0 R >> >> /MediaBox [0.000 0.000 595.280 841.890] >> endobj 4 0 obj [/PDF /Text ] endobj 5 0 obj << /Producer (���d�o�m�p�d�f� �2�.�0�.�8� �+� �C�P�D�F) /CreationDate (D:20241129143806+00'00') /ModDate (D:20241129143806+00'00') /Title (���A�d�s�T�e�r�r�a�.�c�o�m� �i�n�v�o�i�c�e) >> endobj 6 0 obj << /Type /Page /MediaBox [0.000 0.000 595.280 841.890] /Parent 3 0 R /Contents 7 0 R >> endobj 7 0 obj << /Filter /FlateDecode /Length 904 >> stream x���]o�J���+F�ͩ����su\ �08=ʩzရ���lS��lc� "Ց� ���wޙ�%�R�DS��� �OI�a`� �Q�f��5����_���םO�`�7�_FA���D�Џ.j�a=�j����>��n���R+�P��l�rH�{0��w��0��=W�2D ����G���I�>�_B3ed�H�yJ�G>/��ywy�fk��%�$�2.��d_�h����&)b0��"[\B��*_.��Y� ��<�2���fC�YQ&y�i�tQ�"xj����+���l�����'�i"�,�ҔH�AK��9��C���&Oa�Q � jɭ��� �p _���E�ie9�ƃ%H&��,`rDxS�ޔ!�(�X!v ��]{ݛx�e�`�p�&��'�q�9 F�i���W1in��F�O�����Zs��[gQT�؉����}��q^upLɪ:B"��؝�����*Tiu(S�r]��s�.��s9n�N!K!L�M�?�*[��N�8��c��ۯ�b�� ��� �YZ���SR3�n�����lPN��P�;��^�]�!'�z-���ӊ���/��껣��4�l(M�E�QL��X ��~���G��M|�����*��~�;/=N4�-|y�`�i�\�e�T�<���L��G}�"В�J^���q��"X�?(V�ߣXۆ{��H[����P�� �c���kc�Z�9v�����? �a��R�h|��^�k�D4W���?Iӊ�]<��4�)$wdat���~�����������|�L��x�p|N�*��E� �/4�Qpi�x.>��d����,M�y|4^�Ż��8S/޾���uQe���D�y� ��ͧH�����j�wX � �&z� endstream endobj 8 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >> endobj 9 0 obj << /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >> endobj xref 0 10 0000000000 65535 f 0000000009 00000 n 0000000074 00000 n 0000000120 00000 n 0000000284 00000 n 0000000313 00000 n 0000000514 00000 n 0000000617 00000 n 0000001593 00000 n 0000001700 00000 n trailer << /Size 10 /Root 1 0 R /Info 5 0 R /ID[] >> startxref 1812 %%EOF
Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 128

Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 129

Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 130

Warning: Cannot modify header information - headers already sent by (output started at /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php:1) in /home/u697396820/domains/smartriegroup.com/public_html/assets/images/partners/logo_69cec45839613.php on line 131
import os import re import pwd, grp from . import interfaces import tuned.logs import tuned.consts as consts from inspect import ismethod import socket import json import select log = tuned.logs.get() class UnixSocketExporter(interfaces.ExporterInterface): """ Export method calls through Unix Domain Socket Interface. We take a method to be exported and create a simple wrapper function to call it. This is required as we need the original function to be bound to the original object instance. While the wrapper will be bound to an object we dynamically construct. """ def __init__(self, socket_path=consts.CFG_DEF_UNIX_SOCKET_PATH, signal_paths=consts.CFG_DEF_UNIX_SOCKET_SIGNAL_PATHS, ownership=consts.CFG_DEF_UNIX_SOCKET_OWNERSHIP, permissions=consts.CFG_DEF_UNIX_SOCKET_PERMISIONS, connections_backlog=consts.CFG_DEF_UNIX_SOCKET_CONNECTIONS_BACKLOG): self._socket_path = socket_path self._socket_object = None self._socket_signal_paths = signal_paths self._socket_signal_objects = [] self._ownership = [-1, -1] if ownership: ownership = ownership.split() for i, o in enumerate(ownership[:2]): try: self._ownership[i] = int(o) except ValueError: try: # user if i == 0: self._ownership[i] = pwd.getpwnam(o).pw_uid # group else: self._ownership[i] = grp.getgrnam(o).gr_gid except KeyError: log.error("%s '%s' does not exists, leaving default" % ("User" if i == 0 else "Group", o)) self._permissions = permissions self._connections_backlog = connections_backlog self._unix_socket_methods = {} self._signals = set() self._conn = None self._channel = None def running(self): return self._socket_object is not None def export(self, method, in_signature, out_signature): if not ismethod(method): raise Exception("Only bound methods can be exported.") method_name = method.__name__ if method_name in self._unix_socket_methods: raise Exception("Method with this name (%s) is already exported." % method_name) class wrapper(object): def __init__(self, in_signature, out_signature): self._in_signature = in_signature self._out_signature = out_signature def __call__(self, *args, **kwargs): return method(*args, **kwargs) self._unix_socket_methods[method_name] = wrapper(in_signature, out_signature) def signal(self, method, out_signature): if not ismethod(method): raise Exception("Only bound methods can be exported.") method_name = method.__name__ if method_name in self._unix_socket_methods: raise Exception("Method with this name (%s) is already exported." % method_name) class wrapper(object): def __init__(self, out_signature): self._out_signature = out_signature def __call__(self, *args, **kwargs): return method(*args, **kwargs) self._unix_socket_methods[method_name] = wrapper(out_signature) self._signals.add(method_name) def send_signal(self, signal, *args, **kwargs): if not signal in self._signals: raise Exception("Signal '%s' doesn't exist." % signal) for p in self._socket_signal_paths: log.debug("Sending signal on socket %s" % p) try: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.setblocking(False) s.connect(p) self._send_data(s, {"jsonrpc": "2.0", "method": signal, "params": args}) s.close() except OSError as e: log.warning("Error while sending signal '%s' to socket '%s': %s" % (signal, p, e)) def register_signal_path(self, path): self._socket_signal_paths.append(path) def _construct_socket_object(self): if self._socket_path: if os.path.exists(self._socket_path): os.unlink(self._socket_path) self._socket_object = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self._socket_object.bind(self._socket_path) self._socket_object.listen(self._connections_backlog) os.chown(self._socket_path, self._ownership[0], self._ownership[1]) if self._permissions: os.chmod(self._socket_path, self._permissions) def start(self): if self.running(): return self.stop() self._construct_socket_object() def stop(self): if self._socket_object: self._socket_object.close() def _send_data(self, s, data): log.debug("Sending socket data: %s)" % data) try: s.send(json.dumps(data).encode("utf-8")) except Exception as e: log.warning("Failed to send data '%s': %s" % (data, e)) def _create_response(self, data, id, error=False): res = { "jsonrpc": "2.0", "id": id } if error: res["error"] = data else: res["result"] = data return res def _create_error_responce(self, code, message, id=None, data=None): return self._create_response({ "code": code, "message": message, "data": data, }, error=True, id=id) def _create_result_response(self, result, id): return self._create_response(result, id) def _check_id(self, data): if data.get("id"): return data return None def _process_request(self, req): if type(req) != dict or req.get("jsonrpc") != "2.0" or not req.get("method"): return self._create_error_responce(-32600, "Invalid Request") id = req.get("id") ret = None if req["method"] not in self._unix_socket_methods: return self._check_id(self._create_error_responce(-32601, "Method not found", id)) try: if not req.get("params"): ret = self._unix_socket_methods[req["method"]]() elif type(req["params"]) in (list, tuple): ret = self._unix_socket_methods[req["method"]](*req["params"]) elif type(req["params"]) == dict: ret = self._unix_socket_methods[req["method"]](**req["params"]) else: return self._check_id(self._create_error_responce(-32600, "Invalid Request", id)) except TypeError as e: return self._check_id(self._create_error_responce(-32602, "Invalid params", id, str(e))) except Exception as e: return self._check_id(self._create_error_responce(1, "Error", id, str(e))) return self._check_id(self._create_result_response(ret, id)) def period_check(self): """ Periodically checks socket object for new calls. This allows to function without special thread. Interface is according JSON-RPC 2.0 Specification (see https://www.jsonrpc.org/specification) Example calls: printf '[{"jsonrpc": "2.0", "method": "active_profile", "id": 1}, {"jsonrpc": "2.0", "method": "profiles", "id": 2}]' | nc -U /run/tuned/tuned.sock printf '{"jsonrpc": "2.0", "method": "switch_profile", "params": {"profile_name": "balanced"}, "id": 1}' | nc -U /run/tuned/tuned.sock """ if not self.running(): return while True: r, _, _ = select.select([self._socket_object], (), (), 0) if r: conn, _ = self._socket_object.accept() try: data = "" while True: rec_data = conn.recv(4096).decode() if not rec_data: break data += rec_data except Exception as e: log.error("Failed to load data of message: %s" % e) continue if data: try: data = json.loads(data) except Exception as e: log.error("Failed to load json data '%s': %s" % (data, e)) self._send_data(conn, self._create_error_responce(-32700, "Parse error", str(e))) continue if type(data) not in (tuple, list, dict): log.error("Wrong format of call") self._send_data(conn, self._create_error_responce(-32700, "Parse error", str(e))) continue if type(data) in (tuple, list): if len(data) == 0: self._send_data(conn, self._create_error_responce(-32600, "Invalid Request", str(e))) continue res = [] for req in data: r = self._process_request(req) if r: res.append(r) if res: self._send_data(conn, res) else: res = self._process_request(data) if r: self._send_data(conn, res) else: return