Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exportfs: check fsid #878

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oalbrigt
Copy link
Contributor

No description provided.

@@ -359,7 +359,7 @@ cleanup_export_cache() {
break
ocf_log info "Cleanup export cache ... (try $i)"
ocf_run exportfs -f
sleep 0.5
sleep 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed due to possible bashism

@dmuhamedagic
Copy link
Contributor

On Thu, Nov 10, 2016 at 04:35:31AM -0800, Oyvind Albrigtsen wrote:

oalbrigt commented on this pull request.

@@ -359,7 +359,7 @@ cleanup_export_cache() {
break
ocf_log info "Cleanup export cache ... (try $i)"
ocf_run exportfs -f

  • sleep 0.5
    
  • sleep 1
    

changed due to possible bashism

sleep(1) is a separate program, not implemented in shell. AFAIK,
almost all platforms do support floats. Another possibility would
be sth like:

sleep 0.5 2>/dev/null || sleep 1

But are you sure that a sleep is really necessary after exportfs?

@dmuhamedagic
Copy link
Contributor

On Thu, Nov 10, 2016 at 04:29:53PM +0100, Dejan Muhamedagic wrote:

On Thu, Nov 10, 2016 at 04:35:31AM -0800, Oyvind Albrigtsen wrote:

oalbrigt commented on this pull request.

@@ -359,7 +359,7 @@ cleanup_export_cache() {
break
ocf_log info "Cleanup export cache ... (try $i)"
ocf_run exportfs -f

  •   sleep 0.5
    
  •   sleep 1
    

changed due to possible bashism

sleep(1) is a separate program, not implemented in shell. AFAIK,
almost all platforms do support floats. Another possibility would
be sth like:

sleep 0.5 2>/dev/null || sleep 1

But are you sure that a sleep is really necessary after exportfs?

I see now that sleep was already there. At any rate, I don't
think that this change is necessary. Or has somebody complained
about it? Reported a bug?

if [ "$1" != "meta-data" ] && [ "$1" != "usage" ] && [ "$1" != "methods" ]; then
exportfs_validate_all
fi

Copy link
Contributor

Choose a reason for hiding this comment

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

This is superfluous (handled by ocf_rarun).

if ! echo "$OCF_RESKEY_fsid" | grep -q -E "^[A-Za-z0-9-]*$"; then
ocf_exit_reason "$OCF_RESKEY_fsid is not a valid fsid"
return $OCF_ERR_CONFIGURED
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I see now that there's a check for this below (ocf_is_decimal). Anything wrong with it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Missed that there's a check only for multiple directories. Anyway, exports(5) says here:
Other filesystems can be identified with a small integer, or a
UUID which should contain 32 hex digits and arbitrary punctua‐
tion.
That doesn't match the regexp in grep above.

Copy link
Contributor

Choose a reason for hiding this comment

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

The regexp matching that description would be: '^(root|[[:xdigit:][:punct:]]*)$'. And then we'd need to hope that the description is precise. Somehow, I'd rather let this be as is, lest we introduce a regression.

@oalbrigt oalbrigt force-pushed the exportfs-check-fsid branch from e206944 to 3fdbc26 Compare November 10, 2016 16:07
@oalbrigt
Copy link
Contributor Author

Updated based on the comments.

The sleep was changed as it was caught when I tried running checkbashisms on the script, so I figured that was worth fixing as well.

$ checkbashisms heartbeat/exportfs
possible bashism in heartbeat/exportfs line 362 (sleep only takes one integer):
sleep 0.5

@dmuhamedagic
Copy link
Contributor

On Thu, Nov 10, 2016 at 08:10:20AM -0800, Oyvind Albrigtsen wrote:

Updated based on the comments.

The sleep was changed as it was caught when I tried running checkbashisms on the script, so I figured that was worth fixing as well.

$ checkbashisms heartbeat/exportfs
possible bashism in heartbeat/exportfs line 362 (sleep only takes one integer):
sleep 0.5

Well, checkbashisms is certainly wrong there. As mentioned, bash
doesn't implement sleep and hence has nothing to do with it.
Further, this change also has nothing to with the fsid check
either. Still further, let's not try to fix something that isn't
broken ;-)

@oalbrigt
Copy link
Contributor Author

Sure. I'll reverse that part :)

@oalbrigt oalbrigt force-pushed the exportfs-check-fsid branch from 3fdbc26 to d2932d0 Compare November 11, 2016 08:04
@oalbrigt
Copy link
Contributor Author

New update without the sleep-change.

@dmuhamedagic
Copy link
Contributor

dmuhamedagic commented Nov 16, 2016 via email

@krig
Copy link
Contributor

krig commented Nov 17, 2016

Actually I think checkbashisms is somewhat right about sleep: A POSIX compliant version only accepts integers, so for compatibility, only integers should be used:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sleep.html

I don't know if it's an issue in practice on any platform, though googling seems to indicate that only GNU sleep implements floating point arguments.

@oalbrigt oalbrigt force-pushed the exportfs-check-fsid branch from d2932d0 to d1fb323 Compare November 17, 2016 10:34
@oalbrigt
Copy link
Contributor Author

Oh. Seems like I missed that comment. I've now updated based on that.

@dmuhamedagic
Copy link
Contributor

dmuhamedagic commented Nov 17, 2016 via email

@jnpkrn
Copy link
Contributor

jnpkrn commented Nov 17, 2016

On 10/11/16 07:57 -0800, Dejan Muhamedagic wrote:

The regexp matching that description would be:
'^(root|[[:xdigit:][:punct:]]*)$'. And then we'd need to hope that
the description is precise. Somehow, I'd rather let this be as is,
lest we introduce a regression.

nfs-utils in fact only have these restrictions on UUID:

  • only hex characters do count (as in isxdigit(3))
  • there must be exactly 32 of them throughout the value,
    i.e. "punctuation" is an arbitrary int X for which isxdigit(X) == 0

http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=blob;f=utils/mountd/cache.c;hb=nfs-utils-1-3-5-rc3#l260
http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=blob;f=support/nfs/exports.c;hb=nfs-utils-1-3-5-rc3#l391

On 16/11/16 20:06 -0800, Kristoffer Grönlund wrote:

I don't know if it's an issue in practice on any platform, though
googling seems to indicate that only GNU sleep implements floating
point arguments.

Yes, at least since some 17 years ago:
http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=5617251


Anyway, the main problem I see here is that fsid can be formatted
so unfortunately, that it will break the validity of a sed expression
later on. Being string on fsid would alleviate this issue, of new
approach is to be chosen.

Jan (Poki)

@jnpkrn
Copy link
Contributor

jnpkrn commented Nov 17, 2016

On 17/11/16 12:15 +0100, Jan Pokorný wrote:

Being string on fsid would alleviate this issue, of new approach is
to be chosen.

s/string/strict/ :-)

Jan (Poki)

@jnpkrn
Copy link
Contributor

jnpkrn commented Nov 21, 2016

Please see #887 if you find it any better.
It's still somewhat bound to lazy side of the scale, but is a bit more systemic, IMHO.

@dmuhamedagic
Copy link
Contributor

dmuhamedagic commented Nov 21, 2016 via email

@jnpkrn
Copy link
Contributor

jnpkrn commented Nov 22, 2016

On 21/11/16 08:13 -0800, Dejan Muhamedagic wrote:

What I've been trying to understand is the motivation for the
change: can someone shed some light on that aspect. If there's a
problem with a fsid, it's going to be caught by exportfs.

It's a self-defense of the agent's inner handling of the parameters,
as detailed in #887. I'd be surprised if this was a first one
of this kind. I'd be also surprised if some parameter validations
in any agent were not superfluous of sorts, especially if you want
to address multiple versions/implementations of the same.

Anyway, to bring more enlightment: b. from the commit message of
new PR has several implications... and it's better to prevent them.

Further, and just as important, what is the benefit of mimicking
a check which is already implemented in nfs-utils? In general, I'd
assume that such duplication is better avoided. I could spell out
the reasons, but you all certainly know them.

PR #887 doesn't mimick any validation performed down the road,
but rather introduces new -- in practice negligible -- limitation
so as to counterweight the detailed shortcomings.

I admit it's rather lazy approach, but does this pose any issues
compared to sanity gains?

Poki

@dmuhamedagic
Copy link
Contributor

On Tue, Nov 22, 2016 at 08:15:10AM -0800, Jan Pokorný wrote:

On 21/11/16 08:13 -0800, Dejan Muhamedagic wrote:

What I've been trying to understand is the motivation for the
change: can someone shed some light on that aspect. If there's a
problem with a fsid, it's going to be caught by exportfs.

It's a self-defense of the agent's inner handling of the parameters,
as detailed in #887.

That's of course a valid concern in principle, but note that this
parameter is not really consumed by the RA (apart from the case
of multiple export), but by another program. Of course, that
doesn't mean that the RA should allow bad input to cause
malfunction, but given that the input comes from root... I mean
what would be the point of trying to break the RA by the admin
supplying some crazy value? What I'm trying to say is let's put
this in perspective of the actual use. Can we not reasonably
expect a reasonable input value?

I'd be surprised if this was a first one
of this kind. I'd be also surprised if some parameter validations
in any agent were not superfluous of sorts, especially if you want
to address multiple versions/implementations of the same.

Anyway, to bring more enlightment: b. from the commit message of
new PR has several implications... and it's better to prevent them.

Further, and just as important, what is the benefit of mimicking
a check which is already implemented in nfs-utils? In general, I'd
assume that such duplication is better avoided. I could spell out
the reasons, but you all certainly know them.

PR #887 doesn't mimick any validation performed down the road,

If I had to read exportfs(8) and you had to prowl the nfs-utils
code to see what is being allowed then it is certainly trying to
replicate the check.

but rather introduces new -- in practice negligible -- limitation
so as to counterweight the detailed shortcomings.

I admit it's rather lazy approach, but does this pose any issues
compared to sanity gains?

If exportfs cannot digest ',' then there's no harm done. But
again I do wonder if it really makes any difference.

At any rate, we should probably improve that sed expression.

@jnpkrn
Copy link
Contributor

jnpkrn commented Nov 24, 2016 via email

@jnpkrn
Copy link
Contributor

jnpkrn commented Nov 24, 2016 via email

@dmuhamedagic
Copy link
Contributor

dmuhamedagic commented Nov 30, 2016 via email

@jnpkrn
Copy link
Contributor

jnpkrn commented Dec 2, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants