From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B687872490 for ; Tue, 25 May 2021 13:19:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AAAB02B315 for ; Tue, 25 May 2021 13:19:49 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 866762B30A for ; Tue, 25 May 2021 13:19:48 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5BBC1426E0 for ; Tue, 25 May 2021 13:19:48 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 25 May 2021 13:19:47 +0200 Message-Id: <20210525111947.21743-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.024 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [journal.rs] Subject: [pbs-devel] [PATCH proxmox-backup] api2/node/journal: fix parameter extraction of /nodes/node/journal X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2021 11:19:49 -0000 by extracting them via the api macro into the function signature this fixes an issue, where giving 'since' and 'until' where not used since we tried to extract them as 'str' while they were numbers. Signed-off-by: Dominik Csapak --- src/api2/node/journal.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/api2/node/journal.rs b/src/api2/node/journal.rs index 3d28a472..c5a41bda 100644 --- a/src/api2/node/journal.rs +++ b/src/api2/node/journal.rs @@ -60,36 +60,41 @@ use crate::config::acl::PRIV_SYS_AUDIT; )] /// Read syslog entries. fn get_journal( - param: Value, + since: Option, + until: Option, + lastentries: Option, + startcursor: Option, + endcursor: Option, + _param: Value, _info: &ApiMethod, _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let mut args = vec![]; - if let Some(lastentries) = param["lastentries"].as_u64() { + if let Some(lastentries) = lastentries { args.push(String::from("-n")); args.push(format!("{}", lastentries)); } - if let Some(since) = param["since"].as_str() { + if let Some(since) = since { args.push(String::from("-b")); - args.push(since.to_owned()); + args.push(since.to_string()); } - if let Some(until) = param["until"].as_str() { + if let Some(until) = until { args.push(String::from("-e")); - args.push(until.to_owned()); + args.push(until.to_string()); } - if let Some(startcursor) = param["startcursor"].as_str() { + if let Some(startcursor) = startcursor { args.push(String::from("-f")); - args.push(startcursor.to_owned()); + args.push(startcursor); } - if let Some(endcursor) = param["endcursor"].as_str() { + if let Some(endcursor) = endcursor { args.push(String::from("-t")); - args.push(endcursor.to_owned()); + args.push(endcursor); } let mut lines: Vec = vec![]; -- 2.20.1