libselinux: do not log on unexpected escaped character
PATCH 1/1 libselinux: do not log on unexpected escaped character
For file_contexts entries relying on PCRE2, there are multiple escaped characters that are valid (e.g., \d). If such a character is identified, a log message is emitted. While this may have been useful for debugging, there is nothing actionable from that info message. Remove it.
--- libselinux/src/label_file.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
libselinux/src/label_file.h +3 -5
@@ -231,7 +231,7 @@ static inline const char* file_kind_to_string(uint8_t file_kind)* Determine whether the regular expression specification has any meta characters * or any unsupported escape sequence. */ -static bool regex_has_meta_chars (const char *regex,size_t *prefix_len,const char *path,unsigned int lineno) +static bool regex_has_meta_chars (const char *regex,size_t *prefix_len) {const char *p = regex;size_t plen =0 ;
@@ -275,8 +275,7 @@ static bool regex_has_meta_chars(const char *regex, size_t *prefix_len, const chcase ',' :continue ;default : -COMPAT_LOG (SELINUX_INFO ,"%s: line %u has unsupported escaped character %c (%#x) for literal matching, continuing using regex\n" , - path, lineno,isprint ((unsigned char )*p) ? *p :'?' , *p); +/* Unsupported escaped character, continuing using regex */ *prefix_len = plen;return true; }
@@ -343,7 +342,6 @@ static int regex_simplify(const char *regex, size_t len, char **out, const char *p++ = regex[i++];break ;default : -/* regex_has_meta_chars() reported already the notable occurrences */ free (result);return 0 ; }
@@ -523,7 +521,7 @@ static int insert_spec(const struct selabel_handle *rec, struct saved_data *datareturn -1 ; } - has_meta =regex_has_meta_chars (regex, &prefix_len, path, lineno); + has_meta =regex_has_meta_chars (regex, &prefix_len);/* Ensured by read_spec_entry() */ assert (prefix_len <UINT16_MAX );
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
Quoted 8 lines · Thiébaud Weksteen
For
file_contextsentries relying on PCRE2, there are multiple escaped characters that are valid (e.g., \d). If such a character is identified, a log message is emitted. While this may have been useful for debugging, there is nothing actionable from that info message. Remove it.Fixes 92306daf521 ("libselinux: rework selabel_file(5) database")Signed-off-by Thiébaud Weksteen <[email protected]>
Quoted 47 lines
--- libselinux/src/label_file.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)libselinux/src/label_file.h +3
-6@@ -231,7 +231,7 @@ static inline const char* file_kind_to_string(uint8_t file_kind)* Determine whether the regular expression specification has any meta characters * or any unsupported escape sequence. */ -static bool regex_has_meta_chars (const char *regex,size_t *prefix_len,const char *path,unsigned int lineno) +static bool regex_has_meta_chars (const char *regex,size_t *prefix_len) {const char *p = regex;size_t plen =0 ;@@ -275,8 +275,7 @@ static bool regex_has_meta_chars(const char *regex, size_t *prefix_len, const chcase ',' :continue ;default : -COMPAT_LOG (SELINUX_INFO ,"%s: line %u has unsupported escaped character %c (%#x) for literal matching, continuing using regex\n" , - path, lineno,isprint ((unsigned char )*p) ? *p :'?' , *p); +/* Unsupported escaped character, continuing using regex */ *prefix_len = plen;return true; }@@ -343,7 +342,6 @@ static int regex_simplify(const char *regex, size_t len, char **out, const char *p++ = regex[i++];break ;default : -/* regex_has_meta_chars() reported already the notable occurrences */ free (result);return 0 ; }@@ -523,7 +521,7 @@ static int insert_spec(const struct selabel_handle *rec, struct saved_data *datareturn -1 ; } - has_meta =regex_has_meta_chars (regex, &prefix_len, path, lineno); + has_meta =regex_has_meta_chars (regex, &prefix_len);/* Ensured by read_spec_entry() */ assert (prefix_len <UINT16_MAX ); --2.53.0.473.g4a7958ca14-goog
Quoted 8 lines · Christian Göttsche
Quoted 6 lines · Thiébaud Weksteen
For
file_contextsentries relying on PCRE2, there are multiple escaped characters that are valid (e.g., \d). If such a character is identified, a log message is emitted. While this may have been useful for debugging, there is nothing actionable from that info message. Remove it.
Quoted 5 lines
Quoted 2 lines
Fixes 92306daf521 ("libselinux: rework selabel_file(5) database")Signed-off-by Thiébaud Weksteen <[email protected]>
This patch has been merged.
Thanks,
Jim
Quoted 48 lines
Quoted 47 lines
--- libselinux/src/label_file.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)libselinux/src/label_file.h +3
-6@@ -231,7 +231,7 @@ static inline const char* file_kind_to_string(uint8_t file_kind)* Determine whether the regular expression specification has any meta characters * or any unsupported escape sequence. */ -static bool regex_has_meta_chars (const char *regex,size_t *prefix_len,const char *path,unsigned int lineno) +static bool regex_has_meta_chars (const char *regex,size_t *prefix_len) {const char *p = regex;size_t plen =0 ;@@ -275,8 +275,7 @@ static bool regex_has_meta_chars(const char *regex, size_t *prefix_len, const chcase ',' :continue ;default : -COMPAT_LOG (SELINUX_INFO ,"%s: line %u has unsupported escaped character %c (%#x) for literal matching, continuing using regex\n" , - path, lineno,isprint ((unsigned char )*p) ? *p :'?' , *p); +/* Unsupported escaped character, continuing using regex */ *prefix_len = plen;return true; }@@ -343,7 +342,6 @@ static int regex_simplify(const char *regex, size_t len, char **out, const char *p++ = regex[i++];break ;default : -/* regex_has_meta_chars() reported already the notable occurrences */ free (result);return 0 ; }@@ -523,7 +521,7 @@ static int insert_spec(const struct selabel_handle *rec, struct saved_data *datareturn -1 ; } - has_meta =regex_has_meta_chars (regex, &prefix_len, path, lineno); + has_meta =regex_has_meta_chars (regex, &prefix_len);/* Ensured by read_spec_entry() */ assert (prefix_len <UINT16_MAX ); --2.53.0.473.g4a7958ca14-goog