Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v2] sysvinit-inittab: support non-busybox-getty on serial consoles
@ 2019-02-08 16:48 André Draszik
  2019-02-08 17:46 ` Andreas Oberritter
  0 siblings, 1 reply; 3+ messages in thread
From: André Draszik @ 2019-02-08 16:48 UTC (permalink / raw)
  To: openembedded-core

From: André Draszik <andre.draszik@jci.com>

Busybox' getty has code to try to make itself a session leader,
whereas util-linux' agetty doesn't. It expects this to happen
from outside.
When getty is not a session leader, many things don't work on
the serial console, e.g. setting the terminal process group,
job control doesn't work, etc.

Executing image tests also fails with AssertionErrors, because
    Feb  5 16:12:55 qemuarm getty[590]: /dev/ttyAMA1: cannot get controlling tty: Operation not permitted
    Feb  5 16:12:55 qemuarm getty[590]: /dev/ttyAMA1: cannot set process group: Inappropriate ioctl for device

Update the start_getty script to invoke getty via the setsid
utility if needed, i.e. if /sbin/getty is not busybox getty.

[YOCTO #13058]

Signed-off-by: André Draszik <andre.draszik@jci.com>

---
v2: fork fewer processes
---
 .../sysvinit/sysvinit-inittab/start_getty          | 14 +++++++++++++-
 .../sysvinit/sysvinit-inittab_2.88dsf.bb           |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
index e15ae35f90..d3ebb84e18 100644
--- a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
+++ b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
@@ -13,6 +13,18 @@ active_serial=$(grep "serial" /proc/tty/drivers | cut -d/ -f1 | sed "s/ *$//")
 # Rephrase input parameter from ttyS target index (ttyS1, ttyS2, ttyAMA0, etc).
 runtime_tty=$(echo $2 | grep -oh '[0-9]')
 
+# busybox' getty does this itself, util-linux' agetty needs extra help
+getty="/sbin/getty"
+case $(readlink -f "${getty}") in
+    */busybox*)
+        ;;
+    *)
+        if [ -x "/usr/bin/setsid" ] ; then
+            getty="/usr/bin/setsid ${getty}"
+        fi
+        ;;
+esac
+
 # Backup $IFS.
 DEFAULT_IFS=$IFS
 # Customize Internal Field Separator.
@@ -31,7 +43,7 @@ for line in $active_serial; do
 			then
 				if [ -c /dev/$2 ]
 				then
-				    /sbin/getty -L $1 $2 $3
+				    eval ${getty} -L $1 $2 $3
 				fi
 				break
 			fi
diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb b/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb
index 8585a418ab..bfd890d924 100644
--- a/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb
+++ b/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb
@@ -20,6 +20,7 @@ do_install() {
     install -m 0644 ${WORKDIR}/inittab ${D}${sysconfdir}/inittab
     install -d ${D}${base_bindir}
     install -m 0755 ${WORKDIR}/start_getty ${D}${base_bindir}/start_getty
+    sed -e 's,/usr/bin,${bindir},g' -i ${D}${base_bindir}/start_getty
 
     set -x
     tmp="${SERIAL_CONSOLES}"
-- 
2.20.1



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

* Re: [PATCH v2] sysvinit-inittab: support non-busybox-getty on serial consoles
  2019-02-08 16:48 [PATCH v2] sysvinit-inittab: support non-busybox-getty on serial consoles André Draszik
@ 2019-02-08 17:46 ` Andreas Oberritter
  2019-02-11 11:23   ` André Draszik
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Oberritter @ 2019-02-08 17:46 UTC (permalink / raw)
  To: André Draszik; +Cc: openembedded-core

Hi André,

On Fri,  8 Feb 2019 16:48:32 +0000
André Draszik <git@andred.net> wrote:

> From: André Draszik <andre.draszik@jci.com>
> 
> Busybox' getty has code to try to make itself a session leader,
> whereas util-linux' agetty doesn't. It expects this to happen
> from outside.
> When getty is not a session leader, many things don't work on
> the serial console, e.g. setting the terminal process group,
> job control doesn't work, etc.
> 
> Executing image tests also fails with AssertionErrors, because
>     Feb  5 16:12:55 qemuarm getty[590]: /dev/ttyAMA1: cannot get controlling tty: Operation not permitted
>     Feb  5 16:12:55 qemuarm getty[590]: /dev/ttyAMA1: cannot set process group: Inappropriate ioctl for device
> 
> Update the start_getty script to invoke getty via the setsid
> utility if needed, i.e. if /sbin/getty is not busybox getty.
> 
> [YOCTO #13058]
> 
> Signed-off-by: André Draszik <andre.draszik@jci.com>
> 
> ---
> v2: fork fewer processes
> ---
>  .../sysvinit/sysvinit-inittab/start_getty          | 14 +++++++++++++-
>  .../sysvinit/sysvinit-inittab_2.88dsf.bb           |  1 +
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
> index e15ae35f90..d3ebb84e18 100644
> --- a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
> +++ b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
> @@ -13,6 +13,18 @@ active_serial=$(grep "serial" /proc/tty/drivers | cut -d/ -f1 | sed "s/ *$//")
>  # Rephrase input parameter from ttyS target index (ttyS1, ttyS2, ttyAMA0, etc).
>  runtime_tty=$(echo $2 | grep -oh '[0-9]')
>  
> +# busybox' getty does this itself, util-linux' agetty needs extra help
> +getty="/sbin/getty"
> +case $(readlink -f "${getty}") in
> +    */busybox*)
> +        ;;
> +    *)
> +        if [ -x "/usr/bin/setsid" ] ; then
> +            getty="/usr/bin/setsid ${getty}"
> +        fi
> +        ;;
> +esac
> +
>  # Backup $IFS.
>  DEFAULT_IFS=$IFS
>  # Customize Internal Field Separator.
> @@ -31,7 +43,7 @@ for line in $active_serial; do
>  			then
>  				if [ -c /dev/$2 ]
>  				then
> -				    /sbin/getty -L $1 $2 $3
> +				    eval ${getty} -L $1 $2 $3

I think using eval isn't necessary.

Best regards,
Andreas


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

* Re: [PATCH v2] sysvinit-inittab: support non-busybox-getty on serial consoles
  2019-02-08 17:46 ` Andreas Oberritter
@ 2019-02-11 11:23   ` André Draszik
  0 siblings, 0 replies; 3+ messages in thread
From: André Draszik @ 2019-02-11 11:23 UTC (permalink / raw)
  To: Andreas Oberritter; +Cc: openembedded-core

On Fri, 2019-02-08 at 18:46 +0100, Andreas Oberritter wrote:
> Hi André,
> 
> On Fri,  8 Feb 2019 16:48:32 +0000
> André Draszik <git@andred.net> wrote:
> 
> > From: André Draszik <andre.draszik@jci.com>
> > 
> > Busybox' getty has code to try to make itself a session leader,
> > whereas util-linux' agetty doesn't. It expects this to happen
> > from outside.
> > When getty is not a session leader, many things don't work on
> > the serial console, e.g. setting the terminal process group,
> > job control doesn't work, etc.
> > 
> > Executing image tests also fails with AssertionErrors, because
> >     Feb  5 16:12:55 qemuarm getty[590]: /dev/ttyAMA1: cannot get
> > controlling tty: Operation not permitted
> >     Feb  5 16:12:55 qemuarm getty[590]: /dev/ttyAMA1: cannot set process
> > group: Inappropriate ioctl for device
> > 
> > Update the start_getty script to invoke getty via the setsid
> > utility if needed, i.e. if /sbin/getty is not busybox getty.
> > 
> > [YOCTO #13058]
> > 
> > Signed-off-by: André Draszik <andre.draszik@jci.com>
> > 
> > ---
> > v2: fork fewer processes
> > ---
> >  .../sysvinit/sysvinit-inittab/start_getty          | 14 +++++++++++++-
> >  .../sysvinit/sysvinit-inittab_2.88dsf.bb           |  1 +
> >  2 files changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
> > b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
> > index e15ae35f90..d3ebb84e18 100644
> > --- a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
> > +++ b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty
> > @@ -13,6 +13,18 @@ active_serial=$(grep "serial" /proc/tty/drivers | cut
> > -d/ -f1 | sed "s/ *$//")
> >  # Rephrase input parameter from ttyS target index (ttyS1, ttyS2,
> > ttyAMA0, etc).
> >  runtime_tty=$(echo $2 | grep -oh '[0-9]')
> >  
> > +# busybox' getty does this itself, util-linux' agetty needs extra help
> > +getty="/sbin/getty"
> > +case $(readlink -f "${getty}") in
> > +    */busybox*)
> > +        ;;
> > +    *)
> > +        if [ -x "/usr/bin/setsid" ] ; then
> > +            getty="/usr/bin/setsid ${getty}"
> > +        fi
> > +        ;;
> > +esac
> > +
> >  # Backup $IFS.
> >  DEFAULT_IFS=$IFS
> >  # Customize Internal Field Separator.
> > @@ -31,7 +43,7 @@ for line in $active_serial; do
> >  			then
> >  				if [ -c /dev/$2 ]
> >  				then
> > -				    /sbin/getty -L $1 $2 $3
> > +				    eval ${getty} -L $1 $2 $3
> 
> I think using eval isn't necessary.

I didn't investigate why, but it was necessary in this version for whatever
reason - v3 got rid of it now by adding another variable.

Cheers,
Andre'

> 
> Best regards,
> Andreas



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

end of thread, other threads:[~2019-02-11 11:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-08 16:48 [PATCH v2] sysvinit-inittab: support non-busybox-getty on serial consoles André Draszik
2019-02-08 17:46 ` Andreas Oberritter
2019-02-11 11:23   ` André Draszik

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