[systemd-devel] controlling serial console using a token

Andrei Borzenkov arvidjaar at gmail.com
Mon Apr 20 03:06:17 PDT 2015


On Mon, Apr 20, 2015 at 7:15 AM, Praveen kumar R
<praveenrgowda at gmail.com> wrote:
> You mean in the getty-generator.c ?
>
>

I actually mean your own customer generator.

> On Mon, Apr 20, 2015 at 9:14 AM, Andrei Borzenkov <arvidjaar at gmail.com>
> wrote:
>>
>> В Mon, 20 Apr 2015 09:09:09 +0530
>> Praveen kumar R <praveenrgowda at gmail.com> пишет:
>>
>> > This is the snippet of the code in the systemV init system that controls
>> > the serial console login
>> > depending on the token
>> >
>> >  TOKENEXIST=`grep "TOKEN=" /proc/cmdline`
>> >     TOKEN=0
>> >     if [ "X$TOKENEXIST" != "X" ]; then
>> >            #If token is pass as a command line arg, use it.
>> >            TOKEN=`sed 's/.*TOKEN=//; s/ .*//' /proc/cmdline`
>> >     fi
>> >
>> >     TOKENOVERRIDE=`grep "TOKENOVERRIDE=" /proc/cmdline`
>> >     if [ "X$TOKENOVERRIDE" != "X" ]; then
>> >            #If token is pass as a command line arg, use it.
>> >            OVERRIDE=`sed 's/.*TOKENOVERRIDE=//; s/ .*//' /proc/cmdline`
>> >            let "TOKEN = $TOKEN & $OVERRIDE"
>> >     fi
>> >
>> >     echo "TOKEN = $TOKEN"
>> >
>> >     let "CONSOLE_LOGIN = $TOKEN & 512"
>> >     if [ $CONSOLE_LOGIN -ne 0 ];  then
>> >         echo "[`eval $uptime`]: Begin Console Access"
>> >         /etc/console_login &
>> >         echo "eCM console is enabled"
>> >         export ENABLE_ECM_CONSOLE=y
>> >     else
>> >         echo "[`eval $uptime`]: Token doesn't allow console access"
>> >         export ENABLE_ECM_CONSOLE=n
>> >     fi
>> >
>> >
>> >
>> > I am trying to implement the same in the sytemd init system.
>> >
>>
>> The straightforward approach is to put this code in generator that
>> parses command line. It can mask standard console service and create
>> unit for your console.
>>
>> >
>> > On Sun, Apr 19, 2015 at 11:48 AM, Andrei Borzenkov <arvidjaar at gmail.com>
>> > wrote:
>> >
>> > > В Sat, 18 Apr 2015 19:54:50 +0530
>> > > Praveen kumar R <praveenrgowda at gmail.com> пишет:
>> > >
>> > > > Yes it's a kernel command line arg, it is board specific token
>> > > > introduced
>> > > > to control the serial console.
>> > > > if defined serial console should not be enabled.
>> > > >
>> > >
>> > > Sorry I do not understand this sentence. "define" what? Please give
>> > > exact example of kernel command line and explain what behavior you
>> > > expect in this case.
>> > >
>> > > > we have this in place for other system initializing system - sytemV
>> > > > ,
>> > > where
>> > > > depending
>> > > >
>> > > > On Fri, Apr 17, 2015 at 4:24 PM, Lennart Poettering <
>> > > lennart at poettering.net
>> > > > <javascript:_e(%7B%7D,'cvml','lennart at poettering.net');>> wrote:
>> > > >
>> > > > > On Fri, 17.04.15 15:54, Praveen kumar R (praveenrgowda at gmail.com
>> > > > > <javascript:_e(%7B%7D,'cvml','praveenrgowda at gmail.com');>) wrote:
>> > > > >
>> > > > > > I have a token passed on by command line argument on which I
>> > > > > > need to
>> > > > > decide
>> > > > > > to start the serial
>> > > > >
>> > > > > On which command line? Kernel command line? What kind of "token"?
>> > > > >
>> > > > > > console or not. I plan to tweak the getty*ttyS0.service and add
>> > > > > > the
>> > > > > > script which validates the token and starts the console.
>> > > > > >
>> > > > > > Is this the right approach or is there any better way of
>> > > > > > handling it
>> > > ??
>> > > > >
>> > > > > To get a login getty on the serial port its sufficient to add
>> > > > > console=ttyS0... to the kernel cmdline. systemd automatically
>> > > > > starts a
>> > > > > serial getty automatically on the first terminal the kernel
>> > > > > console is
>> > > > > pointing to.
>> > > > >
>> > > > > Lennart
>> > > > >
>> > > > > --
>> > > > > Lennart Poettering, Red Hat
>> > > > >
>> > >
>> > >
>>
>


More information about the systemd-devel mailing list