Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux-HA: Dev
Re: [resource-agents] exportfs change to support wildcard exports (#45)
 

Index | Next | Previous | View Flat


lars.ellenberg at linbit

Dec 13, 2011, 1:55 PM


Views: 469
Permalink
Re: [resource-agents] exportfs change to support wildcard exports (#45)

Taking this to the mailing list to give it a wider audience.

On Tue, Dec 13, 2011 at 09:59:11AM -0800, acqant wrote:
> --- a/heartbeat/exportfs
> +++ b/heartbeat/exportfs
> @@ -181,9 +181,11 @@ END
>
> exportfs_monitor ()
> {
> + local clientspec_re
> # "grep -z" matches across newlines, which is necessary as
> # exportfs output wraps lines for long export directory names
> - exportfs | grep -zqs "${OCF_RESKEY_directory}[[:space:]]*${OCF_RESKEY_clientspec}"
> + clientspec_re=`echo ${OCF_RESKEY_clientspec} | sed 's/*/[*]/'`
> + exportfs | grep -zqs "${OCF_RESKEY_directory}[[:space:]]*${clientspec_re}"
>
> #Adapt grep status code to OCF return code
> case $? in

> Or you can view, comment on it, or merge it online at:
>
> https://github.com/ClusterLabs/resource-agents/pull/45

Thinking about it, I've got a problem with this whole grepping thing here.

grep -z does not just "match accross newlines",
it matches records separated by NUL in that file
(which would be very unexpected).

So it matches the full file.

No anchors on the regex whatsoever.

Client spec will typically have dots in them,
both hostname and ip address form,
which would also need to be matched literally.

If you have two exports /bar and /foo/bar,
to the same (or similar enough, see above) client spec,
the grep for /bar will also match on /foo/bar.

The mount point may also contain dots or other special chars.

I don't like that, really :(

Suggestion:

Why not "unwrap" the exportfs output first,
so we get one record per line,
then match literal (grep -F)?
That should cover most of these issues
(appart from multiple consecutive blanks, or tabs, or newlines,
in the mount point... would that even be "legal"?)

exportfs | fmt -w 1000 -t -u |
grep -x -F "${OCF_RESKEY_directory} ${OCF_RESKEY_clientspec}"

I'm not completely sure about the fmt trick:
Availability should not be a problem (coreutils).
But, is the exportfs output and fmt behaviour really consistent enough
to have that work on all platforms?
But since both exportfs and fmt predate linux, maybe that just works?

If necessary, we can pull off the unwrap with sed in a more "controlled"
fashion as well.

--
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Subject User Time
Re: [resource-agents] exportfs change to support wildcard exports (#45) lars.ellenberg at linbit Dec 13, 2011, 1:55 PM
    Re: [resource-agents] exportfs change to support wildcard exports (#45) dejan at suse Jan 19, 2012, 7:18 PM
        Re: [resource-agents] exportfs change to support wildcard exports (#45) lars.ellenberg at linbit Jan 21, 2012, 8:52 AM
            Re: [resource-agents] exportfs change to support wildcard exports (#45) dejan at suse Jan 31, 2012, 7:31 AM
                Re: [resource-agents] exportfs change to support wildcard exports (#45) lars.ellenberg at linbit Jan 31, 2012, 12:21 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.