X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=d494c847e4e689eecf32fadb6093e03c1e24804b;hp=3cbc78afee4808e6f58706fe5f8b05380a88e464;hb=2882779b0a09272b1b834f78202357f805c26b7d;hpb=0375e3ce50b9e0bc4e559615039988e7834c7d01 diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 3cbc78a..d494c84 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -120,8 +120,7 @@ static unsigned char inbuf[512]; /* buffer for chars read from loopback */ static int if_is_up; /* Interface has been marked up */ static u_int32_t default_route_gateway; /* Gateway for default route added */ static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */ - -static char *lock_file; +static char proxy_arp_dev[16]; /* Device for proxy arp entry */ static struct utsname utsname; /* for the kernel version */ static int kernel_version; @@ -144,8 +143,10 @@ static int open_route_table (void); static int read_route_table (struct rtentry *rt); static int defaultroute_exists (struct rtentry *rt); static int get_ether_addr (u_int32_t ipaddr, struct sockaddr *hwaddr, - char *name); + char *name, int namelen); static void decode_version (char *buf, int *version, int *mod, int *patch); +static int set_kdebugflag(int level); +static int ppp_registered(void); extern u_char inpacket_buf[]; /* borrowed from main.c */ @@ -164,10 +165,6 @@ extern u_char inpacket_buf[]; /* borrowed from main.c */ extern int hungup; -#ifndef LOCK_PREFIX -#define LOCK_PREFIX "/var/lock/LCK.." -#endif - static void set_ppp_fd (int new_fd) { SYSDEBUG ((LOG_DEBUG, "setting ppp_fd to %d\n", new_fd)); @@ -251,7 +248,7 @@ void sys_init(void) * * sys_cleanup - restore any system state we modified before exiting: * mark the interface down, delete default route and/or proxy arp entry. - * This should call die() because it's called from die(). + * This shouldn't call die() because it's called from die(). */ void sys_cleanup(void) @@ -278,33 +275,21 @@ void sys_cleanup(void) void sys_close(void) { - close(sock_fd); - sock_fd = -1; + if (sock_fd >= 0) + close(sock_fd); + if (slave_fd >= 0) + close(slave_fd); + if (master_fd >= 0) + close(master_fd); closelog(); } -/******************************************************************** - * - * note_debug_level - note a change in the debug level. - */ - -void note_debug_level (void) -{ - if (debug) { - SYSDEBUG ((LOG_INFO, "Debug turned ON, Level %d", debug)); - setlogmask(LOG_UPTO(LOG_DEBUG)); - } - else { - setlogmask(LOG_UPTO(LOG_WARNING)); - } -} - /******************************************************************** * * set_kdebugflag - Define the debugging level for the kernel */ -int set_kdebugflag (int requested_level) +static int set_kdebugflag (int requested_level) { if (ioctl(ppp_fd, PPPIOCSDEBUG, &requested_level) < 0) { if ( ! ok_error (errno) ) @@ -396,10 +381,12 @@ int establish_ppp (int tty_fd) void disestablish_ppp(int tty_fd) { + if (!hungup) { /* - * Attempt to restore the previous tty settings + * Flush the tty output buffer so that the TIOCSETD doesn't hang. */ - if (!hungup) { + if (tcflush(tty_fd, TCIOFLUSH) < 0) + warn("tcflush failed: %m"); /* * Restore the previous line discipline */ @@ -601,7 +588,7 @@ void set_up_tty(int tty_fd, int local) setdtr(tty_fd, 1); if (tcgetattr(tty_fd, &tios) < 0) { - if (!ok_errno(errno)) + if (!ok_error(errno)) fatal("tcgetattr: %m(%d)", errno); return; } @@ -656,11 +643,11 @@ void set_up_tty(int tty_fd, int local) } if (tcsetattr(tty_fd, TCSAFLUSH, &tios) < 0) - if (!ok_errno(errno)) + if (!ok_error(errno)) fatal("tcsetattr: %m"); baud_rate = baud_rate_of(speed); - restore_term = TRUE; + restore_term = 1; } /******************************************************************** @@ -859,7 +846,7 @@ void ppp_send_config (int unit,int mtu,u_int32_t asyncmap,int pcomp,int accomp) * Set the MTU and other parameters for the ppp device */ memset (&ifr, '\0', sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); ifr.ifr_mtu = mtu; if (ioctl(sock_fd, SIOCSIFMTU, (caddr_t) &ifr) < 0) @@ -867,7 +854,7 @@ void ppp_send_config (int unit,int mtu,u_int32_t asyncmap,int pcomp,int accomp) SYSDEBUG ((LOG_DEBUG, "send_config: asyncmap = %lx\n", asyncmap)); if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0) { - if (!ok_errno(errno)) + if (!ok_error(errno)) fatal("ioctl(PPPIOCSASYNCMAP): %m(%d)", errno); return; } @@ -875,6 +862,7 @@ void ppp_send_config (int unit,int mtu,u_int32_t asyncmap,int pcomp,int accomp) x = get_flags(); x = pcomp ? x | SC_COMP_PROT : x & ~SC_COMP_PROT; x = accomp ? x | SC_COMP_AC : x & ~SC_COMP_AC; + x = sync_serial ? x | SC_SYNC : x & ~SC_SYNC; set_flags(x); } @@ -921,7 +909,7 @@ void ppp_recv_config (int unit,int mru,u_int32_t asyncmap,int pcomp,int accomp) SYSDEBUG ((LOG_DEBUG, "recv_config: asyncmap = %lx\n", asyncmap)); if (ioctl(ppp_fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0) { - if (!ok_errno(errno)) + if (!ok_error(errno)) error("ioctl(PPPIOCSRASYNCMAP): %m(%d)", errno); } @@ -978,6 +966,30 @@ get_idle_time(u, ip) return ioctl(ppp_fd, PPPIOCGIDLE, ip) >= 0; } +/******************************************************************** + * + * get_ppp_stats - return statistics for the link. + */ +int +get_ppp_stats(u, stats) + int u; + struct pppd_stats *stats; +{ + struct ifpppstatsreq req; + + memset (&req, 0, sizeof (req)); + + req.stats_ptr = (caddr_t) &req.stats; + strlcpy(req.ifr__name, ifname, sizeof(req.ifr__name)); + if (ioctl(sock_fd, SIOCGPPPSTATS, &req) < 0) { + error("Couldn't get PPP statistics: %m"); + return 0; + } + stats->bytes_in = req.stats.p.ppp_ibytes; + stats->bytes_out = req.stats.p.ppp_obytes; + return 1; +} + /******************************************************************** * * ccp_fatal_error - returns 1 if decompression was disabled as a @@ -1012,7 +1024,7 @@ static int read_route_table (struct rtentry *rt); * path_to_procfs - find the path to the proc file system mount point */ -static int path_to_procfs (void) +static int path_to_procfs (const char *tail) { struct mntent *mntent; FILE *fp; @@ -1020,7 +1032,8 @@ static int path_to_procfs (void) fp = fopen(MOUNTED, "r"); if (fp == NULL) { /* Default the mount location of /proc */ - strlcpy (route_buffer, sizeof (route_buffer), "/proc"); + strlcpy (route_buffer, "/proc", sizeof (route_buffer)); + strlcat (route_buffer, tail, sizeof(route_buffer)); return 1; } @@ -1034,7 +1047,8 @@ static int path_to_procfs (void) if (mntent == 0) return 0; - strlcpy(route_buffer, sizeof (route_buffer), mntent->mnt_dir); + strlcpy(route_buffer, mntent->mnt_dir, sizeof (route_buffer)); + strlcat (route_buffer, tail, sizeof(route_buffer)); return 1; } @@ -1045,11 +1059,10 @@ static int path_to_procfs (void) static char *path_to_route (void) { - if (!path_to_procfs()) { + if (!path_to_procfs("/net/route")) { error("proc file system not mounted"); return 0; } - strlcat (route_buffer, sizeof(route_buffer), "/net/route"); return (route_buffer); } @@ -1310,11 +1323,13 @@ int sifproxyarp (int unit, u_int32_t his_adr) * Get the hardware address of an interface on the same subnet * as our local address. */ - if (!get_ether_addr(his_adr, &arpreq.arp_ha, arpreq.arp_dev)) { + if (!get_ether_addr(his_adr, &arpreq.arp_ha, proxy_arp_dev, + sizeof(proxy_arp_dev))) { error("Cannot determine ethernet address for proxy ARP"); return 0; } - + strlcpy(arpreq.arp_dev, proxy_arp_dev, sizeof(arpreq.arp_dev)); + if (ioctl(sock_fd, SIOCSARP, (caddr_t)&arpreq) < 0) { if ( ! ok_error ( errno )) error("ioctl(SIOCSARP): %m(%d)", errno); @@ -1342,6 +1357,7 @@ int cifproxyarp (int unit, u_int32_t his_adr) SET_SA_FAMILY(arpreq.arp_pa, AF_INET); ((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = his_adr; arpreq.arp_flags = ATF_PERM | ATF_PUBL; + strlcpy(arpreq.arp_dev, proxy_arp_dev, sizeof(arpreq.arp_dev)); if (ioctl(sock_fd, SIOCDARP, (caddr_t)&arpreq) < 0) { if ( ! ok_error ( errno )) @@ -1360,7 +1376,7 @@ int cifproxyarp (int unit, u_int32_t his_adr) static int get_ether_addr (u_int32_t ipaddr, struct sockaddr *hwaddr, - char *name) + char *name, int namelen) { struct ifreq *ifr, *ifend; u_int32_t ina, mask; @@ -1386,7 +1402,7 @@ static int get_ether_addr (u_int32_t ipaddr, for (ifr = ifc.ifc_req; ifr < ifend; ifr++) { if (ifr->ifr_addr.sa_family == AF_INET) { ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr; - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); SYSDEBUG ((LOG_DEBUG, "proxy arp: examining interface %s", ifreq.ifr_name)); /* @@ -1417,7 +1433,7 @@ static int get_ether_addr (u_int32_t ipaddr, if (ifr >= ifend) return 0; - memcpy (name, ifreq.ifr_name, sizeof(ifreq.ifr_name)); + strlcpy(name, ifreq.ifr_name, namelen); info("found interface %s for proxy arp", name); /* * Now get the hardware address. @@ -1497,7 +1513,7 @@ u_int32_t GetMask (u_int32_t addr) /* * Check that the interface is up, and not point-to-point nor loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, &ifreq) < 0) continue; @@ -1547,52 +1563,37 @@ static void decode_version (char *buf, int *version, * Procedure to determine if the PPP line discipline is registered. */ -int +static int ppp_registered(void) { int local_fd; - int init_disc = -1; - int initfdflags; - - local_fd = open(devnam, O_NONBLOCK | O_RDWR, 0); - if (local_fd < 0) { - error("Failed to open %s: %m(%d)", devnam, errno); + int mfd = -1; + int ret = 0; + char slave[16]; + + /* + * We used to open the serial device and set it to the ppp line + * discipline here, in order to create a ppp unit. But that is + * not a good idea - the user might have specified a device that + * they can't open (permission, or maybe it doesn't really exist). + * So we grab a pty master/slave pair and use that. + */ + if (!get_pty(&mfd, &local_fd, slave, 0)) { + no_ppp_msg = "Couldn't determine if PPP is supported (no free ptys)"; return 0; } - initfdflags = fcntl(local_fd, F_GETFL); - if (initfdflags == -1) { - error("Couldn't get device fd flags: %m(%d)", errno); - close (local_fd); - return 0; - } - - initfdflags &= ~O_NONBLOCK; - fcntl(local_fd, F_SETFL, initfdflags); -/* - * Read the initial line dicipline and try to put the device into the - * PPP dicipline. - */ - if (ioctl(local_fd, TIOCGETD, &init_disc) < 0) { - error("ioctl(TIOCGETD): %m(%d)", errno); - close (local_fd); - return 0; - } - + /* + * Try to put the device into the PPP discipline. + */ if (ioctl(local_fd, TIOCSETD, &ppp_disc) < 0) { - error("ioctl(TIOCSETD): %m(%d)", errno); - close (local_fd); - return 0; - } - - if (ioctl(local_fd, TIOCSETD, &init_disc) < 0) { - error("ioctl(TIOCSETD): %m(%d)", errno); - close (local_fd); - return 0; - } + error("ioctl(TIOCSETD(PPP)): %m(%d)", errno); + } else + ret = 1; - close (local_fd); - return 1; + close(local_fd); + close(mfd); + return ret; } /******************************************************************** @@ -1607,7 +1608,15 @@ int ppp_available(void) struct ifreq ifr; int size; int my_version, my_modification, my_patch; - extern char *no_ppp_msg; + + no_ppp_msg = + "This system lacks kernel support for PPP. This could be because\n" + "the PPP kernel module could not be loaded, or because PPP was not\n" + "included in the kernel configuration. If PPP was included as a\n" + "module, try `/sbin/modprobe -v ppp'. If that fails, check that\n" + "ppp.o exists in /lib/modules/`uname -r`/net.\n" + "See README.linux file in the ppp distribution for more details.\n"; + /* * Open a socket for doing the ioctl operations. */ @@ -1615,7 +1624,7 @@ int ppp_available(void) if (s < 0) return 0; - strlcpy (ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); + strlcpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; /* * If the device did not exist then attempt to create one by putting the @@ -1624,7 +1633,7 @@ int ppp_available(void) */ if (!ok) { if (ppp_registered()) { - strlcpy (ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); + strlcpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; } } @@ -1637,18 +1646,11 @@ int ppp_available(void) if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP)) ok = 0; - if (!ok) - no_ppp_msg = - "This system lacks kernel support for PPP. This could be because\n" - "the PPP kernel module is not loaded, or because the kernel is\n" - "not configured for PPP. See the README.linux file in the\n" - "ppp-2.3.6 distribution.\n"; - /* * This is the PPP device. Validate the version of the driver at this * point to ensure that this program will work with the driver. */ - else { + if (ok) { char abBuffer [1024]; ifr.ifr_data = abBuffer; @@ -1727,10 +1729,10 @@ void logwtmp (const char *line, const char *name, const char *host) memset(&ut, 0, sizeof(ut)); if (ut.ut_id[0] == 0) - strlcpy(ut.ut_id, sizeof(ut.ut_id), line + 3); + strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id)); - strlcpy(ut.ut_user, sizeof(ut.ut_user), name); - strlcpy(ut.ut_line, sizeof(ut.ut_line), line); + strncpy(ut.ut_user, name, sizeof(ut.ut_user)); + strncpy(ut.ut_line, line, sizeof(ut.ut_line)); time(&ut.ut_time); @@ -1739,7 +1741,7 @@ void logwtmp (const char *line, const char *name, const char *host) /* Insert the host name if one is supplied */ if (*host) - strlcpy (ut.ut_host, sizeof(ut.ut_host), host); + strncpy (ut.ut_host, host, sizeof(ut.ut_host)); /* Insert the IP address of the remote system if IP is enabled */ if (ipcp_protent.enabled_flag && ipcp_hisoptions[0].neg_addr) @@ -1767,11 +1769,18 @@ void logwtmp (const char *line, const char *name, const char *host) } } +#if 0 /******************************************************************** * Code for locking/unlocking the serial device. * This code is derived from chat.c. */ +#ifndef LOCK_PREFIX +#define LOCK_PREFIX "/var/lock/LCK.." +#endif + +static char *lock_file; + /* * lock - create a lock file for the named device */ @@ -1904,6 +1913,7 @@ void unlock(void) lock_file = NULL; } } +#endif /******************************************************************** * @@ -1939,7 +1949,7 @@ int sifup (int u) struct ifreq ifr; memset (&ifr, '\0', sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { if (! ok_error (errno)) error("ioctl (SIOCGIFFLAGS): %m(%d)", errno); @@ -1968,7 +1978,7 @@ int sifdown (int u) if_is_up = 0; memset (&ifr, '\0', sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { if (! ok_error (errno)) error("ioctl (SIOCGIFFLAGS): %m(%d)", errno); @@ -2003,7 +2013,7 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr, SET_SA_FAMILY (ifr.ifr_dstaddr, AF_INET); SET_SA_FAMILY (ifr.ifr_netmask, AF_INET); - strlcpy (ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); /* * Set our IP address */ @@ -2011,10 +2021,10 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr, if (ioctl(sock_fd, SIOCSIFADDR, (caddr_t) &ifr) < 0) { if (errno != EEXIST) { if (! ok_error (errno)) - error("ioctl(SIOCAIFADDR): %m(%d)", errno); + error("ioctl(SIOCSIFADDR): %m(%d)", errno); } else { - warn("ioctl(SIOCAIFADDR): Address already exists"); + warn("ioctl(SIOCSIFADDR): Address already exists"); } return (0); } @@ -2105,45 +2115,96 @@ int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr) return 1; } -/******************************************************************** - * - * open_loopback - open the device we use for getting packets - * in demand mode. Under Linux, we use our existing fd - * to the ppp driver. +/* + * get_pty - get a pty master/slave pair and chown the slave side + * to the uid given. Assumes slave_name points to >= 16 bytes of space. */ int -open_ppp_loopback(void) +get_pty(master_fdp, slave_fdp, slave_name, uid) + int *master_fdp; + int *slave_fdp; + char *slave_name; + int uid; { - int flags, i; + int i, mfd, sfd = -1; + char pty_name[16]; struct termios tios; - master_fd = -1; - for (i = 0; i < 64; ++i) { - slprintf(loop_name, sizeof(loop_name), "/dev/pty%c%x", - 'p' + i / 16, i % 16); - master_fd = open(loop_name, O_RDWR | O_NOCTTY, 0); - if (master_fd >= 0) - break; +#ifdef TIOCGPTN + /* + * Try the unix98 way first. + */ + mfd = open("/dev/ptmx", O_RDWR); + if (mfd >= 0) { + int ptn; + if (ioctl(mfd, TIOCGPTN, &ptn) >= 0) { + slprintf(pty_name, sizeof(pty_name), "/dev/pts/%d", ptn); + chmod(pty_name, S_IRUSR | S_IWUSR); +#ifdef TIOCSPTLCK + ptn = 0; + if (ioctl(mfd, TIOCSPTLCK, &ptn) < 0) + warn("Couldn't unlock pty slave %s: %m", pty_name); +#endif + if ((sfd = open(pty_name, O_RDWR)) < 0) + warn("Couldn't open pty slave %s: %m", pty_name); + } + } +#endif /* TIOCGPTN */ + + if (sfd < 0) { + /* the old way - scan through the pty name space */ + for (i = 0; i < 64; ++i) { + slprintf(pty_name, sizeof(pty_name), "/dev/pty%c%x", + 'p' + i / 16, i % 16); + mfd = open(pty_name, O_RDWR, 0); + if (mfd >= 0) { + pty_name[5] = 't'; + sfd = open(pty_name, O_RDWR | O_NOCTTY, 0); + if (sfd >= 0) { + fchown(sfd, uid, -1); + fchmod(sfd, S_IRUSR | S_IWUSR); + break; + } + close(mfd); + } + } } - if (master_fd < 0) - fatal("No free pty for loopback"); - SYSDEBUG(("using %s for loopback", loop_name)); - loop_name[5] = 't'; - slave_fd = open(loop_name, O_RDWR | O_NOCTTY, 0); - if (slave_fd < 0) - fatal("Couldn't open %s for loopback: %m", loop_name); - set_ppp_fd(slave_fd); + if (sfd < 0) + return 0; - if (tcgetattr(ppp_fd, &tios) == 0) { + strlcpy(slave_name, pty_name, 16); + *master_fdp = mfd; + *slave_fdp = sfd; + if (tcgetattr(sfd, &tios) == 0) { tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB); tios.c_cflag |= CS8 | CREAD; tios.c_iflag = IGNPAR | CLOCAL; tios.c_oflag = 0; tios.c_lflag = 0; - if (tcsetattr(ppp_fd, TCSAFLUSH, &tios) < 0) - warn("couldn't set attributes on loopback: %m(%d)", errno); - } + if (tcsetattr(sfd, TCSAFLUSH, &tios) < 0) + warn("couldn't set attributes on pty: %m"); + } else + warn("couldn't get attributes on pty: %m"); + + return 1; +} + +/******************************************************************** + * + * open_loopback - open the device we use for getting packets + * in demand mode. Under Linux, we use a pty master/slave pair. + */ +int +open_ppp_loopback(void) +{ + int flags; + + if (!get_pty(&master_fd, &slave_fd, loop_name, 0)) + fatal("No free pty for loopback"); + SYSDEBUG(("using %s for loopback", loop_name)); + + set_ppp_fd(slave_fd); flags = fcntl(master_fd, F_GETFL); if (flags == -1 || @@ -2167,7 +2228,7 @@ open_ppp_loopback(void) */ set_kdebugflag (kdebugflag); - return ppp_fd; + return master_fd; } /******************************************************************** @@ -2241,7 +2302,7 @@ int sipxfaddr (int unit, unsigned long int network, unsigned char * node ) } else { memset (&ifr, '\0', sizeof (ifr)); - strlcpy (ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); memcpy (sipx->sipx_node, node, IPX_NODE_LEN); sipx->sipx_family = AF_IPX; @@ -2256,10 +2317,10 @@ int sipxfaddr (int unit, unsigned long int network, unsigned char * node ) result = 0; if (errno != EEXIST) { if (! ok_error (errno)) - dbglog("ioctl(SIOCAIFADDR, CRTITF): %m (%d)", errno); + dbglog("ioctl(SIOCSIFADDR, CRTITF): %m (%d)", errno); } else { - warn("ioctl(SIOCAIFADDR, CRTITF): Address already exists"); + warn("ioctl(SIOCSIFADDR, CRTITF): Address already exists"); } } close (skfd); @@ -2292,7 +2353,7 @@ int cipxfaddr (int unit) } else { memset (&ifr, '\0', sizeof (ifr)); - strlcpy (ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); sipx->sipx_type = IPX_FRAME_ETHERII; sipx->sipx_action = IPX_DLTITF; @@ -2302,7 +2363,7 @@ int cipxfaddr (int unit) */ if (ioctl(skfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) { if (! ok_error (errno)) - info("ioctl(SIOCAIFADDR, IPX_DLTITF): %m (%d)", errno); + info("ioctl(SIOCSIFADDR, IPX_DLTITF): %m (%d)", errno); result = 0; } close (skfd); @@ -2311,6 +2372,7 @@ int cipxfaddr (int unit) return result; } +#if 0 /* * daemon - Detach us from controlling terminal session. */ @@ -2334,6 +2396,7 @@ daemon(nochdir, noclose) } return 0; } +#endif /* * Use the hostname as part of the random number seed. @@ -2359,21 +2422,16 @@ int sys_check_options(void) { #ifdef IPX_CHANGE - struct stat stat_buf; /* * Disable the IPX protocol if the support is not present in the kernel. - * If we disable it then ensure that IP support is enabled. */ - while (ipxcp_protent.enabled_flag) { - if (path_to_procfs()) { - strlcat (route_buffer, sizeof(route_buffer), "/net/ipx_interface"); - if (lstat (route_buffer, &stat_buf) >= 0) - break; + if (ipxcp_protent.enabled_flag) { + struct stat stat_buf; + if (!path_to_procfs("/net/ipx_interface") + || lstat (route_buffer, &stat_buf) < 0) { + error("IPX support is not present in the kernel\n"); + ipxcp_protent.enabled_flag = 0; } - error("IPX support is not present in the kernel\n"); - ipxcp_protent.enabled_flag = 0; - ipcp_protent.enabled_flag = 1; - break; } #endif if (demand && driver_is_old) {