|
|
针对FC4中自带的vsftpd_2.0.3-1
在源码中,发现写日志处理是这样的:
logging.c: Line146-165
- static void
- vsf_log_do_log_to_file(int fd, struct mystr* p_str)
- {
- if (!tunable_no_log_lock)
- {
- int retval = vsf_sysutil_lock_file(fd);
- if (vsf_sysutil_retval_is_error(retval))
- {
- return;
- }
- }
- str_replace_unprintable(p_str, '?');
- str_append_char(p_str, '\n');
- /* Ignore write failure; maybe the disk filled etc. */
- (void) str_write_loop(p_str, fd);
- if (!tunable_no_log_lock)
- {
- vsf_sysutil_unlock_file(fd);
- }
- }
复制代码
str.c: Line652-663
- void
- str_replace_unprintable(struct mystr* p_str, char new_char)
- {
- unsigned int i;
- for (i=0; i < p_str->len; i++)
- {
- if (!vsf_sysutil_isprint(p_str->p_buf[i]))
- {
- p_str->p_buf[i] = new_char;
- }
- }
- }
复制代码
sysutil.c: Line881-901
- int
- vsf_sysutil_isprint(int the_char)
- {
- /* From Solar - we know better than some libc's! Don't let any potential
- * control chars through
- */
- unsigned char uc = (unsigned char) the_char;
- if (uc <= 31)
- {
- return 0;
- }
- if (uc == 177)
- {
- return 0;
- }
- if (uc >= 128 && uc <= 159)
- {
- return 0;
- }
- return isprint(the_char);
- }
复制代码
这样的结果就是在日志中的中文会变成"?"。他的解释是Don't let any potential control chars through.
不过,vsftpd在通过syslog写系统日志时,不会这样处理。(具体信息请man vsftpd.conf)
所以,写入系统日志时的中文是存在的。 |
|