static void _intercept_init(void) { char exename[MAXPATHLEN]; char omitfile[MAXPATHLEN]; FILE *fp; LOG(4, "beginning of _intercept_init()\n"); /* * Is this process on the list of applications to ignore? Note that * programs listed in /etc/libsafe.exclude must be specified as absolute * pathnames. */ get_exename(exename, MAXPATHLEN); if ((fp=fopen("/etc/libsafe.exclude", "r")) != NULL) { while (fgets(omitfile, sizeof(omitfile), fp)) { omitfile[strnlen(omitfile, sizeof(omitfile)) - 1] = (char)NULL; if (!strncmp(omitfile, exename, sizeof(omitfile))) { _libsafe_exclude = 1; } /* * Is this process being run as a privileged process? If so, and * the LIBSAFE_PROTECT_ROOT is set, then only protect privileged * processes. By protecting only privileged processes, overall * system performance can be improved. */ if (!strncmp(omitfile, "LIBSAFE_PROTECT_ROOT", sizeof(omitfile))) { if (geteuid() >= 100) _libsafe_exclude = 1; } } fclose(fp); } }
void parse_opts(int *argcp, char ***argvp) { static char* shortopts = "+H:T:bhJ:"; static struct option longopts[] = { { "home", required_argument, 0, 'H' }, { "tab", required_argument, 0, 'T' }, { "bare", no_argument, 0, 'b' }, { "lisp", no_argument, &lisp_prompt, 1 }, { "help", no_argument, 0, 'h' }, { "sysimage", required_argument, 0, 'J' }, { 0, 0, 0, 0 } }; int c; opterr = 0; int ind = 1; while ((c = getopt_long(*argcp,*argvp,shortopts,longopts,0)) != -1) { switch (c) { case 0: break; case '?': break; case 'H': julia_home = strdup(optarg); ind+=2; break; case 'T': // TODO: more robust error checking. tab_width = atoi(optarg); ind+=2; break; case 'b': image_file = NULL; ind+=1; break; case 'J': image_file = optarg; ind+=2; break; case 'h': printf("%s%s", usage, opts); exit(0); default: ios_printf(ios_stderr, "julia: unhandled option -- %c\n", c); ios_printf(ios_stderr, "This is a bug, please report it.\n"); exit(1); } } if (!julia_home) { julia_home = getenv("JULIA_HOME"); if (julia_home) { julia_home = strdup(julia_home); } else { char *julia_path = (char*)malloc(PATH_MAX); get_exename(julia_path, PATH_MAX); julia_home = strdup(dirname(julia_path)); free(julia_path); } } *argvp += ind; *argcp -= ind; if (image_file==NULL && *argcp > 0) { if (strcmp((*argvp)[0], "-")) { program = (*argvp)[0]; } } }
void parse_opts(int *argcp, char ***argvp) { static char* shortopts = "+H:T:bhJ:"; static struct option longopts[] = { { "home", required_argument, 0, 'H' }, { "tab", required_argument, 0, 'T' }, { "bare", no_argument, 0, 'b' }, { "lisp", no_argument, &lisp_prompt, 1 }, { "help", no_argument, 0, 'h' }, { "sysimage", required_argument, 0, 'J' }, { 0, 0, 0, 0 } }; int c; opterr = 0; int ind = 1; #ifdef JL_SYSTEM_IMAGE_PATH int imagepathspecified=0; #endif while ((c = getopt_long(*argcp,*argvp,shortopts,longopts,0)) != -1) { switch (c) { case 0: break; case '?': break; case 'H': julia_home = strdup(optarg); ind+=2; break; case 'T': // TODO: more robust error checking. tab_width = atoi(optarg); ind+=2; break; case 'b': image_file = NULL; ind+=1; break; case 'J': image_file = optarg; #ifdef JL_SYSTEM_IMAGE_PATH imagepathspecified = 1; #endif ind+=2; break; case 'h': printf("%s%s", usage, opts); exit(0); default: ios_printf(ios_stderr, "julia: unhandled option -- %c\n", c); ios_printf(ios_stderr, "This is a bug, please report it.\n"); exit(1); } } if (!julia_home) { julia_home = getenv("JULIA_HOME"); if (julia_home) { julia_home = strdup(julia_home); } else { char *julia_path = (char*)malloc(PATH_MAX); get_exename(julia_path, PATH_MAX); julia_home = strdup(dirname(julia_path)); free(julia_path); } } *argvp += ind; *argcp -= ind; if (image_file==NULL && *argcp > 0) { if (strcmp((*argvp)[0], "-")) { program = (*argvp)[0]; } } if (image_file) { int build_time_path = 0; #ifdef JL_SYSTEM_IMAGE_PATH if (!imagepathspecified) { image_file = JL_SYSTEM_IMAGE_PATH; build_time_path = 1; } #endif if (image_file[0] != PATHSEP) { struct stat stbuf; char path[512]; if (build_time_path) { // build time path relative to JULIA_HOME snprintf(path, sizeof(path), "%s%s%s", julia_home, PATHSEPSTRING, JL_SYSTEM_IMAGE_PATH); image_file = strdup(path); } else if (jl_stat(image_file, (char*)&stbuf) != 0) { // otherwise try julia_home/../lib/julia/%s snprintf(path, sizeof(path), "%s%s..%slib%sjulia%s%s", julia_home, PATHSEPSTRING, PATHSEPSTRING, PATHSEPSTRING, PATHSEPSTRING, image_file); image_file = strdup(path); } } } }