From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Dr. David Alan Gilbert (git)" <dgilbert@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 11:31:17 +0100 [thread overview]
Message-ID: <20200626103117.GE281902@stefanha-x1.localdomain> (raw)
In-Reply-To: <20200625162929.46672-4-dgilbert@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]
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.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-06-26 10:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 16:29 [PATCH 0/3] virtiofsd capability changes and addition Dr. David Alan Gilbert (git)
2020-06-25 16:29 ` [PATCH 1/3] virtiofsd: Terminate capability list Dr. David Alan Gilbert (git)
2020-06-26 10:31 ` Stefan Hajnoczi
2020-06-25 16:29 ` [PATCH 2/3] virtiofsd: Check capability calls Dr. David Alan Gilbert (git)
2020-06-26 10:31 ` Stefan Hajnoczi
2020-06-25 16:29 ` [PATCH 3/3] virtiofsd: Allow addition or removal of capabilities Dr. David Alan Gilbert (git)
2020-06-26 10:31 ` Stefan Hajnoczi [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=20200626103117.GE281902@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).