当前位置: 首页>>代码示例>>C++>>正文


C++ run_script函数代码示例

本文整理汇总了C++中run_script函数的典型用法代码示例。如果您正苦于以下问题:C++ run_script函数的具体用法?C++ run_script怎么用?C++ run_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了run_script函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run_net_script

int run_net_script(envid_t veid, int op, list_head_t *ip_h, int state,
	int skip_arpdetect)
{
	char *argv[3];
	char *envp[10];
	char *script;
	int ret;
	char buf[STR_SIZE];
	int i = 0;
	char *skip_str = "SKIP_ARPDETECT=yes";

	if (list_empty(ip_h))
		return 0;
	snprintf(buf, sizeof(buf), "VEID=%d", veid);
	envp[i++] = strdup(buf);
	snprintf(buf, sizeof(buf), "VE_STATE=%s", state2str(state));
	envp[i++] = strdup(buf);
	envp[i++] = list2str("IP_ADDR", ip_h);
	envp[i++] = strdup(ENV_PATH);
	if (skip_arpdetect)
		envp[i++] = strdup(skip_str);
	envp[i] = NULL;
	switch (op) {
		case ADD:
			script = VPS_NET_ADD;
			break;
		case DEL:
			script = VPS_NET_DEL;
			break;
		default:
			return 0;
	}
	argv[0] = script;
	argv[1] = NULL;
	ret = run_script(script, argv, envp, 0);
	free_arg(envp);

	return ret;
}
开发者ID:avagin,项目名称:vzctl,代码行数:39,代码来源:net.c

示例2: ASSERT

bool
GLExecPrivSepHelper::chown_sandbox_to_user(PrivSepError &err)
{
	ASSERT(m_initialized);

	if (m_sandbox_owned_by_user) {
		dprintf(D_FULLDEBUG,
		        "GLExecPrivSepHelper::chown_sandbox_to_user: "
		            "sandbox already user-owned\n");
		return true;
	}

	dprintf(D_FULLDEBUG, "changing sandbox ownership to the user\n");

	ArgList args;
	args.AppendArg(m_setup_script);
	args.AppendArg(m_glexec);
	args.AppendArg(m_proxy);
	args.AppendArg(m_sandbox);
	args.AppendArg(m_glexec_retries);
	args.AppendArg(m_glexec_retry_delay);
	MyString error_desc = "error changing sandbox ownership to the user: ";
	int rc = run_script(args,error_desc);
	if( rc != 0) {
		int hold_code = CONDOR_HOLD_CODE_GlexecChownSandboxToUser;
		if( rc != INVALID_PROXY_RC && !param_boolean("GLEXEC_HOLD_ON_INITIAL_FAILURE",true) ) {
			// Do not put the job on hold due to glexec failure.
			// It will simply return to idle status and try again.
			hold_code = 0;
		}

		err.setHoldInfo( hold_code, rc, error_desc.Value());
		return false;
	}

	m_sandbox_owned_by_user = true;
	return true;
}
开发者ID:AlainRoy,项目名称:htcondor,代码行数:38,代码来源:glexec_privsep_helper.linux.cpp

示例3: main

int
main(int argc, char** argv, char** env) 
{
	int status;
	char* fake_argv[3];

	running_as_cgi = 1;
	check_caller(logident, parentgid);

	/* for these CGI programs, we can ignore argc and argv since they
	 * don't contain anything useful.  `script' will always be the driver
	 * program and argv will always just contain the name of the real
	 * script for the driver to import and execute (padded with two dummy
	 * values in argv[0] and argv[1] that are ignored by run_script().
	 */
	fake_argv[0] = NULL;
	fake_argv[1] = NULL;
	fake_argv[2] = script;

	status = run_script("driver", 3, fake_argv, env);
	fatal(logident, status, "%s", strerror(errno));
	return status;
}
开发者ID:OS2World,项目名称:APP-SERVER-MailMan,代码行数:23,代码来源:cgi-wrapper.c

示例4: start

int start (int argc, char **argv)
{
	int rc;
	PyObject *new_path;
	PySys_SetArgv(argc, argv);
	// PySys_SetArgv munged the path - specifically, it added the
	// directory of argv[0] at the start of sys.path.
	// Create a new list object for the path, and rely on our
	// implementation knowledge of set_path above, which writes into
	// the static Py_GetPath() buffer (Note: Py_GetPath() does *not*
	// return the current sys.path value - its just a static buffer
	// holding the initial Python paths)
	new_path = PyList_New(1);
	if (new_path) {
		PyObject *entry = PyString_FromString(Py_GetPath());
		if (entry && (0==PyList_SetItem(new_path, 0, entry)))
			PySys_SetObject("path", new_path);
		Py_DECREF(new_path);
	}
	rc = run_script();
	fini();
	return rc;
}
开发者ID:AlexUlrich,项目名称:digsby,代码行数:23,代码来源:start.c

示例5: context_scope

	bool PreludeScript::run()
	{
		v8::Context::Scope context_scope(get_context());
		global_template_factory.Dispose();
		global_template_factory.Clear();
		//TODO: check whether proper type of value returned
		v8::Handle<v8::Value> prelude_result = run_script(get_context());
		if (prelude_result.IsEmpty())
		{
			set_last_error(v8::String::New("Prelude script did not return any value"));
			return false;
		}
		if (prelude_result->IsFunction()) 
		{
			global_template_factory = v8::Persistent<v8::Function>::New(prelude_result.As<v8::Function>());
			return true;
		}
		else 
		{
			set_last_error(v8::String::New("Prelude script must return a function"));
			return false;
		}
	}
开发者ID:trbngr,项目名称:EventStore,代码行数:23,代码来源:PreludeScript.cpp

示例6: perform_release

/* perform a release */
static void perform_release(void)
{
	char buffer[16];
	struct in_addr temp_addr;

	/* send release packet */
#if !defined(TCSUPPORT_CT) 
	if (state == BOUND || state == RENEWING || state == REBINDING || state == REQUESTING || state == RENEW_REQUESTED) {
#endif
		temp_addr.s_addr = server_addr;
		sprintf(buffer, "%s", inet_ntoa(temp_addr));
		temp_addr.s_addr = requested_ip;
		LOG(LOG_INFO, "Unicasting a release of %s to %s",
				inet_ntoa(temp_addr), buffer);
		send_release(server_addr, requested_ip); /* unicast */
		run_script(NULL, "deconfig");
	}
	LOG(LOG_INFO, "Entering released state");

	change_mode(LISTEN_NONE);
	state = RELEASED;
	timeout = 0x7fffffff;
}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:24,代码来源:dhcpc.c

示例7: run_and_remove_extendedcommand

int run_and_remove_extendedcommand()
{
    char tmp[PATH_MAX];
    sprintf(tmp, "cp %s /tmp/%s", EXTENDEDCOMMAND_SCRIPT, basename(EXTENDEDCOMMAND_SCRIPT));
    __system(tmp);
    remove(EXTENDEDCOMMAND_SCRIPT);
    int i = 0;
    for (i = 20; i > 0; i--) {
        ui_print("Waiting for SD Card to mount (%ds)\n", i);
        if (ensure_path_mounted("/sdcard") == 0) {
            ui_print("SD Card mounted...\n");
            break;
        }
        sleep(1);
    }
    remove("/sdcard/clockworkmod/.recoverycheckpoint");
    if (i == 0) {
        ui_print("Timed out waiting for SD card... continuing anyways.");
    }

    sprintf(tmp, "/tmp/%s", basename(EXTENDEDCOMMAND_SCRIPT));
    return run_script(tmp);
}
开发者ID:Savaged-Zen,项目名称:android_bootable_recovery,代码行数:23,代码来源:extendedcommands.c

示例8: maybe_make_dhfile

static int maybe_make_dhfile(struct conf *conf, const char *ca_dir)
{
	int a=0;
	const char *args[12];
	char *path=NULL;
	struct stat statp;
	if(!lstat(conf->ssl_dhfile, &statp))
	{
		free(path);
		return 0;
	}

	setup_stuff_done++;

	logp("Creating %s\n", conf->ssl_dhfile);
	logp("Running '%s --dhfile %s --dir %s'\n",
		conf->ca_burp_ca, conf->ssl_dhfile, ca_dir);
	a=0;
	args[a++]=conf->ca_burp_ca;
	args[a++]="--dhfile";
	args[a++]=conf->ssl_dhfile;
	args[a++]="--dir";
	args[a++]=ca_dir;
	args[a++]=NULL;
	if(run_script(NULL /* no async yet */, args, NULL, conf, 1 /* wait */,
		0, 0 /* do not use logp - stupid openssl prints lots of dots
		        one at a time with no way to turn it off */))
	{
		logp("Error running %s\n", conf->ca_burp_ca);
		free(path);
		return -1;
	}

	free(path);
	return 0;
}
开发者ID:Kalimeiro,项目名称:burp,代码行数:36,代码来源:ca.c

示例9: main

int main(int argc, char *argv[])
{
    atexit(x);

    if (argc != 2) {
        fprintf(stderr, "Usage: %s {test-script}\n", argv[0]);
        return EXIT_FAILURE;
    }

    FILE *script = fopen(argv[1], "r");
    if (!script) {
        fprintf(stderr, "Failed loading script file: %s\n", argv[1]);
        return EXIT_FAILURE;
    }

    if (!run_script(script)) {
        fprintf(stderr, "Failed running test script\n");
        fclose(script);
        return EXIT_FAILURE;
    }

    fclose(script);
    return EXIT_SUCCESS;
}
开发者ID:k-stachowiak,项目名称:moon-lang,代码行数:24,代码来源:test.c

示例10: run_timer_script

static int run_timer_script(
	struct asfd *asfd,
	const char *timer_script,
	const char *cname,
	struct sdirs *sdirs,
	struct strlist *timer_args,
	struct conf **cconfs)
{
	int a=0;
	const char *args[12];
	args[a++]=timer_script;
	args[a++]=cname;
	args[a++]=sdirs->current;
	args[a++]=sdirs->clients;
	args[a++]="reserved1";
	args[a++]="reserved2";
	args[a++]=NULL;
	return run_script(asfd, args,
		timer_args,
		cconfs,
		1 /* wait */,
		1 /* use logp */,
		0 /* no log_remote */);
}
开发者ID:pablodav,项目名称:burp,代码行数:24,代码来源:timer.c

示例11: gui_parse_text


//.........这里部分代码省略.........
				sprintf(cmd, "dd %s", arg.c_str());
				__system(cmd);
			}
            operation_end(0, simulate);
            return 0;
        }
		if (function == "partitionsd")
		{
			operation_start("Partition SD Card");

			if (simulate) {
				simulate_progress_bar();
			} else {
				int allow_partition;
				DataManager::GetValue(TW_ALLOW_PARTITION_SDCARD, allow_partition);
				if (allow_partition == 0) {
					ui_print("This device does not have a real SD Card!\nAborting!\n");
				} else {
					// Below seen in Koush's recovery
					char sddevice[256];
					Volume *vol = volume_for_path("/sdcard");
					strcpy(sddevice, vol->device);
					// Just need block not whole partition
					sddevice[strlen("/dev/block/mmcblkX")] = NULL;

					char es[64];
					std::string ext_format;
					int ext, swap;
					DataManager::GetValue("tw_sdext_size", ext);
					DataManager::GetValue("tw_swap_size", swap);
					DataManager::GetValue("tw_sdpart_file_system", ext_format);
					sprintf(es, "/sbin/sdparted -es %dM -ss %dM -efs %s -s > /cache/part.log",ext,swap,ext_format.c_str());
					LOGI("\nrunning script: %s\n", es);
					run_script("\nContinue partitioning?",
						   "\nPartitioning sdcard : ",
						   es,
						   "\nunable to execute parted!\n(%s)\n",
						   "\nOops... something went wrong!\nPlease check the recovery log!\n",
						   "\nPartitioning complete!\n\n",
						   "\nPartitioning aborted!\n\n", 0);
					
					// recreate TWRP folder and rewrite settings - these will be gone after sdcard is partitioned
					ensure_path_mounted(SDCARD_ROOT);
					mkdir("/sdcard/TWRP", 0777);
					DataManager::Flush();
					DataManager::SetValue(TW_ZIP_EXTERNAL_VAR, "/sdcard");
					if (DataManager::GetIntValue(TW_USE_EXTERNAL_STORAGE) == 1)
						DataManager::SetValue(TW_ZIP_LOCATION_VAR, "/sdcard");

					update_system_details();
				}
			}
			operation_end(0, simulate);
			return 0;
		}
		if (function == "installhtcdumlock")
		{
			operation_start("Install HTC Dumlock");
			if (simulate) {
				simulate_progress_bar();
			} else
				install_htc_dumlock();

			operation_end(0, simulate);
			return 0;
		}
开发者ID:Borkata,项目名称:linux,代码行数:67,代码来源:action.cpp

示例12: main

int
main(void)
{
    struct script_config config;
    struct kerberos_config *krbconf;
    char *user;

    /*
     * Load the Kerberos principal and password from a file, but set the
     * principal as extra[0] and use something else bogus as the user.  We
     * want to test that alt_auth_map works when there's no relationship
     * between the mapped principal and the user.
     */
    krbconf = kerberos_setup(TAP_KRB_NEEDS_PASSWORD);
    memset(&config, 0, sizeof(config));
    config.user = "bogus-nonexistent-account";
    config.authtok = krbconf->password;
    config.extra[0] = krbconf->username;
    config.extra[1] = krbconf->userprinc;

    /*
     * Generate a testing krb5.conf file with a nonexistent default realm so
     * that we can be sure that our principals will stay fully-qualified in
     * the logs.
     */
    kerberos_generate_conf("bogus.example.com");
    config.extra[2] = "bogus.example.com";

    /* Test without password prompting. */
    plan_lazy();
    run_script("data/scripts/alt-auth/basic", &config);
    run_script("data/scripts/alt-auth/basic-debug", &config);
    run_script("data/scripts/alt-auth/fail", &config);
    run_script("data/scripts/alt-auth/fail-debug", &config);
    run_script("data/scripts/alt-auth/force", &config);
    run_script("data/scripts/alt-auth/only", &config);

    /*
     * If the alternate account exists but the password is incorrect, we
     * should not fall back to the regular account.  Test with debug so that
     * we don't need two principals configured.
     */
    config.authtok = "bogus incorrect password";
    run_script("data/scripts/alt-auth/force-fail-debug", &config);

    /*
     * Switch to our correct user (but wrong realm) realm to test username
     * mapping to a different realm.
     */
    config.authtok = krbconf->password;
    config.user = krbconf->username;
    config.extra[2] = krbconf->realm;
    run_script("data/scripts/alt-auth/username-map", &config);

    /*
     * Split the username into two parts, one in the PAM configuration and one
     * in the real username, so that we can test interpolation of the username
     * when %s isn't the first token.
     */
    config.user = &krbconf->username[1];
    user = bstrndup(krbconf->username, 1);
    config.extra[3] = user;
    run_script("data/scripts/alt-auth/username-map-prefix", &config);
    free(user);
    config.extra[3] = NULL;

    /*
     * Ensure that we don't add the realm of the authentication username when
     * the alt_auth_map already includes a realm.
     */
    basprintf(&user, "%[email protected]", krbconf->username);
    config.user = user;
    diag("re-running username-map with fully-qualified PAM user");
    run_script("data/scripts/alt-auth/username-map", &config);
    free(user);
    config.user = krbconf->username;

    /*
     * Add the password and make the user match our authentication principal,
     * and then test fallback to normal authentication when alternative
     * authentication fails.
     */
    config.user = krbconf->userprinc;
    config.password = krbconf->password;
    config.extra[2] = krbconf->realm;
    run_script("data/scripts/alt-auth/fallback", &config);
    run_script("data/scripts/alt-auth/fallback-debug", &config);
    run_script("data/scripts/alt-auth/fallback-realm", &config);
    run_script("data/scripts/alt-auth/force-fallback", &config);
    run_script("data/scripts/alt-auth/only-fail", &config);

    return 0;
}
开发者ID:HenryJacques,项目名称:pam-krb5,代码行数:93,代码来源:alt-auth-t.c

示例13: main


//.........这里部分代码省略.........
			printf("udhcpcd, version %s\n\n", VERSION);
			exit_client(0);
			break;
		default:
			show_usage();
		}
	}

	OPEN_LOG("udhcpc");
	LOG(LOG_INFO, "udhcp client (v%s) started", VERSION);

	pid_fd = pidfile_acquire(client_config.pidfile);
	pidfile_write_release(pid_fd);

	if (read_interface(client_config.interface, &client_config.ifindex, 
			   NULL, client_config.arp) < 0)
		exit_client(1);
		
	if (!client_config.clientid) {
		client_config.clientid = xmalloc(6 + 3);
		client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
		client_config.clientid[OPT_LEN] = 7;
		client_config.clientid[OPT_DATA] = 1;
		memcpy(client_config.clientid + 3, client_config.arp, 6);
	}

	/* setup signal handlers */
	socketpair(AF_UNIX, SOCK_STREAM, 0, signal_pipe);
	signal(SIGUSR1, signal_handler);
	signal(SIGUSR2, signal_handler);
	signal(SIGTERM, signal_handler);
	
	state = INIT_SELECTING;
	run_script(NULL, "deconfig");
	change_mode(LISTEN_RAW);

	for (;;) {

		tv.tv_sec = timeout - time(0);
		tv.tv_usec = 0;
		FD_ZERO(&rfds);

		if (listen_mode != LISTEN_NONE && fd < 0) {
			if (listen_mode == LISTEN_KERNEL)
				fd = listen_socket(INADDR_ANY, CLIENT_PORT, client_config.interface);
			else
				fd = raw_socket(client_config.ifindex);
			if (fd < 0) {
				LOG(LOG_ERR, "FATAL: couldn't listen on socket, %s", strerror(errno));
				exit_client(0);
			}
		}
		if (fd >= 0) FD_SET(fd, &rfds);
		FD_SET(signal_pipe[0], &rfds);		

		if (tv.tv_sec > 0) {
			DEBUG(LOG_INFO, "Waiting on select...\n");
			max_fd = signal_pipe[0] > fd ? signal_pipe[0] : fd;
			retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
		} else retval = 0; /* If we already timed out, fall through */

		now = time(0);
		if (retval == 0) {
			/* timeout dropped to zero */
			switch (state) {
			case INIT_SELECTING:
开发者ID:foxwolf,项目名称:yjd,代码行数:67,代码来源:dhcpc.c

示例14: main

int
main(void)
{
    struct script_config config;
    struct kerberos_password *password;
    DIR *tmpdir;
    struct dirent *file;
    char *tmppath, *path;

    /* Load the Kerberos principal and password from a file. */
    password = kerberos_config_password();
    if (password == NULL)
        skip_all("Kerberos tests not configured");
    memset(&config, 0, sizeof(config));
    config.user = password->username;
    config.password = password->password;
    config.extra[0] = password->principal;

    /* Generate a testing krb5.conf file. */
    kerberos_generate_conf(password->realm);

    /* Get the temporary directory and store that as the %1 substitution. */
    tmppath = test_tmpdir();
    config.extra[1] = tmppath;

    plan_lazy();

    /*
     * We need to ensure that the only thing in the test temporary directory
     * is the krb5.conf file that we generated, since we're going to check for
     * cleanup by looking for any out-of-place files.
     */
    tmpdir = opendir(tmppath);
    if (tmpdir == NULL)
        sysbail("cannot open directory %s", tmppath);
    while ((file = readdir(tmpdir)) != NULL) {
        if (strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0)
            continue;
        if (strcmp(file->d_name, "krb5.conf") == 0)
            continue;
        basprintf(&path, "%s/%s", tmppath, file->d_name);
        if (unlink(path) < 0)
            sysbail("cannot delete temporary file %s", path);
        free(path);
    }
    closedir(tmpdir);

    /*
     * Authenticate only, call pam_end, and be sure the ticket cache is
     * gone.  The auth-only script sets ccache_dir to the temporary directory,
     * so the module will create a temporary ticket cache there and then
     * should clean it up.
     */
    run_script("data/scripts/cache-cleanup/auth-only", &config);
    path = NULL;
    tmpdir = opendir(tmppath);
    if (tmpdir == NULL)
        sysbail("cannot open directory %s", tmppath);
    while ((file = readdir(tmpdir)) != NULL) {
        if (strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0)
            continue;
        if (strcmp(file->d_name, "krb5.conf") == 0)
            continue;
        if (path == NULL)
            basprintf(&path, "%s/%s", tmppath, file->d_name);
    }
    closedir(tmpdir);
    if (path != NULL)
        diag("found stray temporary file %s", path);
    ok(path == NULL, "ticket cache cleaned up");
    if (path != NULL)
        free(path);

    test_tmpdir_free(tmppath);
    kerberos_config_password_free(password);
    return 0;
}
开发者ID:irush-cs,项目名称:pam-krb5,代码行数:77,代码来源:cache-cleanup-t.c

示例15: check_pipe

void check_pipe(char *pipe_name) {
    fd_set fdset;
    struct timeval timeout = {0, 10};
    int i;
    int fd;

    FD_ZERO(&fdset);

    if (f == NULL) {
        /* blocks
              f = fopen(pipe_name,"r");
        */
        fd = open(pipe_name, O_RDONLY | O_NONBLOCK);
        f = fdopen(fd,"r");
        if(f == NULL) {
            perror(pipe_name);
            return;
        }
    }

    for(;;) {
        if(f != NULL) FD_SET(fileno(f), &fdset);
        switch(select(FD_SETSIZE, &fdset, NULL, NULL, &timeout)) {

        case -1:
            if(errno != EINTR) {
                perror("select");
                exit(1);
            }
            return;

        case 0:
            /* printf("timeout\n"); */
            return;

        default:
            if(f != NULL && FD_ISSET(fileno(f),&fdset)) {
                char line[1024];

                if(fgets(line,sizeof(line),f) == NULL) {
                    struct stat s;
                    /* EOF reached, if f was a pipe, reopen it */
                    /* printf("EOF, reopening pipe"); */
                    /* f = fopen(pipe_name,"r"); */
                    /* printf("EOF, %s\n",pipe_name); */
                    fclose(f);
                    f = NULL;
                    return;
                    /* always re-open on call to check_pipe
                                  if(stat(pipe_name,&s) == -1) {
                                    perror(pipe_name);
                                    exit(1);
                                  }

                                  if(S_ISFIFO(s.st_mode)) {
                                    printf("pipe, %s\n",pipe_name);
                                    f = fopen(pipe_name,"r");
                                  }
                    */
                }
                else {
                    int index;
                    int len = strlen(line);
                    /* len = strlen(line); */
                    if (len > 0) line[len-1] = 0;
                    /* WLH 6 Nov 98
                                  printf("%s: %s\n",pipe_name,line);
                    */
                    get_current_display(&index);
                    run_script(index, line);
                }
            }
            else {
                /* printf("select default not FD_ISSET, %s\n",pipe_name); */
                return;
            }
        } /* end switch(select(FD_SETSIZE,&fdset,NULL,NULL,&timeout)) */
    } /* end for (;;) */
}
开发者ID:pseudotensor,项目名称:Vis5dPlus,代码行数:79,代码来源:pipe.c


注:本文中的run_script函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。