src: switch from fnmatch to g_pattern_match_simple

The g_pattern_match function_simple is an acceptably close
approximation of fnmatch for libvirt's needs.

In contrast to fnmatch(), the '/' character can be matched
by the wildcards, there are no '[...]' character ranges and
'*' and '?' can not be escaped to include them literally in
a pattern.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2020-01-03 15:42:13 +00:00
parent d0312c584f
commit f7df985684
8 changed files with 25 additions and 34 deletions
+2 -3
View File
@@ -19,7 +19,6 @@
*/
#include <config.h>
#include <fnmatch.h>
#include <getopt.h>
#include <signal.h>
#include <stdarg.h>
@@ -67,14 +66,14 @@ static int virLoginShellAllowedUser(virConfPtr conf,
for (i = 0; i < ngroups; i++) {
if (!(gname = virGetGroupName(groups[i])))
continue;
if (fnmatch(entry, gname, 0) == 0) {
if (g_pattern_match_simple(entry, gname)) {
ret = 0;
goto cleanup;
}
VIR_FREE(gname);
}
} else {
if (fnmatch(entry, name, 0) == 0) {
if (g_pattern_match_simple(entry, name)) {
ret = 0;
goto cleanup;
}