Skip to contentSkip to conversation

base-files: profile: Do not assume that the 'command' command exists

PATCH In review Mike Looijmans 8 participants 29 messages Sep 18, 2017 – May 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 base-files: profile: Do not assume that the 'command' command exists

The "command" shell command appears to be a bashism, the standard busybox shell doesn't implement it.

This avoids the following error when logging in to a host that does not have the 'command' command:

-sh: command: not found

It also simplifies the code and reduces the number of forks.

Fixes e77cdb761169e404556487ac650dc562000da406
---
 meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
meta/recipes-core/base-files/base-files/profile +6 -8
index ceaf15f..b5b533c 100644
@@ -22,14 +22,12 @@ if [ -d /etc/profile.d ]; then
 	unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-	# Make sure we are on a serial console (i.e. the device used starts with
-	# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
-	# tries do use ssh
-	case $(tty) in
-		/dev/tty[A-z]*) resize >/dev/null;;
-	esac
-fi
+# Make sure we are on a serial console (i.e. the device used starts with
+# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
+# tries do use ssh
+case $(tty 2>/dev/null) in
+	/dev/tty[A-z]*) resize >/dev/null;;
+esac
 
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 base-files: profile: Make the "resize" command have the intended effect

The "resize" command outputs shell script to be evaluated. The proper way to use it is to do:
eval resize
This sets the related environment variables COLUMNS and ROWS so that a vi invokation uses the proper dimensions. Without the "eval" part, running vi still gives a garbled screen when the dimensions aren't 80x25.

---
 meta/recipes-core/base-files/base-files/profile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/base-files/base-files/profile +1 -1
index b5b533c..36bd35f 100644
@@ -26,7 +26,7 @@ fi
 # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
 # tries do use ssh
 case $(tty 2>/dev/null) in
-	/dev/tty[A-z]*) resize >/dev/null;;
+	/dev/tty[A-z]*) eval `resize` ;;
 esac
 
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
Signature · 1 line
1.9.1
#2 lore raw
In reply to Mike Looijmans
Quoted 52 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Looijmans
Sent: den 18 september 2017 10:39
To: [email protected]
Cc: Mike Looijmans <[email protected]>
Subject: [OE-core] [PATCH 1/2] base-files: profile: Do not assume that the 'command' command exists

The "command" shell command appears to be a bashism, the standard busybox shell doesn't implement it.

This avoids the following error when logging in to a host that does not have the 'command' command:

-sh: command: not found

It also simplifies the code and reduces the number of forks.

Fixes e77cdb761169e404556487ac650dc562000da406
---
 meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
meta/recipes-core/base-files/base-files/profile +6 -9
index ceaf15f..b5b533c 100644
@@ -22,14 +22,12 @@ if [ -d /etc/profile.d ]; then
 	unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-	# Make sure we are on a serial console (i.e. the device used starts with
-	# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
-	# tries do use ssh
-	case $(tty) in
-		/dev/tty[A-z]*) resize >/dev/null;;
-	esac
-fi
+# Make sure we are on a serial console (i.e. the device used starts with
+# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
+# tries do use ssh
+case $(tty 2>/dev/null) in
+	/dev/tty[A-z]*) resize >/dev/null;;
+esac
 
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
 
--
Quoted 1 line

1.9.1

This is basically the same change as I first sent a patch for in April, and last pinged this Friday... The only real difference is that this one misses passing error output from resize to /dev/null (which it should do to handle the case where tty exists, but resize does not).

//Peter

#3 lore raw
Quoted 1 line · Peter Kjellerstedt
Quoted 1 line

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

-----Original Message-----

Quoted 50 lines
Quoted 50 lines

From: [email protected] [mailto:[email protected]] On Behalf Of Mike Looijmans
Sent: den 18 september 2017 10:39
To: [email protected]
Cc: Mike Looijmans <[email protected]>
Subject: [OE-core] [PATCH 1/2] base-files: profile: Do not assume that the 'command' command exists

The "command" shell command appears to be a bashism, the standard busybox shell doesn't implement it.

This avoids the following error when logging in to a host that does not have the 'command' command:

-sh: command: not found

It also simplifies the code and reduces the number of forks.

Fixes e77cdb761169e404556487ac650dc562000da406
---
  meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
  1 file changed, 6 insertions(+), 8 deletions(-)
meta/recipes-core/base-files/base-files/profile +6 -8
index ceaf15f..b5b533c 100644
@@ -22,14 +22,12 @@ if [ -d /etc/profile.d ]; then
  	unset i
  fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-	# Make sure we are on a serial console (i.e. the device used starts with
-	# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
-	# tries do use ssh
-	case $(tty) in
-		/dev/tty[A-z]*) resize >/dev/null;;
-	esac
-fi
+# Make sure we are on a serial console (i.e. the device used starts with
+# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
+# tries do use ssh
+case $(tty 2>/dev/null) in
+	/dev/tty[A-z]*) resize >/dev/null;;
+esac
 
  export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
 
Quoted 7 lines
Quoted 2 lines

--
1.9.1

This is basically the same change as I first sent a patch for in April, and last pinged this Friday... The only real difference is that this one misses passing error output from resize to /dev/null (which it should do to handle the case where tty exists, but resize does not).

Yeah, indeed.

Other problem is that "resize" outputs shell script on stdout to be executed, so the proper "total" invokation would be:

  /dev/tty[A-z]*) eval `resize 2>/dev/null` ;;

The "eval" part is missing in your version...

#4 lore raw
Quoted 10 lines · Mike Looijmans

This is basically the same change as I first sent a patch for in April, and

Quoted 6 lines

last pinged this Friday... The only real difference is that this one misses
passing error output from resize to /dev/null (which it should do to handle
the case where tty exists, but resize does not).

Yeah, indeed.

Apologies for missing that patch!

Quoted 6 lines

Other problem is that "resize" outputs shell script on stdout to be executed, so the proper "total" invokation would be:

  /dev/tty[A-z]*) eval `resize 2>/dev/null` ;;

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in? I promise to merge it.

Ross

#5 lore raw
Quoted 19 lines · Ross

On 18 September 2017 at 12:31, Mike Looijmans <[email protected] <mailto:[email protected]>> wrote:

This is basically the same change as I first sent a patch for in April, and
last pinged this Friday... The only real difference is that this one misses
passing error output from resize to /dev/null (which it should do to handle
the case where tty exists, but resize does not).

Yeah, indeed.

Apologies for missing that patch!

Other problem is that "resize" outputs shell script on stdout to be executed, so the proper "total" invokation would be:

Quoted 6 lines

/dev/tty[A-z]*) eval resize 2>/dev/null ;;

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in? I promise to merge it.

I'll send the one ring, eh, patch, in a few minutes. I'll merge the two into a single as well.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

#6 lore raw
Quoted 20 lines · Mike Looijmans
Quoted 19 lines · Ross

On 18 September 2017 at 12:31, Mike Looijmans <[email protected] <mailto:[email protected]>> wrote:

This is basically the same change as I first sent a patch for in April, and
last pinged this Friday... The only real difference is that this one misses
passing error output from resize to /dev/null (which it should do to handle
the case where tty exists, but resize does not).

Yeah, indeed.

Apologies for missing that patch!

Other problem is that "resize" outputs shell script on stdout to be executed, so the proper "total" invokation would be:

Quoted 8 lines
Quoted 6 lines

/dev/tty[A-z]*) eval resize 2>/dev/null ;;

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in? I promise to merge it.

I'll send the one ring, eh, patch, in a few minutes. I'll merge the two into a single as well.

On second thought, just use Peter's patch "as is".

I've been experimenting with the "eval" part and it doesn't behave well. Tends to confuse minicom, create garbage, and in particular when run from "profile", it seems to result in counterproductive COLUMNS=0 and LINES=0.

I'm actually wondering why the call to "resize" is being done at all. Just calling "resize" has no effect, since it outputs the results on stdout as shell script, and that is being discarded. Looking at the commit that introduced it:

cc6360f4c4d9 (base-files: set dynamic COLUMNS via resize command)

that already has no effect whatsoever. See the man page for resize:
https://linux.die.net/man/1/resize

I also would consider running some program's output as shell script a bit spooky, it looks like a security hole waiting to be exploited.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

#7 lore raw
Quoted 31 lines · Mike Looijmans
Quoted 30 lines · Mike Looijmans
Quoted 28 lines · Ross

On 18 September 2017 at 12:31, Mike Looijmans <[email protected] <mailto:[email protected]>> wrote:

This is basically the same change as I first sent a patch
for in
April, and
last pinged this Friday... The only real difference is that
this one
misses
passing error output from resize to /dev/null (which it
should do to
handle
the case where tty exists, but resize does not).

Yeah, indeed.

Apologies for missing that patch!

Other problem is that "resize" outputs shell script on stdout to be executed, so the proper "total" invokation would be:

/dev/tty[A-z]*) eval resize 2>/dev/null ;;

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in? I promise to merge it.

Quoted 8 lines
Quoted 1 line

I'll send the one ring, eh, patch, in a few minutes. I'll merge the two into a single as well.

On second thought, just use Peter's patch "as is".

I've been experimenting with the "eval" part and it doesn't behave well. Tends to confuse minicom, create garbage, and in particular when run from "profile", it seems to result in counterproductive COLUMNS=0 and LINES=0.

I'm actually wondering why the call to "resize" is being done at all. Just calling "resize" has no effect, since it outputs the results on stdout as shell script, and that is being discarded. Looking at the commit that introduced it:

Looking at the codes in busybox (console-tools/resize.c), I can see that tcsetattr is actually called. The output is due to:

if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
w.ws_col, w.ws_row);

I can confirm that calling 'resize' is needed. Otherwise, you might get input wrapping on the same line when typing long commands.

I just tried busybox init based system and I also met '-sh: command: not found' error message.
I think Peter's patch ([OE-core] [PATCHv2 1/1] base-files: profile: Avoid using "command" to determine if programs exist) is correct.

Best Regards,
Chen Qi

Quoted 25 lines

cc6360f4c4d9 (base-files: set dynamic COLUMNS via resize command)

that already has no effect whatsoever. See the man page for resize:
https://linux.die.net/man/1/resize

I also would consider running some program's output as shell script a bit spooky, it looks like a security hole waiting to be exploited.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

#8 lore raw
Quoted 45 lines · ChenQi
Quoted 32 lines · Mike Looijmans
Quoted 31 lines · Mike Looijmans
Quoted 29 lines · Ross

On 18 September 2017 at 12:31, Mike Looijmans <[email protected] <mailto:[email protected]>> wrote:

This is basically the same change as I first sent a patch
for in
April, and
last pinged this Friday... The only real difference is that
this one
misses
passing error output from resize to /dev/null (which it
should do to
handle
the case where tty exists, but resize does not).

Yeah, indeed.

Apologies for missing that patch!

Other problem is that "resize" outputs shell script on stdout
to be
executed, so the proper "total" invokation would be:

/dev/tty[A-z]*) eval resize 2>/dev/null ;;

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in? I promise to merge it.

Quoted 8 lines
Quoted 1 line

I'll send the one ring, eh, patch, in a few minutes. I'll merge the two into a single as well.

On second thought, just use Peter's patch "as is".

I've been experimenting with the "eval" part and it doesn't behave well. Tends to confuse minicom, create garbage, and in particular when run from "profile", it seems to result in counterproductive COLUMNS=0 and LINES=0.

I'm actually wondering why the call to "resize" is being done at all. Just calling "resize" has no effect, since it outputs the results on stdout as shell script, and that is being discarded. Looking at the commit that introduced it:

Looking at the codes in busybox (console-tools/resize.c), I can see that tcsetattr is actually called. The output is due to:

Quoted 7 lines

if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
w.ws_col, w.ws_row);

I can confirm that calling 'resize' is needed. Otherwise, you might get input wrapping on the same line when typing long commands.

I just tried busybox init based system and I also met '-sh: command: not found' error message.

Sorry for the noise. Just noticed that oe-core has enabled 'command' for busybox by default. It's my own busybox defconfig that hasn't enabled it.

Best Regards,
Chen Qi

Quoted 31 lines

I think Peter's patch ([OE-core] [PATCHv2 1/1] base-files: profile: Avoid using "command" to determine if programs exist) is correct.

Best Regards,
Chen Qi

Quoted 25 lines

cc6360f4c4d9 (base-files: set dynamic COLUMNS via resize command)

that already has no effect whatsoever. See the man page for resize:
https://linux.die.net/man/1/resize

I also would consider running some program's output as shell script a bit spooky, it looks like a security hole waiting to be exploited.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

#9 lore raw
Quoted 60 lines · ChenQi
Quoted 59 lines · ChenQi
Quoted 44 lines · Mike Looijmans
Quoted 27 lines · Mike Looijmans
Quoted 26 lines · Ross

On 18 September 2017 at 12:31, Mike Looijmans <[email protected] <mailto:[email protected]>> wrote:

This is basically the same change as I first sent a patch
for in
April, and
last pinged this Friday... The only real difference is that
this one
misses
passing error output from resize to /dev/null (which it
should do to
handle
the case where tty exists, but resize does not).

Yeah, indeed.

Apologies for missing that patch!

Other problem is that "resize" outputs shell script on stdout
to be
executed, so the proper "total" invokation would be:

/dev/tty[A-z]*) eval resize 2>/dev/null ;;

Quoted 8 lines
Quoted 5 lines

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in? I promise to merge it.

I'll send the one ring, eh, patch, in a few minutes. I'll merge the two into a single as well.

On second thought, just use Peter's patch "as is".

I've been experimenting with the "eval" part and it doesn't behave well. Tends to confuse minicom, create garbage, and in particular when run from "profile", it seems to result in counterproductive COLUMNS=0 and LINES=0.

Quoted 5 lines

I'm actually wondering why the call to "resize" is being done at all. Just calling "resize" has no effect, since it outputs the results on stdout as shell script, and that is being discarded. Looking at the commit that introduced it:

Looking at the codes in busybox (console-tools/resize.c), I can see that tcsetattr is actually called.
The output is due to:

if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
w.ws_col, w.ws_row);

Quoted 8 lines
Quoted 5 lines

I can confirm that calling 'resize' is needed. Otherwise, you might get input wrapping on the same line when typing long commands.

I just tried busybox init based system and I also met '-sh: command:
not found' error message.

Sorry for the noise. Just noticed that oe-core has enabled 'command' for busybox by default. It's my own busybox defconfig that hasn't enabled it.

I was just hit by the same. resize and tty work fine, but command applet is missing in my images.

Is enabling command applet in busybox now hard requirement for all the builds or is anyone still planing to send follow-up on this?

At least to show some more meaningful error when it's not available?

"you probably need to fix your busybox defconfig, because some old thread on oe-core ML says so"

Cheers,

Quoted 42 lines

Best Regards,
Chen Qi

Quoted 33 lines

I think Peter's patch ([OE-core] [PATCHv2 1/1] base-files: profile:
Avoid using "command" to determine if programs exist) is correct.

Best Regards,
Chen Qi

Quoted 26 lines

cc6360f4c4d9 (base-files: set dynamic COLUMNS via resize command)

that already has no effect whatsoever. See the man page for resize:
https://linux.die.net/man/1/resize

I also would consider running some program's output as shell script a bit spooky, it looks like a security hole waiting to be exploited.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

Signature · 4 lines
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#10 lore raw
Quoted 98 lines

-----Original Message-----
From: Martin Jansa [mailto:[email protected]]
Sent: den 18 maj 2018 12:29
To: ChenQi <[email protected]>
Cc: Mike Looijmans <[email protected]>; openembedded- [email protected]; Peter Kjellerstedt <[email protected]>; Burton, Ross <[email protected]>
Subject: Re: [OE-core] [PATCH 1/2] base-files: profile: Do not assume that the 'command' command exists

Quoted 6 lines · ChenQi
Quoted 5 lines · ChenQi
Quoted 4 lines · Mike Looijmans
Quoted 3 lines · Mike Looijmans
Quoted 2 lines · Ross

On 18 September 2017 at 12:31, Mike Looijmans <[email protected] <mailto:[email protected]>>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is basically the same change as I first sent a

patch

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

for in
April, and
last pinged this Friday... The only real difference is

that

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

this one
misses
passing error output from resize to /dev/null (which it
should do to
handle
the case where tty exists, but resize does not).

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Yeah, indeed.

Apologies for missing that patch!

Other problem is that "resize" outputs shell script on

stdout

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

to be
executed, so the proper "total" invokation would be:

/dev/tty[A-z]*) eval resize 2>/dev/null ;;

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in?

I

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

promise to merge it.

I'll send the one ring, eh, patch, in a few minutes. I'll merge

the

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 1 line

two into a single as well.

On second thought, just use Peter's patch "as is".

I've been experimenting with the "eval" part and it doesn't behave well. Tends to confuse minicom, create garbage, and in particular when run from "profile", it seems to result in counterproductive COLUMNS=0 and LINES=0.

I'm actually wondering why the call to "resize" is being done at

all.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Just calling "resize" has no effect, since it outputs the results

on

Quoted 1 line
Quoted 1 line
Quoted 1 line

stdout as shell script, and that is being discarded. Looking at

the

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

commit that introduced it:

Looking at the codes in busybox (console-tools/resize.c), I can see that tcsetattr is actually called.
The output is due to:

Quoted 8 lines
Quoted 8 lines

if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
w.ws_col, w.ws_row);

I can confirm that calling 'resize' is needed. Otherwise, you might get input wrapping on the same line when typing long commands.

I just tried busybox init based system and I also met '-sh:

command:

Quoted 3 lines
Quoted 1 line

not found' error message.

Sorry for the noise. Just noticed that oe-core has enabled 'command'

for

Quoted 1 line

busybox by default. It's my own busybox defconfig that hasn't enabled

it.

I was just hit by the same. resize and tty work fine, but command applet is missing in my images.

Is enabling command applet in busybox now hard requirement for all the builds or is anyone still planing to send follow-up on this?

Quoted 6 lines

At least to show some more meaningful error when it's not available?

"you probably need to fix your busybox defconfig, because some old thread on oe-core ML says so"

Cheers,

Wow, here's an old discussion I had forgotten all about. I actually do have an updated version of the patch that solves the problem by running resize twice, once with stderr piped to /dev/null to determine if the resize command exists, and once without stderr piped to /dev/null to actually do the resize (since resize uses stderr to determine the size of the tty).

I'll send the updated patch in a minute.

Quoted 33 lines
Quoted 12 lines

Best Regards,
Chen Qi

Quoted 9 lines

I think Peter's patch ([OE-core] [PATCHv2 1/1] base-files: profile:
Avoid using "command" to determine if programs exist) is correct.

Best Regards,
Chen Qi

Quoted 3 lines

cc6360f4c4d9 (base-files: set dynamic COLUMNS via resize command)

that already has no effect whatsoever. See the man page for

resize:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

https://linux.die.net/man/1/resize

I also would consider running some program's output as shell

script a

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

bit spooky, it looks like a security hole waiting to be exploited.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Please consider the environment before printing this e-mail

--
Martin 'JaMa' Jansa jabber: [email protected]

//Peter

#11 lore raw

Awesome, thanks!

Quoted 155 lines · Peter Kjellerstedt
Quoted 98 lines

-----Original Message-----
From: Martin Jansa [mailto:[email protected]]
Sent: den 18 maj 2018 12:29
To: ChenQi <[email protected]>
Cc: Mike Looijmans <[email protected]>; openembedded- [email protected]; Peter Kjellerstedt <[email protected]>; Burton, Ross <[email protected]>
Subject: Re: [OE-core] [PATCH 1/2] base-files: profile: Do not assume that the 'command' command exists

Quoted 6 lines · ChenQi
Quoted 5 lines · ChenQi
Quoted 4 lines · Mike Looijmans
Quoted 3 lines · Mike Looijmans
Quoted 2 lines · Ross

On 18 September 2017 at 12:31, Mike Looijmans <[email protected] <mailto:[email protected]>>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This is basically the same change as I first sent a

patch

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

for in
April, and
last pinged this Friday... The only real difference is

that

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

this one
misses
passing error output from resize to /dev/null (which it
should do to
handle
the case where tty exists, but resize does not).

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Yeah, indeed.

Apologies for missing that patch!

Other problem is that "resize" outputs shell script on

stdout

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

to be
executed, so the proper "total" invokation would be:

/dev/tty[A-z]*) eval resize 2>/dev/null ;;

The "eval" part is missing in your version...

Who is going to submit the One True patch with all the fixes in?

I

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

promise to merge it.

I'll send the one ring, eh, patch, in a few minutes. I'll merge

the

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 1 line

two into a single as well.

On second thought, just use Peter's patch "as is".

I've been experimenting with the "eval" part and it doesn't behave well. Tends to confuse minicom, create garbage, and in particular when run from "profile", it seems to result in counterproductive COLUMNS=0 and LINES=0.

I'm actually wondering why the call to "resize" is being done at

all.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Just calling "resize" has no effect, since it outputs the results

on

Quoted 1 line
Quoted 1 line
Quoted 1 line

stdout as shell script, and that is being discarded. Looking at

the

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

commit that introduced it:

Looking at the codes in busybox (console-tools/resize.c), I can see that tcsetattr is actually called.
The output is due to:

Quoted 8 lines
Quoted 8 lines

if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
w.ws_col, w.ws_row);

I can confirm that calling 'resize' is needed. Otherwise, you might get input wrapping on the same line when typing long commands.

I just tried busybox init based system and I also met '-sh:

command:

Quoted 3 lines
Quoted 1 line

not found' error message.

Sorry for the noise. Just noticed that oe-core has enabled 'command'

for

Quoted 1 line

busybox by default. It's my own busybox defconfig that hasn't enabled

it.

I was just hit by the same. resize and tty work fine, but command applet is missing in my images.

Is enabling command applet in busybox now hard requirement for all the builds or is anyone still planing to send follow-up on this?

Quoted 6 lines

At least to show some more meaningful error when it's not available?

"you probably need to fix your busybox defconfig, because some old thread on oe-core ML says so"

Cheers,

Wow, here's an old discussion I had forgotten all about. I actually do have an updated version of the patch that solves the problem by running resize twice, once with stderr piped to /dev/null to determine if the resize command exists, and once without stderr piped to /dev/null to actually do the resize (since resize uses stderr to determine the size of the tty).

I'll send the updated patch in a minute.

Quoted 33 lines
Quoted 12 lines

Best Regards,
Chen Qi

Quoted 9 lines

I think Peter's patch ([OE-core] [PATCHv2 1/1] base-files: profile:
Avoid using "command" to determine if programs exist) is correct.

Best Regards,
Chen Qi

Quoted 3 lines

cc6360f4c4d9 (base-files: set dynamic COLUMNS via resize command)

that already has no effect whatsoever. See the man page for

resize:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

https://linux.die.net/man/1/resize

I also would consider running some program's output as shell

script a

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

bit spooky, it looks like a security hole waiting to be exploited.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Please consider the environment before printing this e-mail

--
Martin 'JaMa' Jansa jabber: [email protected]

//Peter

#12 lore raw

PATCH 1/1 base-files: profile: Get rid of "resize"

In reply to Burton, Ross

The "resize" command actually outputs shell commands to be executed, for example:

$ resize
COLUMNS=102;
LINES=27;
export COLUMNS LINES;

The output of "resize" is being discarded to /dev/null so the call has no effect whatsoever, and does not change the environment (it cannot change the environment of its parent). Remove the call and hence solve the messages about shells missing "command" or "tty" or "resize".

---
 meta/recipes-core/base-files/base-files/profile | 9 ---------
 1 file changed, 9 deletions(-)
meta/recipes-core/base-files/base-files/profile +0 -9
index a062028..cfd0d69 100644
@@ -20,15 +20,6 @@ if [ -d /etc/profile.d ]; then
 	unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-	# Make sure we are on a serial console (i.e. the device used starts with
-	# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
-	# tries do use ssh
-	case $(tty) in
-		/dev/tty[A-z]*) resize >/dev/null;;
-	esac
-fi
-
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
 
 umask 022
Signature · 1 line
1.9.1
#13 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 49 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Looijmans
Sent: den 18 september 2017 16:07
To: [email protected]
Cc: Mike Looijmans <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: [OE-core] [PATCH] base-files: profile: Get rid of "resize"

The "resize" command actually outputs shell commands to be executed, for example:

$ resize
COLUMNS=102;
LINES=27;
export COLUMNS LINES;

The output of "resize" is being discarded to /dev/null so the call has no effect whatsoever, and does not change the environment (it cannot change the environment of its parent). Remove the call and hence solve the messages about shells missing "command" or "tty" or "resize".

---
 meta/recipes-core/base-files/base-files/profile | 9 ---------
 1 file changed, 9 deletions(-)
meta/recipes-core/base-files/base-files/profile +0 -10
index a062028..cfd0d69 100644
@@ -20,15 +20,6 @@ if [ -d /etc/profile.d ]; then
 	unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-	# Make sure we are on a serial console (i.e. the device used starts with
-	# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
-	# tries do use ssh
-	case $(tty) in
-		/dev/tty[A-z]*) resize >/dev/null;;
-	esac
-fi
-
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
 
 umask 022
--
Quoted 1 line

1.9.1

Hold on. Looking at busybox' source code for resize, it seems that it actually does something besides outputting the shell code to set the variables (which is actually enabled by a separate feature called ENABLE_FEATURE_RESIZE_PRINT). It also calls ioctl(STDERR_FILENO, TIOCSWINSZ, &w) where w contains the calculated sizes.

However, I also just learnt that the busybox implementation of resize uses stderr to send control codes to move the cursor to find the tty sizes, which means that if one uses resize 2>/dev/null as my patch suggested, it does not work at all and just times out after three seconds.

What a mess...

//Peter

#14 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 51 lines · Peter Kjellerstedt
Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Looijmans
Sent: den 18 september 2017 16:07
To: [email protected]
Cc: Mike Looijmans <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: [OE-core] [PATCH] base-files: profile: Get rid of "resize"

The "resize" command actually outputs shell commands to be executed, for example:

Quoted 7 lines
$ resize
COLUMNS=102;
LINES=27;
export COLUMNS LINES;

The output of "resize" is being discarded to /dev/null so the call has no effect whatsoever, and does not change the environment (it cannot change

the

Review

Quoted 9 lines

environment of its parent). Remove the call and hence solve the messages about shells missing "command" or "tty" or "resize".

---
 meta/recipes-core/base-files/base-files/profile | 9 ---------
 1 file changed, 9 deletions(-)
(quoted diff) +0 -0

b/meta/recipes-core/base-files/base-files/profile

meta/recipes-core/base-files/base-files/profile if [ -d /etc/profile.d ]; then · line 24

Quoted 9 lines

index a062028..cfd0d69 100644

meta/recipes-core/base-files/base-files/profile +0 -2
@@ -20,15 +20,6 @@ if [ -d /etc/profile.d ]; then
      unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-     # Make sure we are on a serial console (i.e. the device used

starts with

meta/recipes-core/base-files/base-files/profile if [ -d /etc/profile.d ]; then · line 25

Quoted 1 line
meta/recipes-core/base-files/base-files/profile +0 -1
-     # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher

which

Quoted 8 lines
meta/recipes-core/base-files/base-files/profile +0 -6
-     # tries do use ssh
-     case $(tty) in
-             /dev/tty[A-z]*) resize >/dev/null;;
-     esac
-fi
-
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
 
Quoted 11 lines
Quoted 3 lines
meta/recipes-core/base-files/base-files/profile +0 -1
 umask 022
--

1.9.1

Hold on. Looking at busybox' source code for resize, it seems that it actually does something besides outputting the shell code to set the variables (which is actually enabled by a separate feature called ENABLE_FEATURE_RESIZE_PRINT). It also calls ioctl(STDERR_FILENO, TIOCSWINSZ, &w) where w contains the calculated sizes.

My knowledge of ANSI escapes is incredibly sketchy, but isn't that the code to *get* the size of the screen? Put the cursor at 999,999, then ask where it is?

Ross

#15 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 66 lines · Ross
Quoted 53 lines · Peter Kjellerstedt
Quoted 53 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Looijmans
Sent: den 18 september 2017 16:07
To: [email protected]
Cc: Mike Looijmans <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: [OE-core] [PATCH] base-files: profile: Get rid of "resize"

The "resize" command actually outputs shell commands to be executed, for example:

$ resize
COLUMNS=102;
LINES=27;
export COLUMNS LINES;

The output of "resize" is being discarded to /dev/null so the call has no
effect whatsoever, and does not change the environment (it cannot change the
environment of its parent). Remove the call and hence solve the messages about shells missing "command" or "tty" or "resize".

---
 meta/recipes-core/base-files/base-files/profile | 9 ---------
 1 file changed, 9 deletions(-)
meta/recipes-core/base-files/base-files/profile +0 -2
index a062028..cfd0d69 100644
@@ -20,15 +20,6 @@ if [ -d /etc/profile.d ]; then
      unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-     # Make sure we are on a serial console (i.e. the device used

starts with
- # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher
which

meta/recipes-core/base-files/base-files/profile +0 -6
-     # tries do use ssh
-     case $(tty) in
-             /dev/tty[A-z]*) resize >/dev/null;;
-     esac
-fi
-
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
Quoted 10 lines
Quoted 3 lines

umask 022
--
1.9.1

Hold on. Looking at busybox' source code for resize, it seems that it actually does something besides outputting the shell code to set the variables (which is actually enabled by a separate feature called ENABLE_FEATURE_RESIZE_PRINT). It also calls ioctl(STDERR_FILENO, TIOCSWINSZ, &w) where w contains the calculated sizes.

Quoted 3 lines

My knowledge of ANSI escapes is incredibly sketchy, but isn't that the code to *get* the size of the screen? Put the cursor at 999,999, then ask where it is?

The behaviour may have got broken with the various /etc/profile rewrites but it certainly did do something useful originally - it greatly improves usability for shells run on serial consoles. Please don't just remove it.

Quoted 8 lines

Ross

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#16 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 74 lines · Andre McCurdy
Quoted 6 lines · Ross
Quoted 4 lines · Peter Kjellerstedt
Quoted 4 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf

Of

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Mike Looijmans
Sent: den 18 september 2017 16:07
To: [email protected]
Cc: Mike Looijmans <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: [OE-core] [PATCH] base-files: profile: Get rid of "resize"

The "resize" command actually outputs shell commands to be executed,

for

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

example:

$ resize
COLUMNS=102;
LINES=27;
export COLUMNS LINES;

The output of "resize" is being discarded to /dev/null so the call has no
effect whatsoever, and does not change the environment (it cannot

change

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

the
environment of its parent). Remove the call and hence solve the

messages

Quoted 40 lines
Quoted 29 lines
Quoted 29 lines

about shells missing "command" or "tty" or "resize".

---
 meta/recipes-core/base-files/base-files/profile | 9 ---------
 1 file changed, 9 deletions(-)
meta/recipes-core/base-files/base-files/profile +0 -2
index a062028..cfd0d69 100644
@@ -20,15 +20,6 @@ if [ -d /etc/profile.d ]; then
      unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-     # Make sure we are on a serial console (i.e. the device used

starts with
- # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher
which

meta/recipes-core/base-files/base-files/profile +0 -6
-     # tries do use ssh
-     case $(tty) in
-             /dev/tty[A-z]*) resize >/dev/null;;
-     esac
-fi
-
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
Quoted 10 lines
Quoted 3 lines

umask 022
--
1.9.1

Hold on. Looking at busybox' source code for resize, it seems that it actually does something besides outputting the shell code to set the variables (which is actually enabled by a separate feature called ENABLE_FEATURE_RESIZE_PRINT). It also calls ioctl(STDERR_FILENO, TIOCSWINSZ, &w) where w contains the calculated sizes.

Quoted 1 line

My knowledge of ANSI escapes is incredibly sketchy, but isn't that the

code

Quoted 9 lines
Quoted 1 line

to *get* the size of the screen? Put the cursor at 999,999, then ask

where

Quoted 1 line

it is?

The behaviour may have got broken with the various /etc/profile rewrites but it certainly did do something useful originally - it greatly improves usability for shells run on serial consoles. Please don't just remove it.

The question is does it do something useful *now*?

Ross

#17 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 82 lines · Ross
Quoted 81 lines · Andre McCurdy
Quoted 77 lines · Ross
Quoted 59 lines · Peter Kjellerstedt
Quoted 59 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Mike Looijmans
Sent: den 18 september 2017 16:07
To: [email protected]
Cc: Mike Looijmans <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: [OE-core] [PATCH] base-files: profile: Get rid of "resize"

The "resize" command actually outputs shell commands to be executed, for
example:

$ resize
COLUMNS=102;
LINES=27;
export COLUMNS LINES;

The output of "resize" is being discarded to /dev/null so the call has
no
effect whatsoever, and does not change the environment (it cannot change
the
environment of its parent). Remove the call and hence solve the messages
about shells missing "command" or "tty" or "resize".

---
 meta/recipes-core/base-files/base-files/profile | 9 ---------
 1 file changed, 9 deletions(-)
meta/recipes-core/base-files/base-files/profile +0 -2
index a062028..cfd0d69 100644
@@ -20,15 +20,6 @@ if [ -d /etc/profile.d ]; then
      unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-     # Make sure we are on a serial console (i.e. the device used

starts with
- # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse
launcher
which

meta/recipes-core/base-files/base-files/profile +0 -6
-     # tries do use ssh
-     case $(tty) in
-             /dev/tty[A-z]*) resize >/dev/null;;
-     esac
-fi
-
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
Quoted 10 lines
Quoted 3 lines

umask 022
--
1.9.1

Hold on. Looking at busybox' source code for resize, it seems that it actually does something besides outputting the shell code to set the variables (which is actually enabled by a separate feature called ENABLE_FEATURE_RESIZE_PRINT). It also calls ioctl(STDERR_FILENO, TIOCSWINSZ, &w) where w contains the calculated sizes.

My knowledge of ANSI escapes is incredibly sketchy, but isn't that the code
to *get* the size of the screen? Put the cursor at 999,999, then ask where
it is?

Quoted 7 lines
Quoted 4 lines

The behaviour may have got broken with the various /etc/profile rewrites but it certainly did do something useful originally - it greatly improves usability for shells run on serial consoles. Please don't just remove it.

The question is does it do something useful *now*?

I don't have a board with a serial console to test at the moment. Busybox hasn't changed in recent memory though, so as long as the resize command does actually get run I presume it's still going to work.

Quoted 1 line

Ross

#18 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 7 lines · Andre McCurdy
Quoted 1 line

The question is does it do something useful *now*?

I don't have a board with a serial console to test at the moment. Busybox hasn't changed in recent memory though, so as long as the resize command does actually get run I presume it's still going to work.

Re-read the code. There's a call to ioctl with TIOCSWINSZ which I'm *guessing* is set window size. Google is not useful for this! It does all this on stderr.

So yes it *should* work, but not if you redirect stderr to /dev/null.

Yes, this is a mess. :)

Ross

#19 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 10 lines · Ross
Quoted 7 lines · Andre McCurdy
Quoted 2 lines

The question is does it do something useful *now*?

I don't have a board with a serial console to test at the moment. Busybox hasn't changed in recent memory though, so as long as the resize command does actually get run I presume it's still going to work.

Re-read the code.

I've never read the code before, so don't make any claims to know *how* it works or worked :-)

Quoted 5 lines

There's a call to ioctl with TIOCSWINSZ which I'm
*guessing* is set window size. Google is not useful for this! It does all this on stderr.

So yes it *should* work, but not if you redirect stderr to /dev/null.

We don't redirect stderr to /dev/null, only stdout.

Quoted 3 lines

Yes, this is a mess. :)

Ross

#20 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 17 lines · Andre McCurdy
Quoted 1 line · Ross

On 18 September 2017 at 20:01, Andre McCurdy <[email protected]>

Quoted 9 lines · wrote:
Quoted 7 lines
Quoted 2 lines

The question is does it do something useful *now*?

I don't have a board with a serial console to test at the moment. Busybox hasn't changed in recent memory though, so as long as the resize command does actually get run I presume it's still going to work.

Re-read the code.

I've never read the code before, so don't make any claims to know *how* it works or worked :-)

Quoted 8 lines
Quoted 2 lines

There's a call to ioctl with TIOCSWINSZ which I'm
*guessing* is set window size. Google is not useful for this! It does

all

Quoted 3 lines

this on stderr.

So yes it *should* work, but not if you redirect stderr to /dev/null.

We don't redirect stderr to /dev/null, only stdout.

One of the many patches here does.

I'm holding off applying any of them right now. :)

Ross

#21 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 11 lines · Ross
Quoted 7 lines
Quoted 5 lines

There's a call to ioctl with TIOCSWINSZ which I'm
*guessing* is set window size. Google is not useful for this! It does all this on stderr.

So yes it *should* work, but not if you redirect stderr to /dev/null.

We don't redirect stderr to /dev/null, only stdout.

One of the many patches here does.

I'm holding off applying any of them right now. :)

The "get rid of resize" patch seems to have made it into mut.

#22 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

I use resize quasi-regularly. Ever end up in the situation where you've run vim and now the command-line has no idea how large the console is, so everything wraps or scrolls at the wrong times/places? resize fixes that:

# . resize

Please don't remove it.

#23 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 9 lines · Trevor Woerner

I use resize quasi-regularly. Ever end up in the situation where you've run vim and now the command-line has no idea how large the console is, so everything wraps or scrolls at the wrong times/places? resize fixes that:

# . resize

Please don't remove it.

We're not removing the "resize" command itself. It's about removing something that started as a simple one-liner in /etc/profile to call "resize" (that did not fix the problem) and grew out to be a monster over time.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

#24 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

In reply to Andre McCurdy
Quoted 2 lines · Andre McCurdy

The "get rid of resize" patch seems to have made it into mut.

It was reverted at 8pm last night but I didn't push.

Ross

#25 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

In reply to Burton, Ross
Quoted 4 lines · Ross

On 18 September 2017 at 20:01, Andre McCurdy <[email protected] <mailto:[email protected]>> wrote:

> The question is does it do something useful *now*?

Quoted 8 lines

I don't have a board with a serial console to test at the moment. Busybox hasn't changed in recent memory though, so as long as the resize command does actually get run I presume it's still going to work.

Re-read the code. There's a call to ioctl with TIOCSWINSZ which I'm *guessing* is set window size. Google is not useful for this! It does all this on stderr.

Google on TIOCSWINSZ yields:
https://linux.die.net/man/4/tty_ioctl

TIOCSWINSZ
const struct winsize *argp
Set window size.

Of course, there is no explanation on what a "set window size" is supposed to accomplish on the terminal device.

Quoted 1 line

So yes it *should* work, but not if you redirect stderr to /dev/null.

Yep.

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

#26 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

In reply to Burton, Ross
Quoted 8 lines · Ross

On 18 September 2017 at 19:41, Andre McCurdy <[email protected] <mailto:[email protected]>> wrote:

    On Mon, Sep 18, 2017 at 8:17 AM, Burton, Ross <[email protected]
    <mailto:[email protected]>> wrote:
     > On 18 September 2017 at 16:07, Peter Kjellerstedt
     > <[email protected] <mailto:[email protected]>> wrote:
     >>
     >> > 

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com

Please consider the environment before printing this e-mail

-----Original Message-----

Quoted 71 lines

>> > From: [email protected]
<mailto:[email protected]>
>> > [mailto:[email protected]
<mailto:[email protected]>] On Behalf Of
>> > Mike Looijmans
>> > Sent: den 18 september 2017 16:07
>> > To: [email protected]
<mailto:[email protected]>
>> > Cc: Mike Looijmans <[email protected]
<mailto:[email protected]>>; Peter Kjellerstedt
>> > <[email protected] <mailto:[email protected]>> >> > Subject: [OE-core] [PATCH] base-files: profile: Get rid of "resize" >> >
>> > The "resize" command actually outputs shell commands to be executed, for >> > example:
>> >
>> > $ resize
>> > COLUMNS=102;
>> > LINES=27;
>> > export COLUMNS LINES;
>> >
>> > The output of "resize" is being discarded to /dev/null so the call has >> > no
>> > effect whatsoever, and does not change the environment (it cannot change >> > the
>> > environment of its parent). Remove the call and hence solve the messages >> > about shells missing "command" or "tty" or "resize".
>> >
>> > Signed-off-by: Mike Looijmans <[email protected]
<mailto:[email protected]>>
>> > ---
>> > meta/recipes-core/base-files/base-files/profile | 9 --------- >> > 1 file changed, 9 deletions(-)
>> >
>> > diff --git a/meta/recipes-core/base-files/base-files/profile >> > b/meta/recipes-core/base-files/base-files/profile
>> > index a062028..cfd0d69 100644
>> > --- a/meta/recipes-core/base-files/base-files/profile
>> > +++ b/meta/recipes-core/base-files/base-files/profile
>> > @@ -20,15 +20,6 @@ if [ -d /etc/profile.d ]; then
>> > unset i
>> > fi
>> >
>> > -if command -v resize >/dev/null && command -v tty >/dev/null; then
>> > - # Make sure we are on a serial console (i.e. the device used
>> > starts with
>> > - # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher
>> > which
>> > - # tries do use ssh
>> > - case $(tty) in
>> > - /dev/tty[A-z]*) resize >/dev/null;;
>> > - esac
>> > -fi
>> > -
>> > export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
>> >
>> > umask 022
>> > --
>> > 1.9.1
>>
>> Hold on. Looking at busybox' source code for resize, it seems that >> it actually does something besides outputting the shell code to >> set the variables (which is actually enabled by a separate feature >> called ENABLE_FEATURE_RESIZE_PRINT). It also calls
>> ioctl(STDERR_FILENO, TIOCSWINSZ, &w) where w contains the
>> calculated sizes.
>
> My knowledge of ANSI escapes is incredibly sketchy, but isn't that the code > to *get* the size of the screen? Put the cursor at 999,999, then ask where > it is?

Quoted 7 lines

The behaviour may have got broken with the various /etc/profile rewrites but it certainly did do something useful originally - it greatly improves usability for shells run on serial consoles. Please don't just remove it.

The question is does it do something useful *now*?

My experience is that it does not, and never has. I run serial consoles all the time, and if they're not sized to 80x25 weird stuff happens.

Start vi on a serial terminal and it only uses the top 80x25. If a command exceed the 80 char mark, the cursor goes all weird. Running "eval resize" fixes that (until you resize the window). Running just "resize" does not have any effect on that at all.

Cannot we determine the presence of "tty" and "resize" commands at compile time? something like:

if has_command("tty") and has_command("resize"):

    install -m 755 ${S}/resize.sh ${D}${sysconfdir}/profile.d/
#27 lore raw

Re: [PATCH] base-files: profile: Get rid of "resize"

Quoted 8 lines · Mike Looijmans

My experience is that it does not, and never has. I run serial consoles all the time, and if they're not sized to 80x25 weird stuff happens.

Start vi on a serial terminal and it only uses the top 80x25. If a command exceed the 80 char mark, the cursor goes all weird.
Running "eval resize" fixes that (until you resize the window). Running just "resize" does not have any effect on that at all.

Quoted 5 lines

Cannot we determine the presence of "tty" and "resize" commands at compile time? something like:

if has_command("tty") and has_command("resize"):

    install -m 755 ${S}/resize.sh ${D}${sysconfdir}/profile.d/

As part of busybox, yes. Not anywhere else though.

Ross

#28 lore raw

✗ patchtest: failure for "base-files: profile: Do not as..." and 1 more (rev2)

In reply to Mike Looijmans

== Series Details ==

Series: "base-files: profile: Do not as..." and 1 more (rev2)
Revision: 2
URL : https://patchwork.openembedded.org/series/8967/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at cbc396dd10)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe