# Copyright (C) Cfengine AS # This file is part of CFEngine 3 - written and maintained by Cfengine AS. # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; version 3. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA # To the extent this program is licensed as part of the Enterprise # versions of Cfengine, the applicable Commercial Open Source License # (COSL) may apply to this file if you as a licensee so wish it. See # included file COSL.txt. ############################################################################### #+begin_src cfengine3 bundle agent main { vars: "private_key" comment => "The decryption key", string => "$(this.promise_filename).priv"; "encrypted_file" string => "$(this.promise_filename).cfcrypt"; "secret" comment => "We decrypt the encrypted file directly into a variable.", string => execresult("$(sys.cf_secret) -d $(private_key) -i $(encrypted_file) -o -", noshell); reports: "Encrypted file content:" printfile => cat( $(encrypted_file) ); "Decrypted content:$(const.n)$(secret)"; } body printfile cat(file) # @brief Report the contents of a file # @param file The full path of the file to report { file_to_print => "$(file)"; number_of_lines => "inf"; } #+end_src ############################################################################### #+begin_src static_example_output #@ ``` #@ R: Encrypted file content: #@ R: Version: 1.0 #@ R: #@ R: ���V�cv�#�P��, ��-O�8旼[i����p򢢦�Q� #@ 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?+�暢��So��.Org]�"+�S����_HѢ=_O% #@ R: Decrypted content: #@ Super secret message is here #@ ``` #+end_src