Exemple #1
0
/* Returns POSIX OK(0) on success, non-zero on validation failure. */
static int validate_configuration(ddns_t *ctx)
{
	int i, num = 0;

	if (!ctx->info_count) {
		logit(LOG_ERR, "No DDNS provider setup in configuration.");
		return 1;
	}

	for (i = 0; i < ctx->info_count; i++) {
		int ok = 1;
		ddns_info_t *account = &ctx->info[i];

		check_setting(strlen(account->creds.username), i, "Missing username", &ok);
		check_setting(strlen(account->creds.password), i, "Missing password", &ok);
		check_setting(account->alias_count, i, "Missing your alias/hostname", &ok);
		check_setting(strlen(account->dyndns_server_name.name), i,
			      "Missing DDNS server address, check DDNS provider", &ok);
		check_setting(strlen(account->ip_server_name.name), i,
			      "Missing check IP address, check DDNS provider", &ok);

		if (ok)
			num++;
	}

	if (!num) {
		logit(LOG_ERR, "No valid DDNS setup exists.");
		return 1;
	}

	if (num != ctx->info_count)
		logit(LOG_WARNING, "Not all account setups are valid, please check configuration.");

	return 0;
}
Exemple #2
0
/* Returns POSIX OK(0) on success, non-zero on validation failure. */
static int validate_configuration(ddns_t *ctx)
{
	int i, num = 0;

	if (!ctx->info_count) {
		logit(LOG_ERR, "No DDNS provider setup in configuration.");
		return RC_DYNDNS_INVALID_OR_MISSING_PARAMETERS;
	}

	for (i = 0; i < ctx->info_count; i++) {
		int ok = 1;
		ddns_info_t *account = &ctx->info[i];

		/* username, password not required for custom setups */
		if (strncmp(account->system->name, "custom@", 7)) {
			check_setting(strlen(account->creds.username), i, "Missing username", &ok);
//			check_setting(strlen(account->creds.password), i, "Missing password", &ok);
		}
		check_setting(account->alias_count, i, "Missing your alias/hostname", &ok);
		check_setting(strlen(account->server_name.name), i,
			      "Missing DDNS server address, check DDNS provider", &ok);
		check_setting(strlen(account->checkip_name.name), i,
			      "Missing check IP address, check DDNS provider", &ok);

		if (ok)
			num++;
	}

	if (!num) {
		logit(LOG_ERR, "No valid DDNS setup exists.");
		return RC_DYNDNS_INVALID_OR_MISSING_PARAMETERS;
	}

	if (num != ctx->info_count)
		logit(LOG_WARNING, "Not all account setups are valid, please check configuration.");

	return 0;
}