public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,  Dylan Whyte <d.whyte@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup] fix #3038: check user before renewing ticket
Date: Wed, 21 Oct 2020 08:43:43 +0200 (CEST)	[thread overview]
Message-ID: <48157714.325.1603262623854@webmail.proxmox.com> (raw)
In-Reply-To: <20201020092916.11547-1-d.whyte@proxmox.com>

This fix is not really correct. I applied it wit a followup patch.
Please can you test my fix?

comments inline:

> On 10/20/2020 11:29 AM Dylan Whyte <d.whyte@proxmox.com> wrote:
> 
>  
> Fixes a bug in which the userid of the ticket cache is updated,
> when a user connects, but the ticket itself is not.
> This means a newly connected user has a previously connected
> user's ticket and thus, cannot do anything, as the client will
> attempt to use the invalid ticket.
> 
> e.g. if john@pbs connected to the server first, followed by
> mike@pbs, the following would be stored in the ticket cache.
> 
> {
>   "localhost": {
>     "mike@pbs": {
>       "ticket": "PBS:john@pbs:AAAA",
>       "timestamp": 1601039326,
>       "token": "BBBB"
>     }
>   }
> }
> 
> Signed-off-by: Dylan Whyte <d.whyte@proxmox.com>
> ---
>  src/client/http_client.rs | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/src/client/http_client.rs b/src/client/http_client.rs
> index e3d18604..02a58c2d 100644
> --- a/src/client/http_client.rs
> +++ b/src/client/http_client.rs
> @@ -219,11 +219,13 @@ fn store_ticket_info(prefix: &str, server: &str, username: &str, ticket: &str, t
>  
>      let empty = serde_json::map::Map::new();
>      for (server, info) in data.as_object().unwrap_or(&empty) {
> -        for (_user, uinfo) in info.as_object().unwrap_or(&empty) {
> -            if let Some(timestamp) = uinfo["timestamp"].as_i64() {
> -                let age = now - timestamp;
> -                if age < ticket_lifetime {
> -                    new_data[server][username] = uinfo.clone();
> +        for (user, uinfo) in info.as_object().unwrap_or(&empty) {
> +            if user == username {

not needed

> +                if let Some(timestamp) = uinfo["timestamp"].as_i64() {
> +                    let age = now - timestamp;
> +                    if age < ticket_lifetime {
> +                        new_data[server][username] = uinfo.clone();

 new_data[server][user] = uinfo.clone();

> +                    }
>                  }
>              }
>          }
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




  reply	other threads:[~2020-10-21  6:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20  9:29 Dylan Whyte
2020-10-21  6:43 ` Dietmar Maurer [this message]
2020-10-21  7:52   ` Dylan Whyte

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=48157714.325.1603262623854@webmail.proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=d.whyte@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal