PATCH: use getopt_long to parse fusermount command line

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PATCH: use getopt_long to parse fusermount command line

Adam Connell
Here's a small patch to use getopt_long(3) to parse the command line of the
fusermount utility.

It allows the use of "--" to stop argument scanning. This is a nice thing to
do for users b/c fusermount can now operate on directories whose names begin
with a "-", and setuid helper programs can invoke fusermount without having to
parse arguments to verify that a supplied mount point isn't malicious (e.g. a
directory named -o\ eviloption).

All of the flag options now have long forms.

It cleans up the logic for parsing the command line so it will be easier to
add options in the future.

Cheers,
Adam


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PATCH: use getopt_long to parse fusermount command line

Adam Connell
> Here's a small patch to use getopt_long(3) to parse the command line of the
> fusermount utility.
oops...

getopt_long.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PATCH: use getopt_long to parse fusermount command line

Miklos Szeredi
In reply to this post by Adam Connell
> Here's a small patch to use getopt_long(3) to parse the command line
> of the fusermount utility.
>
> It allows the use of "--" to stop argument scanning. This is a nice
> thing to do for users b/c fusermount can now operate on directories
> whose names begin with a "-",

Right.

> and setuid helper programs can invoke fusermount without having to
> parse arguments to verify that a supplied mount point isn't
> malicious (e.g. a directory named -o\ eviloption).

Why is this a problem?  Fusermount will error out because of the
missing mountpoint.

> -    if (a == argc) {
> +    if (i >= argc) {
>          fprintf(stderr, "%s: missing mountpoint argument\n", progname);
>          exit(1);
>      }
>  
> -    origmnt = argv[a++];
> +    origmnt = argv[i];

This seems wrong:  shouldn't 'optind' be used instead of 'i'?

Thanks,
Miklos


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PATCH: use getopt_long to parse fusermount command line

Adam Connell
In reply to this post by Adam Connell
> But man getopt_long says, that:
>
>        If  longindex  is not NULL, it points to a variable which is set to
> the index of the long option relative to longopts.
>
> Doesn't that mean, that it indexes longopts and not argv?  I haven't
> tried so I (and the manpage) may be wrong.

You're right, fixed patch attached.

> Thanks,
> MIklos

Cheers,
Adam

getopt_long-2.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PATCH: use getopt_long to parse fusermount command line

Miklos Szeredi
> You're right, fixed patch attached.

Thanks, applied.

Miklos


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Loading...