Example #1
0
void setup_keydir (struct environment *env, int flags)
{
    const char *dir = getenv ("FLUX_SEC_DIRECTORY");
    char *new_dir = NULL;

    if (!dir)
        dir = flux_conf_get ("keydir", flags);
    if (!dir) {
        struct passwd *pw = getpwuid (getuid ());
        if (!pw)
            log_msg_exit ("Who are you!?!");
        dir = new_dir = xasprintf ("%s/.flux", pw->pw_dir);
    }
    if (!dir)
        log_msg_exit ("Could not determine keydir");
    environment_set (env, "FLUX_SEC_DIRECTORY", dir, 0);
    if (new_dir)
        free (new_dir);
}
Example #2
0
void
script_process(char* script)
{
	// Split script in independent pipelines
	char* array[10];
	int numPipelines = gettokens(script, array, 10, ";");

	// run script commands
	int i;
	for(i = 0; i < numPipelines; ++i)
	{
		// expand environment variables and substitute command line char pointer
		// with the one with expanded environment variables (if necesary)
//		char* expanded = expand_envVars(array[i]);
//		if(expanded) array[i] = expanded;
		array[i] = environment_expand(array[i]);

		// move commands to background (if necesary)
		background(array[i]);

		// Exec `cd` (it's a built-in, but must change shell environment itself,
		// so we check and exec for it directly here)
		if(builtin_cd(array[i]))
		{
			free(array[i]);
			continue;
		}

		// Set environment variable
		if(environment_set(array[i]))
		{
			free(array[i]);
			continue;
		}

		// run foreground command
		pipeline_process(array[i]);

		// free line created by environment variables expansion
		free(array[i]);
	}
}