* Re: Finding out LAT source name
1995-01-10 19:40 Finding out LAT source name Brian 'Doc' O'Neill
@ 1995-01-11 19:22 ` Sam Eads
1995-01-12 3:11 ` Scott Ruch
1 sibling, 0 replies; 3+ messages in thread
From: Sam Eads @ 1995-01-11 19:22 UTC (permalink / raw)
In article <3eunql$n3q@ulowell.uml.edu>, oneill@cs.uml.edu (Brian 'Doc' O'Neill) says:
>
>I'm in the process of porting some shadow password stuff (John F. Haugh II's
>implementation) to OSF/1 V3.0 on the Alpha, and noticed that by default
>OSF/1 doesn't log the source LAT host when a person logs in, nor can I find
>the routines which can get them which were under Ultrix. Does anyone know
>how to determine the source host under OSF/1??
>
>===========================================================================
>Brian O'Neill - Systems Manager, Computer Science oneill@cs.uml.edu
>University of Massachusetts at Lowell Chief Editor, InterWeb Journal
>(508) 934-3645 http://interweb.uml.edu/InterWeb/
>"Nothing's the same anymore." - Sinclair, Babylon 5, _Chrysalis_
Brian,
Listed below is an example program of how to get the information you
need. I haven't figured out if there's any way to get the destination
service name. You might want that if you had more than one service
defined on the system and wanted to know which one a user had connected
to. I originally got parts of this example from DEC through DSNLink, so
I guess I should give them some credit too. (The DSNLink people are
sometimes VERY helpful). As far as I know, this stuff isn't documented
anywhere.
ALSO NOTE: Since LAT was completely re-implemented in OSF/1 V3.0, you
have to use different code for OSF/1 V2.0. THIS CODE WILL ONLY WORK
FOR V3.0 OSF/1. I have the 2.0 code if anyone needs it.
Hope this helps.
Here's the code :
/*
** Get LAT connection information
**
** This code is for OSF/1 V3.0 ONLY
**
** Written by someone at Digital Equipment Corporation
**
** Adapted by Sam Eads (HBO & Company, Atlanta, GA, U.S.A)
*/
#include <stropts.h>
#include <lat/streams/latioc.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
struct stat statb;
main(agc,arg)
int agc;
char **arg;
{
int tfd;
lats_info latioctl_port;
struct strioctl strioctl;
tfd = open("/dev/streams/lat",O_RDWR);
if(tfd < 0) {
perror("openning /dev/streams/lat");
exit(0);
}
if(fstat(0,&statb) < 0) {
perror("stating fd 0");
exit(0);
}
bzero(&latioctl_port,sizeof(lats_info));
latioctl_port.info_dev = minor(statb.st_rdev);
strioctl.ic_cmd = LIOC_INFO_SHOW;
strioctl.ic_len = sizeof(lats_info);
strioctl.ic_dp = (char *)&latioctl_port;
if(ioctl(tfd,I_STR,&strioctl) < 0) {
perror("on latioctl call");
exit(0);
}
close(tfd);
printf("lcl_svc=%s\n",latioctl_port.lcl_service);
printf("lcl_por=%s\n",latioctl_port.lcl_port);
printf("rmt_svc=%s\n",latioctl_port.rmt_service);
printf("rmt_por=%s\n",latioctl_port.rmt_port);
printf("rmt_ond=%s\n",latioctl_port.rmt_node);
}
Sam Eads
Sr. Systems Programmer
HBO & Company, Inc.
Atlanta, GA USA
Email: sam.eads@hboc.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Finding out LAT source name
1995-01-10 19:40 Finding out LAT source name Brian 'Doc' O'Neill
1995-01-11 19:22 ` Sam Eads
@ 1995-01-12 3:11 ` Scott Ruch
1 sibling, 0 replies; 3+ messages in thread
From: Scott Ruch @ 1995-01-12 3:11 UTC (permalink / raw)
Brian 'Doc' O'Neill (oneill@cs.uml.edu) wrote:
: I'm in the process of porting some shadow password stuff (John F. Haugh II's
: implementation) to OSF/1 V3.0 on the Alpha, and noticed that by default
: OSF/1 doesn't log the source LAT host when a person logs in, nor can I find
: the routines which can get them which were under Ultrix. Does anyone know
: how to determine the source host under OSF/1??
The following example program does what you want and more. Note that in
V3.2, the LAT server / port is now saved in utmp/wtmp by the login process.
For other useful examples, check /usr/examples/lat/.
/*
* For LAT on DEC OSF/1 V3.0 and later.
*
* The following code can be used to determine what the server and port names
* are for incoming LAT connections as well as host-initiated connections
* (application ports).
*
* The program takes a LAT tty as an argument 'show_port tty' and displays
* the info for that tty. The functionality here is very similar to the
* 'latcp -d -P -p' command.
*/
#include <stropts.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <lat/streams/latioc.h>
main(argc, argv)
int argc;
char **argv;
{
int fd;
char tty[80];
struct stat statbuf;
lats_info port;
struct strioctl strioctl;
if (argc < 2) {
printf("Usage: show_port tty\n");
exit(-1);
}
if ( (fd = open("/dev/streams/lat", 2)) < 0 ) {
perror("/dev/streams/lat");
exit(-1);
}
bzero(&port, sizeof(lats_info));
bzero(&statbuf, sizeof(statbuf));
bzero(tty, 80);
if ( strncmp(argv[1], "tty", 3) == 0 )
strcpy(tty, "/dev/"); /* BSD style LAT tty = /dev/ttyWX */
else
strcpy(tty, "/dev/lat/"); /* SVR4 style LAT tty = /dev/lat/nnn */
strcat(tty, argv[1]);
if (stat(tty, &statbuf) < 0) {
perror(tty);
exit(-1);
}
port.info_dev = minor(statbuf.st_rdev);
bzero(&strioctl, sizeof(struct strioctl));
strioctl.ic_cmd = LIOC_INFO_SHOW;
strioctl.ic_len = sizeof(lats_info);
strioctl.ic_dp = (char *)&port;
if (ioctl(fd, I_STR, &strioctl) < 0) {
printf("LIOC_INFO_SHOW ioctl failed. errno=%d.\n",errno);
exit(2);
}
printf("\nLocal Port Name = %s", tty);
if (port.info_type == INFO_TOUCH_HIC)
printf(" <application>\n");
else
printf(" <interactive>\n");
if ( port.info_status == INFO_STS_IDLE )
printf("\tPort not active\n");
if (port.rmt_node[0] != NULL)
printf("\tRemote Node Name = %s\n", port.rmt_node);
if (port.rmt_port[0] != NULL)
printf("\tRemote Port Name = %s\n", port.rmt_port);
if (port.rmt_service[0] != NULL)
printf("\tRemote Service Name = %s\n", port.rmt_service);
if (port.lcl_service[0] != NULL)
printf("\tLocal Service Name = %s\n", port.lcl_service);
}
--
------------------------------------------------------------------
Scott Ruch Unix Systems Group
DEC OSF/1 LAT Engineering
Digital Equipment Corp. |d|i|g|i|t|a|l|
200 US Rt. 9 North swr@unx.dec.com
Manalapan, NJ 07726-9455 (908) 577-6082
Monmouth College
Dept. of Software Engineering r4009@ignatz.monmouth.edu
------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread