aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-08-30 17:12:25 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2017-08-31 07:33:37 +0000
commitc67787be51c4cbf4e5c1a28af621822aa8cae513 (patch)
treefbcac7707c8fe64625b2f3ca8dfcf3d2ddaf36d5
parent203c0794837c519c32af1cf638bfd47fd17a35de (diff)
Set runtime_path properly when running non-root
non-root users should use /run/user/$PID/... Change-Id: I1ca136df7a339eff193ed9c9a396d6965b192d0e Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--src/vlib/unix/main.c13
-rw-r--r--src/vpp/vnet/main.c2
2 files changed, 12 insertions, 3 deletions
diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c
index cb34a89f87a..f52316e553b 100644
--- a/src/vlib/unix/main.c
+++ b/src/vlib/unix/main.c
@@ -57,7 +57,7 @@
#define UNIX_CLI_DEFAULT_HISTORY 50
char *vlib_default_runtime_dir __attribute__ ((weak));
-char *vlib_default_runtime_dir = "/run/vlib";
+char *vlib_default_runtime_dir = "vlib";
unix_main_t unix_main;
@@ -437,7 +437,16 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
um->unix_config_complete = 1;
if (um->runtime_dir == 0)
- um->runtime_dir = format (0, "%s%c", vlib_default_runtime_dir, 0);
+ {
+ uid_t uid = geteuid ();
+ if (uid == 00)
+ um->runtime_dir = format (0, "/run/%s%c",
+ vlib_default_runtime_dir, 0);
+ else
+ um->runtime_dir = format (0, "/run/user/%u/%s%c", uid,
+ vlib_default_runtime_dir, 0);
+ }
+
return 0;
}
diff --git a/src/vpp/vnet/main.c b/src/vpp/vnet/main.c
index 9fe65fe2fb5..76371dbe996 100644
--- a/src/vpp/vnet/main.c
+++ b/src/vpp/vnet/main.c
@@ -44,7 +44,7 @@ vpe_main_init (vlib_main_t * vm)
/*
* Default path for runtime data
*/
-char *vlib_default_runtime_dir = "/run/vpp";
+char *vlib_default_runtime_dir = "vpp";
/*
* Load plugins from /usr/lib/vpp_plugins by default