Discussion:
How does pppd know the device when invoked from mgetty?
(too old to reply)
Christopher Nelson
2006-04-21 17:42:31 UTC
Permalink
I have an login.config for mgetty that includes:

/AutoPPP/ - a_ppp /etc/ppp/ppplogin

where ppplogin says:

#!/bin/sh
stty -echo
/usr/sbin/pppd silent auth -chap +pap login

I assume that when invoked this way, pppd will read /etc/ppp/options
but how does it -- or does it? -- know the device it's being invoked
for? If I said:

pppd ... ttyS00

I'd expect it to process /etc/ppp/options.ttyS00. When invoked from
ppplogin, there seems to be no device so I don't know quite what to
expect. Is there something about being invoked from mgetty that lets
it know what device it's on?

Chris
tkvoice
2006-04-21 19:29:24 UTC
Permalink
Because the device is passed to mgetty as an arguement from your
/etc/inittab:

s2:2345:respawn:/usr/local/sbin/mgetty -x 4 -n 2 /dev/ttyS6
Christopher Nelson
2006-04-21 19:39:04 UTC
Permalink
Post by tkvoice
Because the device is passed to mgetty as an arguement from your
s2:2345:respawn:/usr/local/sbin/mgetty -x 4 -n 2 /dev/ttyS6
I know where it comes from, what I wondered is how it gets to pppd. I
can't find anything that says, "When mgetty invokes the login program,
it adds the device as an additional argunment" or "pppd gets the device
from the FOO environment variable if not specified on the command line."
Gert Doering
2006-04-21 20:35:59 UTC
Permalink
Hi,
Post by Christopher Nelson
I know where it comes from, what I wondered is how it gets to pppd. I
can't find anything that says, "When mgetty invokes the login program,
it adds the device as an additional argunment" or "pppd gets the device
from the FOO environment variable if not specified on the command line."
It's in the environment variable $DEVICE, and programs can always call
ttyname(0) to find out which device they are connected to.

Now, whether pppd does any of this is unknown to me - $DEVICE is not
something standardized, so quite likely "not". ttyname() is a libc
standard function.

gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany ***@greenie.muc.de
fax: +49-89-35655025 ***@net.informatik.tu-muenchen.de

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Unruh
2006-04-22 03:06:51 UTC
Permalink
Post by Christopher Nelson
Post by tkvoice
Because the device is passed to mgetty as an arguement from your
s2:2345:respawn:/usr/local/sbin/mgetty -x 4 -n 2 /dev/ttyS6
I know where it comes from, what I wondered is how it gets to pppd. I
can't find anything that says, "When mgetty invokes the login program,
it adds the device as an additional argunment" or "pppd gets the device
from the FOO environment variable if not specified on the command line."
if (!isatty(0) || (p = ttyname(0)) == NULL)

man ttyname
DESCRIPTION
The function ttyname() returns a pointer to the NUL-terminated pathname
of the terminal device that is open on the file descriptor fd, or NULL
on error (for example, if fd is not connected to a terminal). The
return value may point to static data, possibly overwritten by the next
Unruh
2006-04-22 02:56:27 UTC
Permalink
Post by Christopher Nelson
/AutoPPP/ - a_ppp /etc/ppp/ppplogin
#!/bin/sh
stty -echo
/usr/sbin/pppd silent auth -chap +pap login
I assume that when invoked this way, pppd will read /etc/ppp/options
but how does it -- or does it? -- know the device it's being invoked
Because mgetty opens the file with the terminal as the stdin and stdout,
and that is what pppd uses.
Post by Christopher Nelson
pppd ... ttyS00
I'd expect it to process /etc/ppp/options.ttyS00. When invoked from
ppplogin, there seems to be no device so I don't know quite what to
expect. Is there something about being invoked from mgetty that lets
it know what device it's on?
iIt reads /etc/ppp/options. I do not think it reads /etc/ppp/options.ttyS0
Post by Christopher Nelson
Chris
James Carlson
2006-04-25 11:58:28 UTC
Permalink
Post by Unruh
Post by Christopher Nelson
I'd expect it to process /etc/ppp/options.ttyS00. When invoked from
ppplogin, there seems to be no device so I don't know quite what to
expect. Is there something about being invoked from mgetty that lets
it know what device it's on?
iIt reads /etc/ppp/options. I do not think it reads /etc/ppp/options.ttyS0
If the /etc/ppp/options.<ttyname> file is present, then it's _also_
read, and the options contained inside are treated as "privileged,"
even if the invoking user is not. (This is true for /etc/ppp/options,
/etc/ppp/options.<ttyname>, and /etc/ppp/peers/<callname>.)
--
James Carlson, KISS Network <***@sun.com>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677
Loading...