From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: virtio-fs@redhat.com, qemu-devel@nongnu.org, vgoyal@redhat.com
Subject: Re: [Virtio-fs] [PATCH 3/3] virtiofsd: Allow addition or removal of capabilities
Date: Fri, 26 Jun 2020 19:42:52 +0100 [thread overview]
Message-ID: <20200626184252.GS3087@work-vm> (raw)
In-Reply-To: <20200626103117.GE281902@stefanha-x1.localdomain>
* Stefan Hajnoczi (stefanha@redhat.com) wrote:
> On Thu, Jun 25, 2020 at 05:29:29PM +0100, Dr. David Alan Gilbert (git) wrote:
> > + /*
> > + * The modcaps option is a colon separated list of caps,
> > + * each preceded by either + or -.
> > + */
> > + while (lo->modcaps) {
> > + capng_act_t action;
> > + int cap;
> > +
> > + char *next = strchr(lo->modcaps, ':');
> > + if (next) {
> > + *next = '\0';
> > + next++;
> > + }
> > +
> > + switch (lo->modcaps[0]) {
> > + case '+':
> > + action = CAPNG_ADD;
> > + break;
> > +
> > + case '-':
> > + action = CAPNG_DROP;
> > + break;
> > +
> > + default:
> > + fuse_log(FUSE_LOG_ERR,
> > + "%s: Expecting '+'/'-' in modcaps but found '%c'\n",
> > + __func__, lo->modcaps[0]);
> > + exit(1);
> > + }
> > + cap = capng_name_to_capability(lo->modcaps + 1);
> > + if (cap < 0) {
> > + fuse_log(FUSE_LOG_ERR, "%s: Unknown capability '%s'\n", __func__,
> > + lo->modcaps);
> > + exit(1);
> > + }
> > + if (capng_update(action, CAPNG_PERMITTED | CAPNG_EFFECTIVE, cap)) {
> > + fuse_log(FUSE_LOG_ERR, "%s: capng_update failed for '%s'\n",
> > + __func__, lo->modcaps);
> > + exit(1);
> > + }
> > +
> > + lo->modcaps = next;
>
> How about passing char *modcaps into this function so that lo->modcaps
> isn't modified by the parsing loop? That seems a bit cleaner and if we
> ever decide to free lo->modcaps it will work as expected.
Yep, can do.
Dave
> Stefan
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
WARNING: multiple messages have this Message-ID (diff)
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: virtio-fs@redhat.com, qemu-devel@nongnu.org, vgoyal@redhat.com
Subject: Re: [PATCH 3/3] virtiofsd: Allow addition or removal of capabilities
Date: Fri, 26 Jun 2020 19:42:52 +0100 [thread overview]
Message-ID: <20200626184252.GS3087@work-vm> (raw)
In-Reply-To: <20200626103117.GE281902@stefanha-x1.localdomain>
* Stefan Hajnoczi (stefanha@redhat.com) wrote:
> On Thu, Jun 25, 2020 at 05:29:29PM +0100, Dr. David Alan Gilbert (git) wrote:
> > + /*
> > + * The modcaps option is a colon separated list of caps,
> > + * each preceded by either + or -.
> > + */
> > + while (lo->modcaps) {
> > + capng_act_t action;
> > + int cap;
> > +
> > + char *next = strchr(lo->modcaps, ':');
> > + if (next) {
> > + *next = '\0';
> > + next++;
> > + }
> > +
> > + switch (lo->modcaps[0]) {
> > + case '+':
> > + action = CAPNG_ADD;
> > + break;
> > +
> > + case '-':
> > + action = CAPNG_DROP;
> > + break;
> > +
> > + default:
> > + fuse_log(FUSE_LOG_ERR,
> > + "%s: Expecting '+'/'-' in modcaps but found '%c'\n",
> > + __func__, lo->modcaps[0]);
> > + exit(1);
> > + }
> > + cap = capng_name_to_capability(lo->modcaps + 1);
> > + if (cap < 0) {
> > + fuse_log(FUSE_LOG_ERR, "%s: Unknown capability '%s'\n", __func__,
> > + lo->modcaps);
> > + exit(1);
> > + }
> > + if (capng_update(action, CAPNG_PERMITTED | CAPNG_EFFECTIVE, cap)) {
> > + fuse_log(FUSE_LOG_ERR, "%s: capng_update failed for '%s'\n",
> > + __func__, lo->modcaps);
> > + exit(1);
> > + }
> > +
> > + lo->modcaps = next;
>
> How about passing char *modcaps into this function so that lo->modcaps
> isn't modified by the parsing loop? That seems a bit cleaner and if we
> ever decide to free lo->modcaps it will work as expected.
Yep, can do.
Dave
> Stefan
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2020-06-26 18:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 16:29 [Virtio-fs] [PATCH 0/3] virtiofsd capability changes and addition Dr. David Alan Gilbert (git)
2020-06-25 16:29 ` Dr. David Alan Gilbert (git)
2020-06-25 16:29 ` [Virtio-fs] [PATCH 1/3] virtiofsd: Terminate capability list Dr. David Alan Gilbert (git)
2020-06-25 16:29 ` Dr. David Alan Gilbert (git)
2020-06-26 10:31 ` [Virtio-fs] " Stefan Hajnoczi
2020-06-26 10:31 ` Stefan Hajnoczi
2020-06-25 16:29 ` [Virtio-fs] [PATCH 2/3] virtiofsd: Check capability calls Dr. David Alan Gilbert (git)
2020-06-25 16:29 ` Dr. David Alan Gilbert (git)
2020-06-26 10:31 ` [Virtio-fs] " Stefan Hajnoczi
2020-06-26 10:31 ` Stefan Hajnoczi
2020-06-25 16:29 ` [Virtio-fs] [PATCH 3/3] virtiofsd: Allow addition or removal of capabilities Dr. David Alan Gilbert (git)
2020-06-25 16:29 ` Dr. David Alan Gilbert (git)
2020-06-26 10:31 ` [Virtio-fs] " Stefan Hajnoczi
2020-06-26 10:31 ` Stefan Hajnoczi
2020-06-26 18:42 ` Dr. David Alan Gilbert [this message]
2020-06-26 18:42 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200626184252.GS3087@work-vm \
--to=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vgoyal@redhat.com \
--cc=virtio-fs@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.