1# Copyright (C) Cfengine AS 2 3# This file is part of CFEngine 3 - written and maintained by Cfengine AS. 4 5# This program is free software; you can redistribute it and/or modify it 6# under the terms of the GNU General Public License as published by the 7# Free Software Foundation; version 3. 8 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13 14# You should have received a copy of the GNU General Public License 15# along with this program; if not, write to the Free Software 16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 17 18# To the extent this program is licensed as part of the Enterprise 19# versions of Cfengine, the applicable Commercial Open Source License 20# (COSL) may apply to this file if you as a licensee so wish it. See 21# included file COSL.txt. 22 23############################################################################### 24#+begin_src cfengine3 25bundle agent main 26{ 27 vars: 28 29 "private_key" 30 comment => "The decryption key", 31 string => "$(this.promise_filename).priv"; 32 33 "encrypted_file" string => "$(this.promise_filename).cfcrypt"; 34 35 "secret" 36 comment => "We decrypt the encrypted file directly into a variable.", 37 string => execresult("$(sys.cf_secret) -d $(private_key) -i $(encrypted_file) -o -", noshell); 38 39 reports: 40 "Encrypted file content:" 41 printfile => cat( $(encrypted_file) ); 42 43 "Decrypted content:$(const.n)$(secret)"; 44} 45 46body printfile cat(file) 47# @brief Report the contents of a file 48# @param file The full path of the file to report 49{ 50 file_to_print => "$(file)"; 51 number_of_lines => "inf"; 52} 53#+end_src 54 55############################################################################### 56#+begin_src static_example_output 57#@ ``` 58#@ R: Encrypted file content: 59#@ R: Version: 1.0 60#@ R: 61#@ R: ���V�cv�#�P��, ��-O�8旼[i����p�Q� 62#@ R: Φ&l�x'�#j���qQ����[�F�1����v�Q��ˮ�J'�թ�|^HG%)�`&�����~k�$wd]"�%4X\(Q�~�O����s�A~���/��:�" gi�Rn&ٍ�E^���߬3��M�ə�%2s�SB��b3���K4wm����o�B�:P��O�#��1�t8��`�@��j/��+����j��g����Z�D�iJ��͞j��8ĉ�ag�9vz?+�暢��So��.Org]�"+�S����_HѢ=_O% 63#@ R: Decrypted content: 64#@ Super secret message is here 65#@ ``` 66#+end_src 67