From: deal@xi.cs.fsu.edu (Richard Deal)
Subject: Re: How to change the login message
Date: 9 Nov 1994 13:51:36 GMT [thread overview]
Message-ID: <39qk58$oh5@mailer.fsu.edu> (raw)
In-Reply-To: 39nv4r$e94@mailer.fsu.edu
Richard Deal (deal@xi.cs.fsu.edu) wrote:
: Dan Cambron (rp3418@email.sps.mot.com) wrote:
: : What's the secret to changing the login message when someone comes in
: : to a machine via telnet, rlogin, etc. ultrix used the gettytab file, what's the
: : equivalent method in OSF?
: : thanks,
: : dan
: Dan,
: What I do is have a wrapper around the telnet daemon that first spits out
: the /etc/issue file (since most, if not all, SVR4 machines don't print it
: out on network connections) and then execs the telnet daemon. If you're
: interested, I could send you the code...only about 20-40 lines in length.
: Richard
: deal@cs.fsu.edu
Due to overwhelming demand, here's my telnet wrapper script to print out the
etc issue file upon login. Note that we use it with TIS's firewall toolkit
in this example...it execs their netacl program...just replace this with
in.telnetd (or the appropriate name of your telnet daemon).
I originally got it from a post on the net...don't know from who...but I've
had to modify it to handle I/O appropriately (newlines, etc.).
Enjoy!
CUT HERE
------------------------------------------------------------
/* Just some standard header file includes */
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
/* This program is called from ined, a direct replacement */
/* for the telnetd entry (though it uses telnetd) */
/* It is assumed that inetd has properly set the socket to */
/* file descriptors 0 and 1 (stdin and stdout) */
/* put the name of this file in the inetd.conf file for */
/* telnet...note that we use TIS's firewall toolkit so we */
/* exec their telnet wrapper...if you're not running this, */
/* just exec in.telnetd */
#define OUT 1
main(int argc, char *argv[])
{
int fd;
char out[3];
char tmp;
FILE *output;
/* init our working space */
out[2] = '\000';
/* open up the /etc/issue file as read-only */
fd = open("/etc/issue", O_RDONLY);
/* this complex-looking while loop tries to emulate the */
/* way /etc/issue is read by the getty process. I have */
/* not looked at the getty code, so I have no idea if */
/* all it's functionality is present here. Basically */
/* what this hack allows you to do is to print just */
/* any character that can be represented in escape */
/* format - though it's a little different than standard*/
/* `C'. Format is \xx where xx is a decimal number. */
/* Note: to print the `\` character, you need to */
/* represent it as `\92` */
while(read(fd, &tmp, 1))
{
if(tmp=='\\')
{
read(fd, &out[0], 1);
if( !isdigit(out[0]) )
{
tmp = out[0];
}
else
{
read(fd, &out[1], 1);
if( !isdigit(out[1]) )
{
tmp = out[1];
}
else
{
tmp = atoi(out);
}
}
}
if (tmp != '\12')
putchar(tmp);
else
{
putchar(tmp);
putchar('\15');
}
}
/* close the /etc/issue file */
close(fd);
/* the following forces the text read in from the issue file */
/* to be flushed out thruogh the open socke file descriptor */
/* Why did I do it with a fork()? Well, this way seemed to */
/* work the best - doing a manual buffer flush did not produce */
/* the proper results. I tried several methods - it looks like */
/* there may be some strange buffering problems with sockets. */
/* This is not particular to Linux, I had exactly the same */
/* problems with DEC Ultrix. */
if(!fork())
{
/* start up the telnet daemon */
/* execv("/etc/inet/telnetd", argv); */
/* execv("/usr/etc/in.telnetd", argv); */
execl ("/usr/local/etc/netacl", "in.telnetd", (char *)0);
/*
int execl (const char *path, const char *arg0, ..., const
char *argn, (char *)0);
*/
}
}
------------------------------------------------------
END
prev parent reply other threads:[~1994-11-09 13:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-08 0:35 How to change the login message Dan Cambron
1994-11-08 13:40 ` Anthony D. Wood
1994-11-08 13:40 ` Richard Deal
1994-11-09 13:51 ` Richard Deal [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox