public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Bernhard Bitsch <bbitsch@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH] ddns.cgi: Fix sanity check logic.
Date: Wed, 07 Jul 2021 21:37:50 +0200	[thread overview]
Message-ID: <e5b6b047-b6fa-75d5-6021-e85803d10884@ipfire.org> (raw)
In-Reply-To: <20210706160829.2548-1-stefan.schantl@ipfire.org>

[-- Attachment #1: Type: text/plain, Size: 2454 bytes --]

Tested-by: Bernhard Bitsch <bbitsch(a)ipfire.org>

Am 06.07.2021 um 18:08 schrieb Stefan Schantl:
> The input validation did not work in the proper way. It allways
> reported "No password" when using a provider which supports token and
> the token has been given.
> 
> This of course is wrong and leaded to unuseable providers.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
> ---
>   html/cgi-bin/ddns.cgi | 32 ++++++++++++++++++++------------
>   1 file changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/html/cgi-bin/ddns.cgi b/html/cgi-bin/ddns.cgi
> index e30aa3d4f..0e3ccbe45 100644
> --- a/html/cgi-bin/ddns.cgi
> +++ b/html/cgi-bin/ddns.cgi
> @@ -171,20 +171,28 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::
>   		$errormessage = $Lang::tr{'invalid domain name'};
>   	}
>   
> -	# Check if a username has been sent.
> -	if ($settings{'LOGIN'} eq '') {
> -		$errormessage = $Lang::tr{'username not set'};
> -	}
> +	# Check if the choosen provider supports token based authentication.
> +	if ($settings{'SERVICE'} ~~ @token_provider) {
> +		# Check if a token has been given.
> +		unless ($settings{'TOKEN'}) {
> +			$errormessage = $Lang::tr{'token not set'};
> +		}
>   
> -	# Check if a password has been typed in.
> -	# freedns.afraid.org does not require this field.
> -	if (($settings{'PASSWORD'} eq '') && ($settings{'SERVICE'} ne 'freedns.afraid.org') && ($settings{'SERVICE'} ne 'regfish.com')) {
> -		$errormessage = $Lang::tr{'password not set'};
> -	}
> +		# Automatically set the username to token.
> +		$settings{'LOGIN'} = "token";
>   
> -	# Check if a token has been given for provider which support tokens.
> -	if (($settings{'SERVICE'} ~~ @token_provider) && ($settings{'TOKEN'} eq '')) {
> -		$errormessage = $Lang::tr{'token not set'};
> +	# A provider without token support has been choosen.
> +	} else {
> +		# Check if a username has been sent.
> +		if ($settings{'LOGIN'} eq '') {
> +			$errormessage = $Lang::tr{'username not set'};
> +		}
> +
> +		# Check if a password has been typed in.
> +		# freedns.afraid.org does not require this field.
> +		if (($settings{'PASSWORD'} eq '') && ($settings{'SERVICE'} ne 'freedns.afraid.org') && ($settings{'SERVICE'} ne 'regfish.com')) {
> +			$errormessage = $Lang::tr{'password not set'};
> +		}
>   	}
>   
>   	# Go furter if there was no error.
> 

      reply	other threads:[~2021-07-07 19:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 16:08 Stefan Schantl
2021-07-07 19:37 ` Bernhard Bitsch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5b6b047-b6fa-75d5-6021-e85803d10884@ipfire.org \
    --to=bbitsch@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox