diff mbox

9pfs: don't use AT_EMPTY_PATH in local_set_cred_passthrough()

Message ID 148862487677.5452.160308730808722965.stgit@bahia.lan
State New
Headers show

Commit Message

Greg Kurz March 4, 2017, 10:54 a.m. UTC
The name argument can never be an empty string, and dirfd always point to
the containing directory of the file name. AT_EMPTY_PATH is hence useless
here. Also it breaks build with glibc version 2.13 and older.

It is actually an oversight of a previous tentative patch to implement this
function. We can safely drop it.

Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p-local.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Cave-Ayland March 4, 2017, 1:52 p.m. UTC | #1
On 04/03/17 10:54, Greg Kurz wrote:

> The name argument can never be an empty string, and dirfd always point to
> the containing directory of the file name. AT_EMPTY_PATH is hence useless
> here. Also it breaks build with glibc version 2.13 and older.
> 
> It is actually an oversight of a previous tentative patch to implement this
> function. We can safely drop it.
> 
> Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>  hw/9pfs/9p-local.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index ea9a1ced0394..45e9a1f9b0ca 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -349,7 +349,7 @@ static int local_set_cred_passthrough(FsContext *fs_ctx, int dirfd,
>                                        const char *name, FsCred *credp)
>  {
>      if (fchownat(dirfd, name, credp->fc_uid, credp->fc_gid,
> -                 AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH) < 0) {
> +                 AT_SYMLINK_NOFOLLOW) < 0) {
>          /*
>           * If we fail to change ownership and if we are
>           * using security model none. Ignore the error
> 
> 

Thanks Greg - this, along with the updated version of the previous patch
fixes the build for me.

Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
Eric Blake March 4, 2017, 3:16 p.m. UTC | #2
On 03/04/2017 04:54 AM, Greg Kurz wrote:
> The name argument can never be an empty string, and dirfd always point to
> the containing directory of the file name. AT_EMPTY_PATH is hence useless
> here. Also it breaks build with glibc version 2.13 and older.
> 
> It is actually an oversight of a previous tentative patch to implement this
> function. We can safely drop it.
> 
> Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>  hw/9pfs/9p-local.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index ea9a1ced0394..45e9a1f9b0ca 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -349,7 +349,7 @@  static int local_set_cred_passthrough(FsContext *fs_ctx, int dirfd,
                                       const char *name, FsCred *credp)
 {
     if (fchownat(dirfd, name, credp->fc_uid, credp->fc_gid,
-                 AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH) < 0) {
+                 AT_SYMLINK_NOFOLLOW) < 0) {
         /*
          * If we fail to change ownership and if we are
          * using security model none. Ignore the error