Bug #4239
Function returning binary content trigger sql error with stored config
| Status: | Accepted | Start date: | 07/15/2010 | |
|---|---|---|---|---|
| Priority: | High | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | stored configuration | |||
| Target version: | 2.7.x | |||
| Affected Puppet version: | 0.25.5 | Branch: | ||
| Keywords: | ||||
| Votes: | 2 |
Description
To generate SSL certificates on the puppet server and distributing them to puppet clients, I have created a small parser function. Unfortunately, it trigger a SQL exception with stored config : SQLite3::SQLException: unrecognized token: “‘7HÉ9¸X509KEY": INSERT INTO "param_values” (“param_name_id”, “updated_at”, “line”, “resource_id”, “value”, “created_at”) VALUES(5, '2010-07-15 17:35:42’, 81, 359, ‘7HÉ9¸X509KEY
It appears that the binary content is not escaped before passing it to the SQL database.
Here’s a small piece of code which reproduce the problem: module Puppet::Parser::Functions newfunction(:getBinaryContent, :type => :rvalue) do |args| filename=“/bin/echo” filesize = File.size(filename) content = IO.read(filename, filesize, 0) return content end end
And the manifest : file {“/root/mybinary”: ensure => present, content => getBinaryContent(); }
I don’t know how exactly store config works but it seem a bad idea to have the content param of the file stored in DB. Is the content of all file generated by template stored in DB ?
History
Updated by James Turnbull almost 2 years ago
- Status changed from Unreviewed to Accepted
- Priority changed from Normal to High
- Target version set to 2.7.x
Updated by Paul Hinze 15 days ago
I get the same behavior with storeconfigs and binary file content (a GPG keyring, in my particular case). I don’t have a special function defined, I’m just using template() to pull the content in. Switching to a source parameter in my case served as a workaround.