[net.sources] Dialup: a simpler way to call other computers via cu

blm@chinet.UUCP (Brad L. McKinley) (01/12/86)

Since I have a terrible memory for which phone number goes to which
database and which login name goes with which password I made a
crutch.  dialup allows a user to remember only the service name.
It then looks in a simple database in the user's home directory for
the dialing information and places the call via cu(1).  It will also
list the login name and password for the service unless supressed
with the '-s' option.

Enjoy,

Brad McKinley
M D R Professional Software, Inc.
915 S.W. 3rd Ave
Ontario, Oregon 97914
(503) 889-4321

"God invented Arrakis to train the faithful."
--------------- cut here ---------------
: shar archive -- dialup -- 1/10/85
: Brad L. McKinley -- 503-889-4321
: M D R Professional Software Inc.
: 915 SW 3rd Avenue
: Ontario, Oregon 97914
:
echo "creating Makefile"
sed 's/^X//' > Makefile << E_O_F
X#
X#  This is the MAKEFILE that work on my machine (TRS-80 Model 16 running
X#  XENIX).  Check to see if they're correct for yours.  Don't forget to
X#  turn the leading spaces into tabs!!!
X#
X
XBINARY = /mdr/bin/dialup
X
XOBJECTS = main.o get_service.o
X
XLIBRARIES = -lc
X
XCFLAGS = -O
X
XLDFLAGS = -n -s -x
X
X$(BINARY): $(OBJECTS)
X	@echo loading $(BINARY)
X	@ld -o $(BINARY) $(LDFLAGS) /lib/crt0.o $(OBJECTS) $(LIBRARIES)
X	@chmod 771 $(BINARY)
E_O_F
echo "creating main.c"
sed 's/^X//' > main.c << E_O_F
X#include <signal.h>
X#include <stdio.h>
X
X#define   USAGE     "usage: dialup [-s] service.\n"
X
Xchar service[40],
X     phone[20],
X     baud[10],
X     login[20],
X     password[20];
Xmain(argc, argv)
Xint  argc;
Xchar *argv[];
X{
X     int  silent = 0;
X     char name[21];
X
X     signal(SIGINT,  SIG_DFL);      /* I need this at my location */
X     signal(SIGQUIT, SIG_DFL);      /* I don't know about the rest of you */
X
X     switch (argc) {
X
X     case 1:
X          printf("\nEnter network name: ");
X          scanf("%20s", name);
X          break;
X
X     case 2:
X          strncpy(name, argv[1], 21);
X          break;
X
X     case 3:
X          if (strcmp(argv[1], "-s") == 0) {
X               silent = 1;
X               strncpy(name, argv[2], 21);
X          }
X          else {
X               fprintf(stderr, USAGE);
X               exit(1);
X          }
X          break;
X
X     default:
X          fprintf(stderr, USAGE);
X          exit(1);
X          break;
X     }
X
X     get_service(name);
X
X     printf("\n");
X     printf("Service : %s\n", service);
X     if (!silent) {
X          printf("Phone # : %s\n", phone);
X          printf("Baud    : %s\n", baud);
X          printf("Login   : %s\n", login);
X          printf("Password: %s\n", password);
X     }
X     printf("\n");
X
X     execlp("cu", "cu", phone, "-s", baud, 0);
X}
E_O_F
echo "creating get_service.c"
sed 's/^X//' > get_service.c << E_O_F
X#include <stdio.h>
X
Xextern char    *getenv();
X
Xextern char    service[40],
X               phone[20],
X               baud[10],
X               login[20],
X               password[20];
X
Xget_service(name)
Xchar *name;
X{
X     char dialup[128], c_name[20];
X     FILE *du_file;
X
X     strcpy(dialup, getenv("HOME"));   /* build file name */
X     strcat(dialup, "/.dialup");
X
X     if ((du_file = fopen(dialup, "r")) == NULL) {    /* open it */
X          fprintf(stderr, "dialup: can't open %s.\n", dialup);
X          exit(1);
X     }
X
X     while (!feof(du_file)) {     /* loop till the end of the file */
X          c_name[0] = 0;
X          phone[0] = 0;
X          baud[0] = 0;
X          login[0] = 0;
X          password[0] = 0;
X          service[0] = 0;
X
X          fscanf(du_file, "%[^:]%*c", c_name);
X          fscanf(du_file, "%[^:]%*c", phone);
X          fscanf(du_file, "%[^:]%*c", baud);
X          fscanf(du_file, "%[^:]%*c", login);
X          fscanf(du_file, "%[^:]%*c", password);
X          fscanf(du_file, "%[^\n]%*c", service);
X
X          if (strcmp(name, c_name) == 0) {       /* match? */
X               fclose(du_file);                  /* if so, close up early */
X               return;                           /* and return */
X          }
X     }
X
X     fclose(du_file);                            /* No matches in file */
X     fprintf(stderr, "dialup: %s network unknown.\n", name);
X     exit(1);
X}
E_O_F
echo "creating dialup.1"
sed 's/^X//' > dialup.1 << E_O_F
X.TH DIALUP 1
X.SH NAME
Xdialup \- load phone number from service name and call
X.SH SYNTAX
X.B dialup
X[
X.B -s
X]
X.B service
X.SH DESCRIPTION
X.B Dialup
Xuses a simple database setup in the user's home directory to help users
Xwho call other computers via cu(1).  This database contains the mnuemonic
Xname of the database for reference.  It also contains the phone number,
Xbaud rate and description and optionally the user's login name and
Xpassword for that service.
X.PP
XIf the
X.B -s
Xoption is used the login name and password are not printed.
X.PP
XThe database consists of six fields seperated by colons (:) much like
X/etc/passwd.  The fields in order are: name, phone number, baud rate,
Xlogin name, password and description.
X.SH "SEE ALSO"
Xcu(1)
X.SH CREDIT
XThis program was developed by Brad L. McKinley at M D R Professional
XSoftware Inc.  The user of the program accepts any and all responsibility
Xfor damages caused by this program.
E_O_F

jqj@cornell.UUCP (J Q Johnson) (01/13/86)

The "dialup" program posted to net.sources stores unencrypted passwords for
other systems in the user's home directory.  As a systems admin, I consider
this a major security problem (relying as it does ONLY on Unix file protection
to maintain confidentiality).  I would not allow this program on my systems!