コード例 #1
0
ファイル: watchdog.c プロジェクト: CHINA-JD/prestogres
int
wd_chk_setuid(void)
{
	char path[128];
	char cmd[128];
	
	/* check setuid bit of ifup command */
	wd_get_cmd(cmd, pool_config->if_up_cmd);
	snprintf(path, sizeof(path), "%s/%s", pool_config->ifconfig_path, cmd);
	if (! has_setuid_bit(path))
	{
		ereport(NOTICE,
			(errmsg("checking setuid bit of ifup command"),
				 errdetail("ifup[%s] doesn't have setuid bit", path)));
		return 0;
	}

	/* check setuid bit of ifdown command */
	wd_get_cmd(cmd, pool_config->if_down_cmd);
	snprintf(path, sizeof(path), "%s/%s", pool_config->ifconfig_path, cmd);
	if (! has_setuid_bit(path))
	{
		ereport(NOTICE,
			(errmsg("checking setuid bit of ifdown command"),
				 errdetail("ifdown[%s] doesn't have setuid bit", path)));
		return 0;
	}

	/* check setuid bit of arping command */
	wd_get_cmd(cmd, pool_config->arping_cmd);
	snprintf(path, sizeof(path), "%s/%s", pool_config->arping_path, cmd);
	if (! has_setuid_bit(path))
	{
		ereport(NOTICE,
			(errmsg("checking setuid bit of arping command"),
				 errdetail("arping[%s] doesn't have setuid bit", path)));

		return 0;
	}
	ereport(NOTICE,
		(errmsg("checking setuid bit of required commands"),
			 errdetail("all commands have proper setuid bit")));
	return 1;
}
コード例 #2
0
ファイル: wd_if.c プロジェクト: codeforall/pgpool2
int
wd_IP_up(void)
{
	int rtn = WD_OK;
	char path[WD_MAX_PATH_LEN];
	char cmd[128];

	if (strlen(pool_config->delegate_IP) == 0)
		return WD_NG;

	if (WD_List->delegate_ip_flag == 0)
	{
		WD_List->delegate_ip_flag = 1;

		wd_get_cmd(cmd,pool_config->if_up_cmd);
		snprintf(path,sizeof(path),"%s/%s",pool_config->ifconfig_path,cmd);
		rtn = exec_ifconfig(path,pool_config->if_up_cmd);

		wd_get_cmd(cmd,pool_config->arping_cmd);
		snprintf(path,sizeof(path),"%s/%s",pool_config->arping_path,cmd);
		rtn = exec_ifconfig(path,pool_config->arping_cmd);
	}
	return rtn;
}
コード例 #3
0
ファイル: watchdog.c プロジェクト: aerfaman/pgpool2
int
wd_chk_setuid(void)
{
	char path[128];
	char cmd[128];
	
	/* check setuid bit of ifup command */
	wd_get_cmd(cmd, pool_config->if_up_cmd);
	snprintf(path, sizeof(path), "%s/%s", pool_config->ifconfig_path, cmd);
	if (! has_setuid_bit(path))
	{
		pool_log("wd_chk_setuid: ifup[%s] doesn't have setuid bit", path);
		return 0;
	}

	/* check setuid bit of ifdown command */
	wd_get_cmd(cmd, pool_config->if_down_cmd);
	snprintf(path, sizeof(path), "%s/%s", pool_config->ifconfig_path, cmd);
	if (! has_setuid_bit(path))
	{
		pool_log("wd_chk_setuid: ifdown[%s] doesn't have setuid bit", path);
		return 0;
	}

	/* check setuid bit of arping command */
	wd_get_cmd(cmd, pool_config->arping_cmd);
	snprintf(path, sizeof(path), "%s/%s", pool_config->arping_path, cmd);
	if (! has_setuid_bit(path))
	{
		pool_log("wd_chk_setuid: arping[%s] doesn't have setuid bit", path);
		return 0;
	}

	pool_log("wd_chk_setuid all commands have setuid bit");
	return 1;
}
コード例 #4
0
ファイル: wd_if.c プロジェクト: codeforall/pgpool2
int
wd_IP_down(void)
{
	int rtn = WD_OK;
	char path[WD_MAX_PATH_LEN];
	char cmd[128];
	int i;

	if (strlen(pool_config->delegate_IP) == 0)
		return WD_NG;

	if (WD_List->delegate_ip_flag == 1)
	{
		WD_List->delegate_ip_flag = 0;
		wd_get_cmd(cmd,pool_config->if_down_cmd);
		snprintf(path, sizeof(path), "%s/%s", pool_config->ifconfig_path, cmd);
		rtn = exec_ifconfig(path,pool_config->if_down_cmd);

		if (rtn == WD_OK)
		{
			for (i = 0; i < 3; i++)
			{
				if (wd_is_unused_ip(pool_config->delegate_IP))
					break;
			}

			if (i >= 3)
				rtn = WD_NG;
		}

		if (rtn == WD_OK)
			pool_log("wd_IP_down: ifconfig down succeeded");
		else
			pool_error("wd_IP_down: ifconfig down failed");
	}
	else
	{
		pool_debug("wd_IP_down: not delegate IP holder");
	}

	return rtn;
}