Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support encoding on glib compiled with libiconv #1048

Closed
bkil-syslogng opened this issue May 10, 2016 · 4 comments
Closed

Support encoding on glib compiled with libiconv #1048

bkil-syslogng opened this issue May 10, 2016 · 4 comments
Assignees

Comments

@bkil-syslogng
Copy link
Contributor

bkil-syslogng commented May 10, 2016

If the user compiles glib with libiconv on a platform without a native iconv, character encoding can not be specified. (The issue is not easy to reproduce on many systems, but LD_PRELOAD should do the trick.)

Given the following config:

@version: 3.8

options
{ threaded(yes); }
;
source s_program_37b57ebaaa6a460085d2d35d6f7d56ec
{ program("cat" encoding("UTF-8")); }
;
destination d_file_a3219214c5e541d5a18b0e9ca3eedee2
{ file("/tmp/81525975-13e5-4a41-8e9e-1bbd7cdc3d25.txt"); }
;
log
{ source(s_program_37b57ebaaa6a460085d2d35d6f7d56ec); destination(d_file_a3219214c5e541d5a18b0e9ca3eedee2); flags(flow-control); };

Startup fails with the following message:

[2016-05-10T11:51:22.050595] Module loaded and initialized successfully; module='afprog'
Error parsing afprog, unknown encoding UTF-8 in /home/tamasnagy/install/opt/syslog-ng/etc/syslog-ng.conf at line 7, column 88:

{ program("/bin/cat /home/tamasnagy/install/opt/syslog-ng/etc/syslog-ng.conf" encoding("UTF-8")); }
                                                                                       ^^^^^^^

syslog-ng documentation: http://www.balabit.com/support/documentation/?product=syslog-ng
mailing list: https://lists.balabit.hu/mailman/listinfo/syslog-ng

It worked correctly on syslog-ng 3.7.3.

The root cause is that lib/logproto/logproto-server.c checks supported encodings by first trying to convert from "utf8" to the given encoding. However, this always fails because "utf8" is not considered a valid encoding on some of the libraries. Internal canonicalization is done by upper casing each character.

On a separate note, this analysis concludes that the user should be advised that only those codes can be used in a syslog-ng config which are supported by the used iconv implementation, i.e., giving { program("cat" encoding("UTF8")); } should also fail on such a system. syslog-ng does not implement an extra aliasing layer and glib's aliasing doesn't seem to be exhaustive in this regard either.

Here are the aliases for libiconv:

Here are some of the aliases for glib:

bkil-syslogng added a commit to bkil-syslogng/syslog-ng that referenced this issue May 10, 2016
Although, most libc implementations provide a native iconv with various
aliases, libiconv does not know about the alias `utf8`.
Neither does glib provide this alias if compiled with libiconv.

Furthermore, be advised that the user can only specify in the syslog-ng
config those iconv codes which are supported by the local iconv or
libiconv.

Fixes syslog-ng#1048

Regression introduced:

3fa6028
"logproto: handle invalid encoding() options at parsing time"

Signed-off-by: bkil-syslogng <tamas.nagy@balabit.com>
@bkil-syslogng bkil-syslogng self-assigned this May 10, 2016
@bkil-syslogng
Copy link
Contributor Author

As a further enhancement, should we also add an utf-8 alias here?

@bazsi
Copy link
Collaborator

bazsi commented May 11, 2016

I dont think so. The value in logmatcher is a pcre flag and not an encoding
value.
On May 10, 2016 12:13 PM, "Tamas Nagy" notifications@github.com wrote:

As a further enhancement, should we also add an utf-8 alias here?

https://github.com/balabit/syslog-ng/blob/f36548bd805772d3709319b39c4ac7801e69d267/lib/logmatcher.c#L876


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1048 (comment)

@bkil-syslogng
Copy link
Contributor Author

Well, as we see, some people prefer writing utf-8, while others prefer utf8. Providing an alias here could reduce confusion.

@bazsi
Copy link
Collaborator

bazsi commented May 12, 2016

There's an alias: unicode. I dont mind the dashed version either.
On May 12, 2016 11:40 AM, "Tamas Nagy" notifications@github.com wrote:

Well, as we see, some people prefer writing utf-8, while others prefer
utf8. Providing an alias here could reduce confusion.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#1048 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants