@@ -50,6 +50,7 @@ my $conf_split_re = qr/^([^\s]+)\s+(.+)/; # splitting each line of the conf file
my $split_char = '[,;]'; # separator for match and options fields
my $string_comparison_re = qr/^(host|user|sec|upcall_target)(=|==|!=|~|!~)(.+)/;
+my $uid_comparison_re = qr/^(uid|creduid)(<|<=|=|==|>=|>|!=)(0x[0-9a-f]+|[0-9]+)$/;
sub log_msg {
my $msg_level = shift;
@@ -198,6 +199,17 @@ sub check_string_match {
return $result;
}
+sub check_uid_match {
+ my $key_uid = shift;
+ my $comparison = shift;
+ my $comparison_uid = shift;
+
+ $comparison_uid = scalar POSIX::strtol($comparison_uid, 16) if (substr($comparison_uid, 0, 2) eq '0x');
+
+ my $comparison_string = sprintf("%d %s %d", $key_uid, $comparison, $comparison_uid);
+ return 1 if (eval $comparison_string);
+ return 0;
+}
sub match_criterion {
my $criterion = shift;
@@ -206,6 +218,8 @@ sub match_criterion {
return 1 if ($criterion eq '*'); # '*' is always true
if (($field, $comparator, $match_pattern) = $criterion =~ $string_comparison_re) {
return 0 if (! check_string_match($key_vars{$field}, $comparator, $match_pattern));
+ } elsif (($field, $comparator, $match_pattern) = $criterion =~ $uid_comparison_re) {
+ return 0 if (! check_uid_match($key_vars{$field}, $comparator, $match_pattern));
} else {
log_msg 0, "unrecognized match string: $criterion";
return 0;
Use numeric comparisons for 'uid' and 'creduid' matching. Signed-off-by: Frank Sorenson <sorenson@redhat.com> --- contrib/upcall-helper/cifs-upcall-helper | 14 ++++++++++++++ 1 file changed, 14 insertions(+)