[dpdk-dev] pdump: fix dir permissions value in mkdir call

Message ID 1476110148-31624-1-git-send-email-reshma.pattan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Pattan, Reshma Oct. 10, 2016, 2:35 p.m. UTC
  From: Reshma Pattan <reshma.pattan@intel.com>

Inside the function pdump_get_socket_path(), pdump socket
directories are created using mkdir() call with permissions 700,
which was assigning wrong permissions to the directories
i.e. "d-w-r-xr-T" instead of drwx---. The reason is mkdir() call
doesn't consider 700 as an octal value until unless 0 is explicitly
added before the value. Because of this, socket creation failure is
observed when DPDK application was ran in non root user mode.
DPDK application running in root user mode never reported the issue.

So 0 is prefixed to the value to create directories with
the correct permissions.

Fixes: e4ffa2d3 ("pdump: fix error handlings")
Fixes: bdd8dcc6 ("pdump: fix default socket path")

Reported-by: Jianfeng Tan <jianfeng.tan@intel.com>
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 lib/librte_pdump/rte_pdump.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Remy Horton Oct. 10, 2016, 9:44 p.m. UTC | #1
On 10/10/2016 15:35, Reshma Pattan wrote:
[..]
> Fixes: e4ffa2d3 ("pdump: fix error handlings")
> Fixes: bdd8dcc6 ("pdump: fix default socket path")
>
> Reported-by: Jianfeng Tan <jianfeng.tan@intel.com>
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> ---
>  lib/librte_pdump/rte_pdump.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Acked-by: Remy Horton <remy.horton@intel.com>
  
Thomas Monjalon Oct. 12, 2016, 12:40 p.m. UTC | #2
2016-10-10 22:44, Remy Horton:
> 
> On 10/10/2016 15:35, Reshma Pattan wrote:
> [..]
> > Fixes: e4ffa2d3 ("pdump: fix error handlings")
> > Fixes: bdd8dcc6 ("pdump: fix default socket path")
> >
> > Reported-by: Jianfeng Tan <jianfeng.tan@intel.com>
> > Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> > ---
> >  lib/librte_pdump/rte_pdump.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Acked-by: Remy Horton <remy.horton@intel.com>

Applied, thanks
  
Jianfeng Tan Oct. 13, 2016, 11:24 a.m. UTC | #3
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Reshma Pattan
> Sent: Monday, October 10, 2016 10:36 PM
> To: dev@dpdk.org
> Cc: Pattan, Reshma
> Subject: [dpdk-dev] [PATCH] pdump: fix dir permissions value in mkdir call
> 
> From: Reshma Pattan <reshma.pattan@intel.com>
> 
> Inside the function pdump_get_socket_path(), pdump socket
> directories are created using mkdir() call with permissions 700,
> which was assigning wrong permissions to the directories
> i.e. "d-w-r-xr-T" instead of drwx---. The reason is mkdir() call
> doesn't consider 700 as an octal value until unless 0 is explicitly
> added before the value. Because of this, socket creation failure is
> observed when DPDK application was ran in non root user mode.
> DPDK application running in root user mode never reported the issue.
> 
> So 0 is prefixed to the value to create directories with
> the correct permissions.
> 
> Fixes: e4ffa2d3 ("pdump: fix error handlings")
> Fixes: bdd8dcc6 ("pdump: fix default socket path")
> 
> Reported-by: Jianfeng Tan <jianfeng.tan@intel.com>
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>

Tested-by: Jianfeng Tan <jianfeng.tan@intel.com>

Thank you Reshma.
  

Patch

diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c
index 9b921ce..ea5ccd9 100644
--- a/lib/librte_pdump/rte_pdump.c
+++ b/lib/librte_pdump/rte_pdump.c
@@ -471,12 +471,12 @@  pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type)
 			snprintf(dpdk_dir, sizeof(dpdk_dir), "%s%s",
 					SOCKET_PATH_VAR_RUN, DPDK_DIR);
 
-		mkdir(dpdk_dir, 700);
+		mkdir(dpdk_dir, 0700);
 		snprintf(dir, sizeof(dir), "%s%s",
 					dpdk_dir, SOCKET_DIR);
 	}
 
-	ret =  mkdir(dir, 700);
+	ret =  mkdir(dir, 0700);
 	/* if user passed socket path is invalid, return immediately */
 	if (ret < 0 && errno != EEXIST) {
 		RTE_LOG(ERR, PDUMP,