public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames
@ 2024-01-31 12:04 Alexander Kanavin
  2024-01-31 12:04 ` [PATCH 2/2] classes/package_rpm: streamline the logic in one of the condition blocks Alexander Kanavin
  2024-02-01  0:02 ` [OE-core] [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames Alexandre Belloni
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Kanavin @ 2024-01-31 12:04 UTC (permalink / raw)
  To: openembedded-core; +Cc: Alexander Kanavin

As specified in:
https://github.com/rpm-software-management/rpm/blob/rpm-4.19.x/docs/manual/spec.md#shell-globbing

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes-global/package_rpm.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
index 819ee502783..c9354734756 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -217,7 +217,7 @@ python write_specfile () {
                 return "%attr({:o},{},{}) ".format(mode, owner, group)
 
             def escape_chars(p):
-                return p.replace("%", "%%")
+                return p.replace("%", "%%").replace("\\", "\\\\").replace('"', '\\"'))
 
             path = rootpath.replace(walkpath, "")
             if path.endswith("DEBIAN") or path.endswith("CONTROL"):
-- 
2.39.2



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

* [PATCH 2/2] classes/package_rpm: streamline the logic in one of the condition blocks
  2024-01-31 12:04 [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames Alexander Kanavin
@ 2024-01-31 12:04 ` Alexander Kanavin
  2024-02-01  0:02 ` [OE-core] [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames Alexandre Belloni
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Kanavin @ 2024-01-31 12:04 UTC (permalink / raw)
  To: openembedded-core; +Cc: Alexander Kanavin

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes-global/package_rpm.bbclass | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
index c9354734756..ffa0623af1d 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -243,13 +243,11 @@ python write_specfile () {
                     p = path + '/' + dir
                     # All packages own the directories their files are in...
                     target.append(get_attr(dir) + '%dir "' + escape_chars(p) + '"')
-            else:
+            elif path:
                 # packages own only empty directories or explict directory.
                 # This will prevent the overlapping of security permission.
                 attr = get_attr(path)
-                if path and not files and not dirs:
-                    target.append(attr + '%dir "' + escape_chars(path) + '"')
-                elif path and path in dirfiles:
+                if (not files and not dirs) or path in dirfiles:
                     target.append(attr + '%dir "' + escape_chars(path) + '"')
 
             for file in files:
-- 
2.39.2



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

* Re: [OE-core] [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames
  2024-01-31 12:04 [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames Alexander Kanavin
  2024-01-31 12:04 ` [PATCH 2/2] classes/package_rpm: streamline the logic in one of the condition blocks Alexander Kanavin
@ 2024-02-01  0:02 ` Alexandre Belloni
  2024-02-01  9:15   ` Alexander Kanavin
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2024-02-01  0:02 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: openembedded-core, Alexander Kanavin

On 31/01/2024 13:04:37+0100, Alexander Kanavin wrote:
> As specified in:
> https://github.com/rpm-software-management/rpm/blob/rpm-4.19.x/docs/manual/spec.md#shell-globbing
> 
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  meta/classes-global/package_rpm.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
> index 819ee502783..c9354734756 100644
> --- a/meta/classes-global/package_rpm.bbclass
> +++ b/meta/classes-global/package_rpm.bbclass
> @@ -217,7 +217,7 @@ python write_specfile () {
>                  return "%attr({:o},{},{}) ".format(mode, owner, group)
>  
>              def escape_chars(p):
> -                return p.replace("%", "%%")
> +                return p.replace("%", "%%").replace("\\", "\\\\").replace('"', '\\"'))

  File "/home/pokybuild/yocto-worker/build-appliance/build/meta/classes-global/package_rpm.bbclass", line 220
    return p.replace("%", "%%").replace("\\", "\\\\").replace('"', '\\"'))
                                                                         ^
SyntaxError: unmatched ')'


>  
>              path = rootpath.replace(walkpath, "")
>              if path.endswith("DEBIAN") or path.endswith("CONTROL"):
> -- 
> 2.39.2
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#194515): https://lists.openembedded.org/g/openembedded-core/message/194515
> Mute This Topic: https://lists.openembedded.org/mt/104073360/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


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

* Re: [OE-core] [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames
  2024-02-01  0:02 ` [OE-core] [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames Alexandre Belloni
@ 2024-02-01  9:15   ` Alexander Kanavin
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Kanavin @ 2024-02-01  9:15 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: openembedded-core, Alexander Kanavin

On Thu, 1 Feb 2024 at 01:02, Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
> > -                return p.replace("%", "%%")
> > +                return p.replace("%", "%%").replace("\\", "\\\\").replace('"', '\\"'))
>
>   File "/home/pokybuild/yocto-worker/build-appliance/build/meta/classes-global/package_rpm.bbclass", line 220
>     return p.replace("%", "%%").replace("\\", "\\\\").replace('"', '\\"'))
>                                                                          ^
> SyntaxError: unmatched ')'
>

Thanks,  I sent a corrected patchset now.

Alex


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

end of thread, other threads:[~2024-02-01  9:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-31 12:04 [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames Alexander Kanavin
2024-01-31 12:04 ` [PATCH 2/2] classes/package_rpm: streamline the logic in one of the condition blocks Alexander Kanavin
2024-02-01  0:02 ` [OE-core] [PATCH 1/2] classes/package_rpm: additionally escape \ and " in filenames Alexandre Belloni
2024-02-01  9:15   ` Alexander Kanavin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox