Skip to contentSkip to conversation

package/apparmor: replace deprecated egrep with grep -E

PATCH New aduskett at gmail.com 4 participants 10 messages May 8, 2020 – May 9, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 package/apparmor: replace deprecated egrep with grep -E

From: Adam Duskett <[email protected]>

Upstream commit: 5f46dedd6e8109d845af118b36039a5d7dd05af9

---
 ...replace-deprecated-egrep-with-grep-e.patch | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 package/apparmor/0002-replace-deprecated-egrep-with-grep-e.patch
package/apparmor/0002-replace-deprecated-egrep-with-grep-e.patch new file +28 -0
new file mode 100644
index 0000000000..4caefe447b
@@ -0,0 +1,28 @@
+From 5f46dedd6e8109d845af118b36039a5d7dd05af9 Mon Sep 17 00:00:00 2001
+From: Christian Boltz <[email protected]>
+Date: Mon, 18 Mar 2019 19:17:16 +0100
+Subject: [PATCH] replace deprecated egrep with grep -e
+
+(cherry picked from commit 5f46dedd6e8109d845af118b36039a5d7dd05af9)
+Signed-off-by: Christian Boltz <[email protected]>
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ parser/rc.apparmor.functions | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/parser/rc.apparmor.functions b/parser/rc.apparmor.functions
+index 22e8367..f3108f8 100644
+--- a/parser/rc.apparmor.functions
++++ b/parser/rc.apparmor.functions
+@@ -129,7 +129,7 @@ skip_profile() {
+ 	     "${profile%.pacnew}" != "${profile}" ] ; then
+ 		return 2
+ 	fi
+-	if echo "${profile}" | egrep -q '^.+\.new-[0-9\.]+_[0-9]+$'; then
++	if echo "${profile}" | grep -E -q '^.+\.new-[0-9\.]+_[0-9]+$'; then
+ 		return 2
+ 	fi
+ 
+-- 
+2.26.2
+
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/5 package/apparmor: fix compatibility with busybox grep

From: Adam Duskett <[email protected]>

The following regex string in rc.apparmor.functions
"^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" is broken due to the unescaped { at the end of the regex pattern.
GNU grep ignors the error. However, the Busybox grep does not and throws the error "unescaped character {"

Escape the "{" character to fix this issue.

Note: Upstream has rewritten large sections of the rc.apparmor.functions file and the function this patch fixes will no longer be necessary after the next version is released. However, it is not possible to easily backport the upstream patches as the rewrite comes with new features that would not be possible with a simple patch such as this one.

---
 ...apparmor.functions-to-work-with-busy.patch | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 package/apparmor/0003-fix-regex-in-rc.apparmor.functions-to-work-with-busy.patch
package/apparmor/0003-fix-regex-in-rc.apparmor.functions-to-work-with-busy.patch new file +37 -0
new file mode 100644
index 0000000000..54afcd43a8
@@ -0,0 +1,37 @@
+From 12764faa0a01bcc4e0ffc92ce308985dbad0d954 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Thu, 7 May 2020 18:25:29 -0700
+Subject: [PATCH] fix regex in rc.apparmor.functions to work with busybox
+
+The following regex string in rc.apparmor.functions
+"^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" is broken due to
+the unescaped {. GNU grep ignores the error. However, the Busybox grep does
+not and throws the error "unescaped character {"
+
+Escape the "{" character to fix this issue.
+
+Note: Upstream has rewritten large sections of the rc.apparmor.functions file
+and the function this patch fixes will no longer be necessary after the next
+version is released.
+
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ parser/rc.apparmor.functions | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/parser/rc.apparmor.functions b/parser/rc.apparmor.functions
+index f3108f8..db0697c 100644
+--- a/parser/rc.apparmor.functions
++++ b/parser/rc.apparmor.functions
+@@ -140,7 +140,7 @@ force_complain() {
+ 	local profile=$1
+ 
+ 	# if profile not in complain mode
+-	if ! egrep -q "^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" $profile ; then
++	if ! grep -E -q "^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+\{" $profile ; then
+ 		local link="${PROFILE_DIR}/force-complain/`basename ${profile}`"
+ 		if [ -e "$link" ] ; then
+ 			aa_log_warning_msg "found $link, forcing complain mode"
+-- 
+2.26.2
+
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/5 package/apparmor: fix compatibility with busybox grep

Adam, All,

Quoted 8 lines · On Fri, May 8, 2020 at 4:00 AM <[email protected]> wrote:

From: Adam Duskett <[email protected]>

The following regex string in rc.apparmor.functions
"^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" is broken due to the unescaped { at the end of the regex pattern.
GNU grep ignors the error. However, the Busybox grep does not and throws the error "unescaped character {"

Indeed, my original series had:

select BR2_PACKAGE_GREP

to overcome this issue but it went somewhat missing.

Quoted 65 lines

Escape the "{" character to fix this issue.

Note: Upstream has rewritten large sections of the rc.apparmor.functions file and the function this patch fixes will no longer be necessary after the next version is released. However, it is not possible to easily backport the upstream patches as the rewrite comes with new features that would not be possible with a simple patch such as this one.

---
 ...apparmor.functions-to-work-with-busy.patch | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 package/apparmor/0003-fix-regex-in-rc.apparmor.functions-to-work-with-busy.patch
package/apparmor/0003-fix-regex-in-rc.apparmor.functions-to-work-with-busy.patch new file +37 -1
new file mode 100644
index 0000000000..54afcd43a8
@@ -0,0 +1,37 @@
+From 12764faa0a01bcc4e0ffc92ce308985dbad0d954 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Thu, 7 May 2020 18:25:29 -0700
+Subject: [PATCH] fix regex in rc.apparmor.functions to work with busybox
+
+The following regex string in rc.apparmor.functions
+"^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" is broken due to
+the unescaped {. GNU grep ignores the error. However, the Busybox grep does
+not and throws the error "unescaped character {"
+
+Escape the "{" character to fix this issue.
+
+Note: Upstream has rewritten large sections of the rc.apparmor.functions file
+and the function this patch fixes will no longer be necessary after the next
+version is released.
+
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ parser/rc.apparmor.functions | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/parser/rc.apparmor.functions b/parser/rc.apparmor.functions
+index f3108f8..db0697c 100644
+--- a/parser/rc.apparmor.functions
++++ b/parser/rc.apparmor.functions
+@@ -140,7 +140,7 @@ force_complain() {
+       local profile=$1
+
+       # if profile not in complain mode
+-      if ! egrep -q "^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" $profile ; then
++      if ! grep -E -q "^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+\{" $profile ; then
+               local link="${PROFILE_DIR}/force-complain/`basename ${profile}`"
+               if [ -e "$link" ] ; then
+                       aa_log_warning_msg "found $link, forcing complain mode"
+--
+2.26.2
+
--

2.26.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#3 lore raw

PATCH 2/5 package/apparmor: fix compatibility with busybox grep

Adam, Angelo, All,

On 2020-05-08 08:32 +0200, Angelo Compagnucci spake thusly:

Quoted 10 lines · On Fri, May 8, 2020 at 4:00 AM <[email protected]> wrote:
Quoted 8 lines

From: Adam Duskett <[email protected]>

The following regex string in rc.apparmor.functions
"^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" is broken due to the unescaped { at the end of the regex pattern.
GNU grep ignors the error. However, the Busybox grep does not and throws the error "unescaped character {"

Quoted 3 lines

Indeed, my original series had:
select BR2_PACKAGE_GREP
to overcome this issue but it went somewhat missing.

I dropped it in my rework of the series, because there was no explanations why it was needed.

In the end, I did apply Adam's patch, because:
- it is simple enough and correct,
- we will notice it no longer applies when we bump the version, and so can drop it.

If we 'd have gone for selecting the full grep, we would not have noticed that it would no longer needed when we update, later.

Thanks.

Regards,
Yann E. MORIN.

Quoted 64 lines
Quoted 64 lines

Escape the "{" character to fix this issue.

Note: Upstream has rewritten large sections of the rc.apparmor.functions file and the function this patch fixes will no longer be necessary after the next version is released. However, it is not possible to easily backport the upstream patches as the rewrite comes with new features that would not be possible with a simple patch such as this one.

---
 ...apparmor.functions-to-work-with-busy.patch | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 package/apparmor/0003-fix-regex-in-rc.apparmor.functions-to-work-with-busy.patch
package/apparmor/0003-fix-regex-in-rc.apparmor.functions-to-work-with-busy.patch new file +37 -1
new file mode 100644
index 0000000000..54afcd43a8
@@ -0,0 +1,37 @@
+From 12764faa0a01bcc4e0ffc92ce308985dbad0d954 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Thu, 7 May 2020 18:25:29 -0700
+Subject: [PATCH] fix regex in rc.apparmor.functions to work with busybox
+
+The following regex string in rc.apparmor.functions
+"^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" is broken due to
+the unescaped {. GNU grep ignores the error. However, the Busybox grep does
+not and throws the error "unescaped character {"
+
+Escape the "{" character to fix this issue.
+
+Note: Upstream has rewritten large sections of the rc.apparmor.functions file
+and the function this patch fixes will no longer be necessary after the next
+version is released.
+
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ parser/rc.apparmor.functions | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/parser/rc.apparmor.functions b/parser/rc.apparmor.functions
+index f3108f8..db0697c 100644
+--- a/parser/rc.apparmor.functions
++++ b/parser/rc.apparmor.functions
+@@ -140,7 +140,7 @@ force_complain() {
+       local profile=$1
+
+       # if profile not in complain mode
+-      if ! egrep -q "^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+{" $profile ; then
++      if ! grep -E -q "^/.*[ \t]+flags[ \t]*=[ \t]*\([ \t]*complain[ \t]*\)[ \t]+\{" $profile ; then
+               local link="${PROFILE_DIR}/force-complain/`basename ${profile}`"
+               if [ -e "$link" ] ; then
+                       aa_log_warning_msg "found $link, forcing complain mode"
+--
+2.26.2
+
--

2.26.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH 3/5 package/apparmor: fix typo in Config.in

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

pyhon should be python

---
 package/apparmor/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/apparmor/Config.in +1 -1
index 3cb5349cac..b0d2e44ff7 100644
@@ -34,7 +34,7 @@ config BR2_PACKAGE_APPARMOR_UTILS
 	depends on BR2_PACKAGE_PYTHON3
 	select BR2_PACKAGE_PYTHON3_READLINE
 	help
-	  A set of utilities (written in pyhon):
+	  A set of utilities (written in python):
 	    aa-audit          aa-disable      aa-logprof
 	    aa-autodep        aa-easyprof     aa-mergeprof
 	    aa-cleanprof      aa-enforce      aa-status
Signature · 1 line
2.26.2
#5 lore raw

PATCH 4/5 package/apparmor: add a dependency on net-tools if utils is selected

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

aa-unconfied requires the full version of netstat provided by the net-tools package. Without the full version, running aa-unconfined will result in the error:
netstat: invalid option -- 'p'

---
 package/apparmor/Config.in | 2 ++
 1 file changed, 2 insertions(+)
package/apparmor/Config.in +2 -0
index b0d2e44ff7..481317ac7b 100644
@@ -31,8 +31,10 @@ comment "utils need python3"
 
 config BR2_PACKAGE_APPARMOR_UTILS
 	bool "utils"
+	depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	depends on BR2_PACKAGE_PYTHON3
 	select BR2_PACKAGE_PYTHON3_READLINE
+	select BR2_PACKAGE_NET_TOOLS # aa-unconfined
 	help
 	  A set of utilities (written in python):
 	    aa-audit          aa-disable      aa-logprof
Signature · 1 line
2.26.2
#6 lore raw

PATCH 5/5 package/systemd: add support for apparmor

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

If libapparmor is selected, depend on libapparmor and set -Dapparmor=true

---
 package/systemd/systemd.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/systemd/systemd.mk +7 -0
index 9f5429fd19..50398e747e 100644
@@ -49,6 +49,13 @@ else
 SYSTEMD_CONF_OPTS += -Dacl=false
 endif
 
+ifeq ($(BR2_PACKAGE_LIBAPPARMOR),y)
+SYSTEMD_DEPENDENCIES += libapparmor
+SYSTEMD_CONF_OPTS += -Dapparmor=true
+else
+SYSTEMD_CONF_OPTS += -Dapparmor=false
+endif
+
 ifeq ($(BR2_PACKAGE_AUDIT),y)
 SYSTEMD_DEPENDENCIES += audit
 SYSTEMD_CONF_OPTS += -Daudit=true
Signature · 1 line
2.26.2
#7 lore raw

PATCH 5/5 package/systemd: add support for apparmor

Quoted 8 lines · On Thu, 7 May 2020 18:59:56 -0700 aduskett at gmail.com wrote:

From: Adam Duskett <[email protected]>

If libapparmor is selected, depend on libapparmor and set -Dapparmor=true

---
 package/systemd/systemd.mk | 7 +++++++
 1 file changed, 7 insertions(+)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#8 lore raw

PATCH 1/5 package/apparmor: replace deprecated egrep with grep -E

In reply to aduskett at gmail.com

Adam, All,

On 2020-05-07 18:59 -0700, aduskett at gmail.com spake thusly:

Quoted 5 lines

From: Adam Duskett <[email protected]>

Upstream commit: 5f46dedd6e8109d845af118b36039a5d7dd05af9

Patches 1-4 applied to master, thanks. See a few replies to patch 2 and 4.

I've not (yet) applied patch 5, because it is sitting somewhere between being a feature-patch and being a fix. If is a feature-patch because it allows building systemnd with apparmor support, while it is a fix because it guarantees build ordering now... So saying I'm torn onthat one is a bit strong, but still I am not sure either...

Regards,
Yann E. MORIN.

Quoted 42 lines
---
 ...replace-deprecated-egrep-with-grep-e.patch | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 package/apparmor/0002-replace-deprecated-egrep-with-grep-e.patch
package/apparmor/0002-replace-deprecated-egrep-with-grep-e.patch new file +28 -0
new file mode 100644
index 0000000000..4caefe447b
@@ -0,0 +1,28 @@
+From 5f46dedd6e8109d845af118b36039a5d7dd05af9 Mon Sep 17 00:00:00 2001
+From: Christian Boltz <[email protected]>
+Date: Mon, 18 Mar 2019 19:17:16 +0100
+Subject: [PATCH] replace deprecated egrep with grep -e
+
+(cherry picked from commit 5f46dedd6e8109d845af118b36039a5d7dd05af9)
+Signed-off-by: Christian Boltz <[email protected]>
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ parser/rc.apparmor.functions | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/parser/rc.apparmor.functions b/parser/rc.apparmor.functions
+index 22e8367..f3108f8 100644
+--- a/parser/rc.apparmor.functions
++++ b/parser/rc.apparmor.functions
+@@ -129,7 +129,7 @@ skip_profile() {
+ 	     "${profile%.pacnew}" != "${profile}" ] ; then
+ 		return 2
+ 	fi
+-	if echo "${profile}" | egrep -q '^.+\.new-[0-9\.]+_[0-9]+$'; then
++	if echo "${profile}" | grep -E -q '^.+\.new-[0-9\.]+_[0-9]+$'; then
+ 		return 2
+ 	fi
+ 
+-- 
+2.26.2
+
Signature · 1 line
2.26.2
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#9 lore raw

PATCH 1/5 package/apparmor: replace deprecated egrep with grep -E

Quoted 5 lines · On Fri, 8 May 2020 10:14:49 +0200 "Yann E. MORIN" <[email protected]>…

I've not (yet) applied patch 5, because it is sitting somewhere between being a feature-patch and being a fix. If is a feature-patch because it allows building systemnd with apparmor support, while it is a fix because it guarantees build ordering now... So saying I'm torn onthat one is a bit strong, but still I am not sure either...

I've decided for you, and applied it to master :-)

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com