[libvirt] [PATCH] Allow sticky bit to be read and set.

--- src/conf/storage_conf.c | 8 +++++--- src/storage/storage_backend.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 3132aae..017648d 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -667,7 +667,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, } else { int tmp; - if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || (tmp & ~0777)) { + if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || + (tmp & ~(S_ISVTX | S_IRWXUGO))) { VIR_FREE(mode); virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed octal mode")); @@ -1037,7 +1038,7 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def) { virBufferAddLit(&buf," <permissions>\n"); virBufferAsprintf(&buf," <mode>0%o</mode>\n", - def->target.perms.mode); + def->target.perms.mode & (S_ISVTX | S_IRWXUGO)); virBufferAsprintf(&buf," <owner>%d</owner>\n", (int) def->target.perms.uid); virBufferAsprintf(&buf," <group>%d</group>\n", @@ -1290,7 +1291,8 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options, virBufferAddLit(buf," <permissions>\n"); virBufferAsprintf(buf," <mode>0%o</mode>\n", - def->perms.mode); + def->perms.mode & + (S_ISVTX | S_IRWXUGO)); virBufferAsprintf(buf," <owner>%u</owner>\n", (unsigned int) def->perms.uid); virBufferAsprintf(buf," <group>%u</group>\n", diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index df3833a..5fd14ed 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -1210,7 +1210,7 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target, } } - target->perms.mode = sb.st_mode & S_IRWXUGO; + target->perms.mode = sb.st_mode & (S_ISVTX | S_IRWXUGO); target->perms.uid = sb.st_uid; target->perms.gid = sb.st_gid; -- 1.7.8.6

On 08/10/2012 07:19 AM, Ján Tomko wrote: Commit message is sparse, give one or two sentences why this might be useful.
--- src/conf/storage_conf.c | 8 +++++--- src/storage/storage_backend.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 3132aae..017648d 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -667,7 +667,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, } else { int tmp;
- if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || (tmp & ~0777)) { + if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || + (tmp & ~(S_ISVTX | S_IRWXUGO))) {
POSIX requires S_ISVTX to be a constant value, so it's also okay to write this 01777, but I like the symbolic naming as evidence of what we're doing. ACK once you provide a commit message. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/14/2012 05:18 PM, Eric Blake wrote:
On 08/10/2012 07:19 AM, Ján Tomko wrote:
Commit message is sparse, give one or two sentences why this might be useful.
ACK once you provide a commit message.
Hmm, maybe I was too hasty in giving this an ack, since there still seems to be a discussion around your v2 patch on whether we even want to silently ignore or error out on extra bits that we don't allow, and on whether files behave differently than directories. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Ján Tomko