all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-zsync 1/2] rename encode_cron to parse_cron
@ 2022-02-21  9:07 Fabian Ebner
  2022-02-21  9:07 ` [pve-devel] [PATCH pve-zsync 2/2] parse cron: handle additional whitespace Fabian Ebner
  2022-02-21 15:06 ` [pve-devel] applied: [PATCH pve-zsync 1/2] rename encode_cron to parse_cron Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Ebner @ 2022-02-21  9:07 UTC (permalink / raw)
  To: pve-devel

The old name is confusing, because "encode" is usually not used when
converting from text to a data structure.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 pve-zsync | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pve-zsync b/pve-zsync
index b466076..7246336 100755
--- a/pve-zsync
+++ b/pve-zsync
@@ -232,7 +232,7 @@ sub read_cron {
 
     my $text = read_file($CRONJOBS, 0);
 
-    return encode_cron(@{$text});
+    return parse_cron(@{$text});
 }
 
 sub parse_argv {
@@ -302,7 +302,7 @@ sub add_state_to_job {
     return $job;
 }
 
-sub encode_cron {
+sub parse_cron {
     my (@text) = @_;
 
     my $cfg = {};
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH pve-zsync 2/2] parse cron: handle additional whitespace
  2022-02-21  9:07 [pve-devel] [PATCH pve-zsync 1/2] rename encode_cron to parse_cron Fabian Ebner
@ 2022-02-21  9:07 ` Fabian Ebner
  2022-02-21 15:05   ` Thomas Lamprecht
  2022-02-21 15:06 ` [pve-devel] applied: [PATCH pve-zsync 1/2] rename encode_cron to parse_cron Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Fabian Ebner @ 2022-02-21  9:07 UTC (permalink / raw)
  To: pve-devel

Can only happen by manually editing AFAICT, but cron does execute the
jobs, so just be a bit less restrictive when parsing.

Reported in the community forum:
https://forum.proxmox.com/threads/105254/

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 pve-zsync | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/pve-zsync b/pve-zsync
index 7246336..f69e126 100755
--- a/pve-zsync
+++ b/pve-zsync
@@ -308,8 +308,7 @@ sub parse_cron {
     my $cfg = {};
 
     while (my $line = shift(@text)) {
-
-	my @arg = split('\s', $line);
+	my @arg = split('\s+', $line);
 	my $param = parse_argv(@arg);
 
 	if ($param->{source} && $param->{dest}) {
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH pve-zsync 2/2] parse cron: handle additional whitespace
  2022-02-21  9:07 ` [pve-devel] [PATCH pve-zsync 2/2] parse cron: handle additional whitespace Fabian Ebner
@ 2022-02-21 15:05   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2022-02-21 15:05 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Ebner

On 21.02.22 10:07, Fabian Ebner wrote:
> Can only happen by manually editing AFAICT, but cron does execute the
> jobs, so just be a bit less restrictive when parsing.

I mean, it won't get more broken as already but can we avoid white-space splitting
on command arguments in general?

We could use the same underlying helper as PVE::Tools::split_args uses,
Text::ParseWords::shellwords (included in perl-modules directly)..

> 
> Reported in the community forum:
> https://forum.proxmox.com/threads/105254/
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  pve-zsync | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/pve-zsync b/pve-zsync
> index 7246336..f69e126 100755
> --- a/pve-zsync
> +++ b/pve-zsync
> @@ -308,8 +308,7 @@ sub parse_cron {
>      my $cfg = {};
>  
>      while (my $line = shift(@text)) {
> -
> -	my @arg = split('\s', $line);
> +	my @arg = split('\s+', $line);
>  	my $param = parse_argv(@arg);
>  
>  	if ($param->{source} && $param->{dest}) {





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] applied: [PATCH pve-zsync 1/2] rename encode_cron to parse_cron
  2022-02-21  9:07 [pve-devel] [PATCH pve-zsync 1/2] rename encode_cron to parse_cron Fabian Ebner
  2022-02-21  9:07 ` [pve-devel] [PATCH pve-zsync 2/2] parse cron: handle additional whitespace Fabian Ebner
@ 2022-02-21 15:06 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2022-02-21 15:06 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Ebner

On 21.02.22 10:07, Fabian Ebner wrote:
> The old name is confusing, because "encode" is usually not used when
> converting from text to a data structure.
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  pve-zsync | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-21 15:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21  9:07 [pve-devel] [PATCH pve-zsync 1/2] rename encode_cron to parse_cron Fabian Ebner
2022-02-21  9:07 ` [pve-devel] [PATCH pve-zsync 2/2] parse cron: handle additional whitespace Fabian Ebner
2022-02-21 15:05   ` Thomas Lamprecht
2022-02-21 15:06 ` [pve-devel] applied: [PATCH pve-zsync 1/2] rename encode_cron to parse_cron Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal