Listing 5: slcallback.c--Login shell for SLIP users. Implements modem callback using uucp dialing libraries
#include <stdio.h>
#include <signal.h>
#include <strings.h>
#include <sys/types.h>
#include <pwd.h>
#define _PATH_SLDIAL "/usr/bin/sldial"
#define CB_DELAY 30
main()
{
struct passwd *pwent;
char *pgrm, *name, *slhost;
pwent=getpwuid(getuid());
printf("You seem to be %s (%d)\n",
pwent->pw_name, getuid());
printf("Calling back\n\n\n");
fflush(stdout);
signal(SIGHUP, SIG_IGN);
slhost=pwent->pw_name;
/* some code to hang up the line */
if (fork())
exit(0);
sleep(CB_DELAY); /* time for IBM modems to hangup */
/* just call sldial, it has everything set up */
pgrm = _PATH_SLDIAL;
name = ((name = strrchr (pgrm, '/')) == NULL) ? pgrm : name + 1;
execl(pgrm, name, "-f", "-d", "-S", slhost,
slhost, (char *) 0);
exit(0);
}
/* End of slcallback.c */
|