Skip to content

rgw: modify string match_wildcards with fnmatch - #53156

Merged
cbodley merged 2 commits into
ceph:mainfrom
qiuxinyidian:rgw-dev
Jan 9, 2024
Merged

cbodley merged 2 commits into
ceph:mainfrom
qiuxinyidian:rgw-dev

Conversation

@qiuxinyidian

@qiuxinyidian qiuxinyidian commented Aug 25, 2023 •

Copy link
Copy Markdown
Contributor

Fixes: https://tracker.ceph.com/issues/62292

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@qiuxinyidian
qiuxinyidian requested a review from a team as a code owner August 25, 2023 16:57
@qiuxinyidian

qiuxinyidian commented Aug 31, 2023 •

Copy link
Copy Markdown
Contributor Author

arm make check fail for env issue. try it again.

@qiuxinyidian qiuxinyidian reopened this Aug 31, 2023
@qiuxinyidian

Copy link
Copy Markdown
Contributor Author

anybody ?

@cbodley cbodley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/rgw/rgw_string.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, we can't assume that these string_views are null-terminated

@qiuxinyidian qiuxinyidian Sep 17, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, we can't assume that these string_views are null-terminated

in http://web.mit.edu/freebsd/csup/fnmatch.c see

#define	EOS	'\0'

static const char *rangematch(const char *, char, int);

int
fnmatch(const char *pattern, const char *string, int flags)
{
	const char *stringstart;
	char c, test;

	for (stringstart = string;;)
		switch (c = *pattern++) {
		case EOS:
			if ((flags & FNM_LEADING_DIR) && *string == '/')
				return (0);
			return (*string == EOS ? 0 : FNM_NOMATCH);
		case '?':

@cbodley cbodley Sep 18, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fnmatch() expects its input strings to be null-terminated, but std::string_view variables are not required to be null-terminated - that's why they don't have a c_str() member function. for example, match_policy() can break the arguments up by :s and call match_wildcards() on each substring. in that case, passing these std::string_view pattern, std::string_view input arguments directly to fnmatch() would try to match the entire strings (up to their null terminators) instead of just the substrings

if we are going to switch to fnmatch(), then the arguments to match_wildcards() and match_policy() should change to const char*s or const std::string&s to reflect that requirement

@adamemerson do you agree that we should handle the recursive/greedy matches? is fnmatch() is a good fit for this, or should we extend the existing matching logic?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well for me 1) maybe; 2) probably not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is fnmatch() is a good fit for this, or should we extend the existing matching logic? @mattbenjamin @adamemerson

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I think I'd prefer extending the existing logic to extra allocations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbodley @adamemerson @mattbenjamin
What should we do next ?
Maybe one of us should extend the existing logic to extra allocations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbodley @adamemerson maybe change match_wildcards to recursive way?

@cbodley cbodley Dec 8, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuxinyidian sorry for the delays. i do think we should match aws' behavior for this parsing, and i'd rather not make this parsing too complicated in the process. so i do like your approach to use fnmatch()

if we are going to switch to fnmatch(), then the arguments to match_wildcards() and match_policy() should change to const char*s or const std::string&s to reflect that requirement

can you try this way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbodley OK, i will try

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@qiuxinyidian

Copy link
Copy Markdown
Contributor Author

@cbodley please check it .

@qiuxinyidian

Copy link
Copy Markdown
Contributor Author

@adamemerson please check it

@cbodley

cbodley commented Jan 9, 2024

Copy link
Copy Markdown
Contributor

@cbodley
cbodley merged commit f909132 into ceph:main Jan 9, 2024
@cbodley

cbodley commented Jan 9, 2024

Copy link
Copy Markdown
Contributor

thanks @qiuxinyidian!

@qiuxinyidian
qiuxinyidian deleted the rgw-dev branch January 23, 2024 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants