__key_value fails if initial value contains metacharacters #321

Closed
opened 2021-11-20 15:24:21 +00:00 by ungleich-gitea · 2 comments

Created by: phrawzty

The awk command which performs the essential function of __key_value will fail if the initial value contains metacharacters. For example :

# manifest
__key_value logtarget --value '/var/log/foo.log' --file 'file.cfg' --delimiter '='
# file.cfg
logtarget=/var/log/bar.log

This will end up generating an awk gsub string that contains the following :

[...] {gsub(//var/log/thing.log/, "/var/log/foo.log")} [...]

The first element is clearly illegal and will result in a syntax failure from awk.

A solution is to replace the slashes which surround the first element at line 43 of /conf/type/__key_value/gencode-remote with double-quotes, as is already the case with the second element. Is there any particular reason why slashes are preferred here over double-quotes ?

*Created by: phrawzty* The `awk` command which performs the essential function of `__key_value` will fail if the _initial_ value contains metacharacters. For example : ``` # manifest __key_value logtarget --value '/var/log/foo.log' --file 'file.cfg' --delimiter '=' ``` ``` # file.cfg logtarget=/var/log/bar.log ``` This will end up generating an awk gsub string that contains the following : ``` [...] {gsub(//var/log/thing.log/, "/var/log/foo.log")} [...] ``` The first element is clearly illegal and will result in a syntax failure from `awk`. A solution is to replace the slashes which surround the first element at line 43 of `/conf/type/__key_value/gencode-remote` with double-quotes, as is already the case with the second element. Is there any particular reason why slashes are preferred here over double-quotes ?
Author
Owner

Created by: phrawzty

Hehe, yes, that is exactly the solution. :)

*Created by: phrawzty* Hehe, yes, that is exactly the solution. :)
Author
Owner

Created by: telmich

Should be fixed in 62b5af8, can you verify that it works for you?

*Created by: telmich* Should be fixed in 62b5af8, can you verify that it works for you?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#321
No description provided.