|
|
a7cfd51 |
From 47a7bb8fb64885d46c995a18d2c4601fbf9609f9 Mon Sep 17 00:00:00 2001
|
|
|
e23cb04 |
From: Brian Bockelman <bbockelm@cse.unl.edu>
|
|
|
e23cb04 |
Date: Tue, 24 Jul 2012 09:40:06 -0500
|
|
|
e23cb04 |
Subject: [PATCH] Apply the user's condor_config last, rather than first.
|
|
|
e23cb04 |
|
|
|
e23cb04 |
---
|
|
|
a7cfd51 |
src/condor_utils/condor_config.cpp | 55 +++++++++++++++++++++++++++++------
|
|
|
a7cfd51 |
1 files changed, 45 insertions(+), 10 deletions(-)
|
|
|
e23cb04 |
|
|
|
e23cb04 |
diff --git a/src/condor_utils/condor_config.cpp b/src/condor_utils/condor_config.cpp
|
|
|
a7cfd51 |
index ef35572..455bdfa 100644
|
|
|
e23cb04 |
--- a/src/condor_utils/condor_config.cpp
|
|
|
e23cb04 |
+++ b/src/condor_utils/condor_config.cpp
|
|
|
e23cb04 |
@@ -110,6 +110,7 @@ void check_params();
|
|
|
e23cb04 |
// External variables
|
|
|
e23cb04 |
extern int ConfigLineNo;
|
|
|
e23cb04 |
} /* End extern "C" */
|
|
|
e23cb04 |
+bool find_user_file(std::string &);
|
|
|
e23cb04 |
|
|
|
e23cb04 |
// Global variables
|
|
|
e23cb04 |
BUCKET *ConfigTab[TABLESIZE];
|
|
|
a7cfd51 |
@@ -654,6 +655,14 @@ real_config(char* host, int wantsQuiet, bool wantExtraInfo)
|
|
|
a7cfd51 |
if(dirlist) { free(dirlist); dirlist = NULL; }
|
|
|
a7cfd51 |
if(newdirlist) { free(newdirlist); newdirlist = NULL; }
|
|
|
a7cfd51 |
|
|
|
e23cb04 |
+ // Now, insert overrides from the user config file
|
|
|
e23cb04 |
+ std::string file_location;
|
|
|
e23cb04 |
+ if (find_user_file(file_location))
|
|
|
e23cb04 |
+ {
|
|
|
e23cb04 |
+ process_config_source( file_location.c_str(), "user local source", host, false );
|
|
|
e23cb04 |
+ local_config_sources.append(file_location.c_str());
|
|
|
e23cb04 |
+ }
|
|
|
e23cb04 |
+
|
|
|
e23cb04 |
// Now, insert any macros defined in the environment.
|
|
|
e23cb04 |
char **my_environ = GetEnviron();
|
|
|
e23cb04 |
for( int i = 0; my_environ[i]; i++ ) {
|
|
|
a7cfd51 |
@@ -996,6 +1005,38 @@ find_global()
|
|
|
e23cb04 |
}
|
|
|
e23cb04 |
|
|
|
e23cb04 |
|
|
|
e23cb04 |
+// Find user-specific location of a file
|
|
|
e23cb04 |
+// Returns true if found, and puts the location in the file_location argument.
|
|
|
e23cb04 |
+// If not found, returns false. The contents of file_location are undefined.
|
|
|
e23cb04 |
+bool
|
|
|
e23cb04 |
+find_user_file(std::string &file_location)
|
|
|
e23cb04 |
+{
|
|
|
e23cb04 |
+#ifdef UNIX
|
|
|
e23cb04 |
+ // $HOME/.condor/condor_config
|
|
|
e23cb04 |
+ struct passwd *pw = getpwuid( geteuid() );
|
|
|
e23cb04 |
+ std::stringstream ss;
|
|
|
e23cb04 |
+ if ( can_switch_ids() || !pw || !pw->pw_dir ) {
|
|
|
e23cb04 |
+ return false;
|
|
|
e23cb04 |
+ }
|
|
|
e23cb04 |
+ ss << pw->pw_dir << "/." << myDistro->Get() << "/" << myDistro->Get() << "_config";
|
|
|
e23cb04 |
+ file_location = ss.str();
|
|
|
e23cb04 |
+
|
|
|
e23cb04 |
+ int fd;
|
|
|
e23cb04 |
+ if ((fd = safe_open_wrapper_follow(file_location.c_str(), O_RDONLY)) < 0) {
|
|
|
e23cb04 |
+ return false;
|
|
|
e23cb04 |
+ } else {
|
|
|
e23cb04 |
+ close(fd);
|
|
|
e23cb04 |
+ dprintf(D_FULLDEBUG, "Reading condor configuration from '%s'\n", file_location.c_str());
|
|
|
e23cb04 |
+ }
|
|
|
e23cb04 |
+
|
|
|
e23cb04 |
+ return true;
|
|
|
e23cb04 |
+#else
|
|
|
e23cb04 |
+ // To get rid of warnings...
|
|
|
e23cb04 |
+ file_location = "";
|
|
|
e23cb04 |
+ return false;
|
|
|
e23cb04 |
+#endif
|
|
|
e23cb04 |
+}
|
|
|
e23cb04 |
+
|
|
|
e23cb04 |
// Find location of specified file
|
|
|
e23cb04 |
char*
|
|
|
e23cb04 |
find_file(const char *env_name, const char *file_name)
|
|
|
a7cfd51 |
@@ -1052,21 +1093,15 @@ find_file(const char *env_name, const char *file_name)
|
|
|
e23cb04 |
if (!config_source) {
|
|
|
e23cb04 |
// List of condor_config file locations we'll try to open.
|
|
|
e23cb04 |
// As soon as we find one, we'll stop looking.
|
|
|
e23cb04 |
- const int locations_length = 4;
|
|
|
e23cb04 |
+ const int locations_length = 3;
|
|
|
e23cb04 |
MyString locations[locations_length];
|
|
|
e23cb04 |
- // 1) $HOME/.condor/condor_config
|
|
|
e23cb04 |
- struct passwd *pw = getpwuid( geteuid() );
|
|
|
e23cb04 |
- if ( !can_switch_ids() && pw && pw->pw_dir ) {
|
|
|
da2fd33 |
- formatstr( locations[0], "%s/.%s/%s", pw->pw_dir, myDistro->Get(),
|
|
|
e23cb04 |
- file_name );
|
|
|
e23cb04 |
- }
|
|
|
e23cb04 |
// 2) /etc/condor/condor_config
|
|
|
da2fd33 |
- locations[1].formatstr( "/etc/%s/%s", myDistro->Get(), file_name );
|
|
|
da2fd33 |
+ locations[0].formatstr( "/etc/%s/%s", myDistro->Get(), file_name );
|
|
|
e23cb04 |
// 3) /usr/local/etc/condor_config (FreeBSD)
|
|
|
da2fd33 |
- locations[2].formatstr( "/usr/local/etc/%s", file_name );
|
|
|
da2fd33 |
+ locations[1].formatstr( "/usr/local/etc/%s", file_name );
|
|
|
e23cb04 |
if (tilde) {
|
|
|
e23cb04 |
// 4) ~condor/condor_config
|
|
|
da2fd33 |
- locations[3].formatstr( "%s/%s", tilde, file_name );
|
|
|
da2fd33 |
+ locations[2].formatstr( "%s/%s", tilde, file_name );
|
|
|
e23cb04 |
}
|
|
|
e23cb04 |
|
|
|
e23cb04 |
int ctr;
|
|
|
e23cb04 |
--
|
|
|
e23cb04 |
1.7.4.1
|
|
|
e23cb04 |
|