24
24
// once as part of the Full_Path and again as just the name
26
26
#include <unistd.h>
30
#ifdef HAVE_SYS_PARAM_H
30
31
#include <sys/param.h> // for MAXPATHLEN
31
33
#include <pwd.h> // getpwuid
34
40
int main(int argc, char** argv) {
37
char user_name[256], group_name[256];
43
char user_name[256], group_name[256];
39
51
strcpy(user_name, "boinc_project");
40
52
strcpy(group_name, "boinc_project");
70
82
pw = getpwnam(user_name);
71
83
if (pw) setuid(pw->pw_uid);
85
// For unknown reasons, the LD_LIBRARY_PATH and DYLD_LIBRARY_PATH
86
// environment variables are not passed in to switcher, though all
87
// other environment variables do get propagated. So we recreate
88
// LD_LIBRARY_PATH and DYLD_LIBRARY_PATH here.
89
f = fopen(INIT_DATA_FILE, "r");
91
retval = parse_init_data_file(f, aid);
96
// Get project name without leading path
97
projectDirName = strrchr(aid.project_dir, '/');
101
projectDirName = aid.project_dir;
103
sprintf(newlibs, "../../%s:.:../..", projectDirName);
105
strcat(newlibs, ":/usr/local/cuda/lib/");
107
char* p = getenv("LD_LIBRARY_PATH");
109
sprintf(libpath, "%s:%s", newlibs, p);
111
strcpy(libpath, newlibs);
113
setenv("LD_LIBRARY_PATH", libpath, 1);
115
// On the Mac, do the same for DYLD_LIBRARY_PATH
118
p = getenv("DYLD_LIBRARY_PATH");
120
sprintf(libpath, "%s:%s", newlibs, p);
122
strcpy(libpath, newlibs);
124
setenv("DYLD_LIBRARY_PATH", libpath, 1);
73
128
execv(argv[1], argv+2);
75
130
// If we got here execv failed