* [dpdk-dev] [PATCH] eal: create a runtime directory on windows
@ 2020-10-21 20:26 Pallavi Kadam
2020-10-22 18:15 ` Ranjit Menon
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Pallavi Kadam @ 2020-10-21 20:26 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, talshn, pallavi.kadam
Added eal_create_runtime_dir() function in order to run any application
as a user that does not have administrator access.
Currently, since there is no runtime directory set, the code tries to
create a file in C:\ which is only writable with administrator
privileges. As a result, if the user is not admin, the application will
fail.
Signed-off-by: Ranjit Menon <ranjit.menon@intel.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
---
lib/librte_eal/windows/eal.c | 57 ++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
index 6334aca03..b0f356405 100644
--- a/lib/librte_eal/windows/eal.c
+++ b/lib/librte_eal/windows/eal.c
@@ -5,6 +5,7 @@
#include <fcntl.h>
#include <io.h>
#include <share.h>
+#include <direct.h>
#include <sys/stat.h>
#include <rte_debug.h>
@@ -34,6 +35,55 @@ static int mem_cfg_fd = -1;
/* internal configuration (per-core) */
struct lcore_config lcore_config[RTE_MAX_LCORE];
+int
+eal_create_runtime_dir(void)
+{
+ char temp_dir[PATH_MAX];
+ char runtime_dir[PATH_MAX];
+ int ret;
+
+ /* get user-writable temp path */
+ if (GetTempPathA(sizeof(temp_dir), temp_dir) == 0) {
+ RTE_LOG_WIN32_ERR("GetTempPath");
+ return -1;
+ }
+
+ /* create DPDK runtime subdirectory under temp dir */
+ ret = strcat_s(temp_dir, sizeof(temp_dir), "dpdk");
+ if (ret != 0) {
+ RTE_LOG(ERR, EAL, "Error creating DPDK runtime path name\n");
+ return -1;
+ }
+
+ /* create prefix-specific subdirectory under DPDK runtime dir */
+ ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s\\%s",
+ temp_dir, eal_get_hugefile_prefix());
+ if (ret < 0 || ret == sizeof(runtime_dir)) {
+ RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime path\n");
+ return -1;
+ }
+
+ /* create the path if it doesn't exist - step by step */
+ ret = _mkdir(temp_dir);
+ if (ret < 0 && errno != EEXIST) {
+ RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
+ temp_dir, strerror(errno));
+ return -1;
+ }
+
+ ret = _mkdir(runtime_dir);
+ if (ret < 0 && errno != EEXIST) {
+ RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
+ runtime_dir, strerror(errno));
+ return -1;
+ }
+
+ if (eal_set_runtime_dir(runtime_dir, sizeof(runtime_dir)))
+ return -1;
+
+ return 0;
+}
+
/* Detect if we are a primary or a secondary process */
enum rte_proc_type_t
eal_proc_type_detect(void)
@@ -181,6 +231,13 @@ eal_parse_args(int argc, char **argv)
}
}
+ /* create runtime data directory */
+ if (internal_conf->no_shconf == 0 &&
+ eal_create_runtime_dir() < 0) {
+ RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
+ return -1;
+ }
+
if (eal_adjust_config(internal_conf) != 0)
return -1;
--
2.18.0.windows.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: create a runtime directory on windows
2020-10-21 20:26 [dpdk-dev] [PATCH] eal: create a runtime directory on windows Pallavi Kadam
@ 2020-10-22 18:15 ` Ranjit Menon
2020-10-22 19:05 ` Dmitry Kozlyuk
2020-10-26 18:44 ` [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users Pallavi Kadam
2 siblings, 0 replies; 9+ messages in thread
From: Ranjit Menon @ 2020-10-22 18:15 UTC (permalink / raw)
To: Pallavi Kadam, dev, thomas; +Cc: dmitry.kozliuk, Narcisa.Vasile, talshn
On 10/21/2020 1:26 PM, Pallavi Kadam wrote:
> Added eal_create_runtime_dir() function in order to run any application
> as a user that does not have administrator access.
> Currently, since there is no runtime directory set, the code tries to
> create a file in C:\ which is only writable with administrator
> privileges. As a result, if the user is not admin, the application will
> fail.
>
> Signed-off-by: Ranjit Menon <ranjit.menon@intel.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> ---
> lib/librte_eal/windows/eal.c | 57 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 57 insertions(+)
>
> diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
> index 6334aca03..b0f356405 100644
> --- a/lib/librte_eal/windows/eal.c
> +++ b/lib/librte_eal/windows/eal.c
> @@ -5,6 +5,7 @@
> #include <fcntl.h>
> #include <io.h>
> #include <share.h>
> +#include <direct.h>
> #include <sys/stat.h>
>
> #include <rte_debug.h>
> @@ -34,6 +35,55 @@ static int mem_cfg_fd = -1;
> /* internal configuration (per-core) */
> struct lcore_config lcore_config[RTE_MAX_LCORE];
>
> +int
> +eal_create_runtime_dir(void)
> +{
> + char temp_dir[PATH_MAX];
> + char runtime_dir[PATH_MAX];
> + int ret;
> +
> + /* get user-writable temp path */
> + if (GetTempPathA(sizeof(temp_dir), temp_dir) == 0) {
> + RTE_LOG_WIN32_ERR("GetTempPath");
> + return -1;
> + }
> +
> + /* create DPDK runtime subdirectory under temp dir */
> + ret = strcat_s(temp_dir, sizeof(temp_dir), "dpdk");
> + if (ret != 0) {
> + RTE_LOG(ERR, EAL, "Error creating DPDK runtime path name\n");
> + return -1;
> + }
> +
> + /* create prefix-specific subdirectory under DPDK runtime dir */
> + ret = snprintf(runtime_dir, sizeof(runtime_dir), "%s\\%s",
> + temp_dir, eal_get_hugefile_prefix());
> + if (ret < 0 || ret == sizeof(runtime_dir)) {
> + RTE_LOG(ERR, EAL, "Error creating prefix-specific runtime path\n");
> + return -1;
> + }
> +
> + /* create the path if it doesn't exist - step by step */
> + ret = _mkdir(temp_dir);
> + if (ret < 0 && errno != EEXIST) {
> + RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
> + temp_dir, strerror(errno));
> + return -1;
> + }
> +
> + ret = _mkdir(runtime_dir);
> + if (ret < 0 && errno != EEXIST) {
> + RTE_LOG(ERR, EAL, "Error creating '%s': %s\n",
> + runtime_dir, strerror(errno));
> + return -1;
> + }
> +
> + if (eal_set_runtime_dir(runtime_dir, sizeof(runtime_dir)))
> + return -1;
> +
> + return 0;
> +}
> +
> /* Detect if we are a primary or a secondary process */
> enum rte_proc_type_t
> eal_proc_type_detect(void)
> @@ -181,6 +231,13 @@ eal_parse_args(int argc, char **argv)
> }
> }
>
> + /* create runtime data directory */
> + if (internal_conf->no_shconf == 0 &&
> + eal_create_runtime_dir() < 0) {
> + RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
> + return -1;
> + }
> +
> if (eal_adjust_config(internal_conf) != 0)
> return -1;
>
Thomas, Dmitry: If at all possible, I think we should try and get this
fix into -rc2.
Without this fix, a non-admin user cannot run any application on Windows.
ranjit m.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: create a runtime directory on windows
2020-10-21 20:26 [dpdk-dev] [PATCH] eal: create a runtime directory on windows Pallavi Kadam
2020-10-22 18:15 ` Ranjit Menon
@ 2020-10-22 19:05 ` Dmitry Kozlyuk
2020-10-26 19:01 ` Kadam, Pallavi
2020-10-26 18:44 ` [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users Pallavi Kadam
2 siblings, 1 reply; 9+ messages in thread
From: Dmitry Kozlyuk @ 2020-10-22 19:05 UTC (permalink / raw)
To: Pallavi Kadam; +Cc: dev, thomas, ranjit.menon, Narcisa.Vasile, talshn
> /* Detect if we are a primary or a secondary process */
> enum rte_proc_type_t
> eal_proc_type_detect(void)
> @@ -181,6 +231,13 @@ eal_parse_args(int argc, char **argv)
> }
> }
>
> + /* create runtime data directory */
> + if (internal_conf->no_shconf == 0 &&
> + eal_create_runtime_dir() < 0) {
> + RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
> + return -1;
> + }
> +
> if (eal_adjust_config(internal_conf) != 0)
> return -1;
Windows rte_eal_init() forces in-memory operation (internal_conf.in_memory=0)
with a warning message, because runtime directory and shared configuration is
only used for multi-process. Maybe do the same for no_shconf, as it's
essentially the same, but for legacy mode?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH] eal: create a runtime directory on windows
2020-10-22 19:05 ` Dmitry Kozlyuk
@ 2020-10-26 19:01 ` Kadam, Pallavi
0 siblings, 0 replies; 9+ messages in thread
From: Kadam, Pallavi @ 2020-10-26 19:01 UTC (permalink / raw)
To: Dmitry Kozlyuk; +Cc: dev, thomas, ranjit.menon, Narcisa.Vasile, talshn
Hi Dmitry,
On 10/22/2020 12:05 PM, Dmitry Kozlyuk wrote:
>> /* Detect if we are a primary or a secondary process */
>> enum rte_proc_type_t
>> eal_proc_type_detect(void)
>> @@ -181,6 +231,13 @@ eal_parse_args(int argc, char **argv)
>> }
>> }
>>
>> + /* create runtime data directory */
>> + if (internal_conf->no_shconf == 0 &&
>> + eal_create_runtime_dir() < 0) {
>> + RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
>> + return -1;
>> + }
>> +
>> if (eal_adjust_config(internal_conf) != 0)
>> return -1;
> Windows rte_eal_init() forces in-memory operation (internal_conf.in_memory=0)
> with a warning message, because runtime directory and shared configuration is
> only used for multi-process. Maybe do the same for no_shconf, as it's
> essentially the same, but for legacy mode?
Thank you for the suggestion.
We sent out v2, forcing no_shconf to 1 for now.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users
2020-10-21 20:26 [dpdk-dev] [PATCH] eal: create a runtime directory on windows Pallavi Kadam
2020-10-22 18:15 ` Ranjit Menon
2020-10-22 19:05 ` Dmitry Kozlyuk
@ 2020-10-26 18:44 ` Pallavi Kadam
2020-10-27 23:10 ` Dmitry Kozlyuk
` (2 more replies)
2 siblings, 3 replies; 9+ messages in thread
From: Pallavi Kadam @ 2020-10-26 18:44 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, talshn, pallavi.kadam
Currently, since there is no runtime directory set, the code tries to
create a file in C:\ which is only writable with administrator
privileges. As a result, if the user is not admin, the application will
fail.
So, forcing no_shconf to 1 to prevent the code having to create files in
the runtime directory.
Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
lib/librte_eal/windows/eal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
index 6334aca03..105549de1 100644
--- a/lib/librte_eal/windows/eal.c
+++ b/lib/librte_eal/windows/eal.c
@@ -295,6 +295,7 @@ rte_eal_init(int argc, char **argv)
RTE_LOG(WARNING, EAL, "Multi-process support is requested, "
"but not available.\n");
internal_conf->in_memory = 1;
+ internal_conf->no_shconf = 1;
}
if (!internal_conf->no_hugetlbfs && (eal_hugepage_info_init() < 0)) {
--
2.18.0.windows.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users
2020-10-26 18:44 ` [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users Pallavi Kadam
@ 2020-10-27 23:10 ` Dmitry Kozlyuk
2020-10-28 12:41 ` Burakov, Anatoly
2020-10-29 18:37 ` Narcisa Ana Maria Vasile
2 siblings, 0 replies; 9+ messages in thread
From: Dmitry Kozlyuk @ 2020-10-27 23:10 UTC (permalink / raw)
To: Pallavi Kadam; +Cc: dev, thomas, ranjit.menon, Narcisa.Vasile, talshn
On Mon, 26 Oct 2020 11:44:58 -0700, Pallavi Kadam wrote:
> Currently, since there is no runtime directory set, the code tries to
> create a file in C:\ which is only writable with administrator
> privileges. As a result, if the user is not admin, the application will
> fail.
> So, forcing no_shconf to 1 to prevent the code having to create files in
> the runtime directory.
>
> Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
> lib/librte_eal/windows/eal.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
> index 6334aca03..105549de1 100644
> --- a/lib/librte_eal/windows/eal.c
> +++ b/lib/librte_eal/windows/eal.c
> @@ -295,6 +295,7 @@ rte_eal_init(int argc, char **argv)
> RTE_LOG(WARNING, EAL, "Multi-process support is requested, "
> "but not available.\n");
> internal_conf->in_memory = 1;
> + internal_conf->no_shconf = 1;
> }
>
> if (!internal_conf->no_hugetlbfs && (eal_hugepage_info_init() < 0)) {
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users
2020-10-26 18:44 ` [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users Pallavi Kadam
2020-10-27 23:10 ` Dmitry Kozlyuk
@ 2020-10-28 12:41 ` Burakov, Anatoly
2020-11-03 20:28 ` Thomas Monjalon
2020-10-29 18:37 ` Narcisa Ana Maria Vasile
2 siblings, 1 reply; 9+ messages in thread
From: Burakov, Anatoly @ 2020-10-28 12:41 UTC (permalink / raw)
To: Pallavi Kadam, dev, thomas
Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, talshn
On 26-Oct-20 6:44 PM, Pallavi Kadam wrote:
> Currently, since there is no runtime directory set, the code tries to
> create a file in C:\ which is only writable with administrator
> privileges. As a result, if the user is not admin, the application will
> fail.
> So, forcing no_shconf to 1 to prevent the code having to create files in
> the runtime directory.
>
> Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
> lib/librte_eal/windows/eal.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
> index 6334aca03..105549de1 100644
> --- a/lib/librte_eal/windows/eal.c
> +++ b/lib/librte_eal/windows/eal.c
> @@ -295,6 +295,7 @@ rte_eal_init(int argc, char **argv)
> RTE_LOG(WARNING, EAL, "Multi-process support is requested, "
> "but not available.\n");
> internal_conf->in_memory = 1;
> + internal_conf->no_shconf = 1;
> }
>
> if (!internal_conf->no_hugetlbfs && (eal_hugepage_info_init() < 0)) {
>
This is the correct way, as in-memory implies no_shconf. I would like to
deprecate noshconf option as it's a subset of what in-memory does.
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users
2020-10-28 12:41 ` Burakov, Anatoly
@ 2020-11-03 20:28 ` Thomas Monjalon
0 siblings, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2020-11-03 20:28 UTC (permalink / raw)
To: Pallavi Kadam
Cc: dev, ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, talshn,
Burakov, Anatoly
28/10/2020 13:41, Burakov, Anatoly:
> On 26-Oct-20 6:44 PM, Pallavi Kadam wrote:
> > Currently, since there is no runtime directory set, the code tries to
> > create a file in C:\ which is only writable with administrator
> > privileges. As a result, if the user is not admin, the application will
> > fail.
> > So, forcing no_shconf to 1 to prevent the code having to create files in
> > the runtime directory.
> >
> > Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> > Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> > ---
> > internal_conf->in_memory = 1;
> > + internal_conf->no_shconf = 1;
>
> This is the correct way, as in-memory implies no_shconf. I would like to
> deprecate noshconf option as it's a subset of what in-memory does.
>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users
2020-10-26 18:44 ` [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users Pallavi Kadam
2020-10-27 23:10 ` Dmitry Kozlyuk
2020-10-28 12:41 ` Burakov, Anatoly
@ 2020-10-29 18:37 ` Narcisa Ana Maria Vasile
2 siblings, 0 replies; 9+ messages in thread
From: Narcisa Ana Maria Vasile @ 2020-10-29 18:37 UTC (permalink / raw)
To: Pallavi Kadam
Cc: dev, thomas, ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, talshn
On Mon, Oct 26, 2020 at 11:44:58AM -0700, Pallavi Kadam wrote:
> Currently, since there is no runtime directory set, the code tries to
> create a file in C:\ which is only writable with administrator
> privileges. As a result, if the user is not admin, the application will
> fail.
> So, forcing no_shconf to 1 to prevent the code having to create files in
> the runtime directory.
>
> Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
> lib/librte_eal/windows/eal.c | 1 +
> 1 file changed, 1 insertion(+)
>
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-11-03 20:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 20:26 [dpdk-dev] [PATCH] eal: create a runtime directory on windows Pallavi Kadam
2020-10-22 18:15 ` Ranjit Menon
2020-10-22 19:05 ` Dmitry Kozlyuk
2020-10-26 19:01 ` Kadam, Pallavi
2020-10-26 18:44 ` [dpdk-dev] [PATCH v2] eal: enable windows apps to run on non-admin users Pallavi Kadam
2020-10-27 23:10 ` Dmitry Kozlyuk
2020-10-28 12:41 ` Burakov, Anatoly
2020-11-03 20:28 ` Thomas Monjalon
2020-10-29 18:37 ` Narcisa Ana Maria Vasile
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).