aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <roland@topspin.com>2005-06-24 16:06:01 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 11:35:56 -0800
commit5091b3e8360a0cd552e69eae76dba4868e3f113f (patch)
treec5cbe4f5579f60c512059cf1319852f983adc4f5
parentbc8f5e2c9dfc80dd310d12013ed970aa15da566b (diff)
downloadlibibverbs-5091b3e8360a0cd552e69eae76dba4868e3f113f.tar.gz
Don't follow driver path in user's environment if we're running SUID
Signed-off-by: Roland Dreier <roland@topspin.com>
-rw-r--r--src/init.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/init.c b/src/init.c
index 4fc6d37..e57482f 100644
--- a/src/init.c
+++ b/src/init.c
@@ -41,6 +41,8 @@
#include <glob.h>
#include <stdio.h>
#include <dlfcn.h>
+#include <unistd.h>
+#include <sys/types.h>
#include "ibverbs.h"
@@ -207,11 +209,17 @@ static void INIT ibverbs_init(void)
*/
load_driver(NULL);
- user_path = getenv(OPENIB_DRIVER_PATH_ENV);
- if (user_path) {
- wr_path = strdupa(user_path);
- while ((dir = strsep(&wr_path, ";:")))
- find_drivers(dir);
+ /*
+ * Only follow the path passed in through the calling user's
+ * environment if we're not running SUID.
+ */
+ if (getuid() == geteuid()) {
+ user_path = getenv(OPENIB_DRIVER_PATH_ENV);
+ if (user_path) {
+ wr_path = strdupa(user_path);
+ while ((dir = strsep(&wr_path, ";:")))
+ find_drivers(dir);
+ }
}
find_drivers(default_path);