X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=761aafc88f92530b27264d4bfa87215b66ff194c;hb=f6330ec2a89df650cd6bfeaa6538b8053aeb45c7;hp=b4a435d2a99368bdb48316c798961f1be8f08147;hpb=6edf252483b30dbcdcc5059f01831455365d5b6e;p=ppp.git diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index b4a435d..761aafc 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -73,12 +73,12 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -643,6 +643,21 @@ static int make_ppp_unit() } if (x < 0) error("Couldn't create new ppp unit: %m"); + + if (x == 0 && req_ifname[0] != '\0') { + struct ifreq ifr; + char t[MAXIFNAMELEN]; + memset(&ifr, 0, sizeof(struct ifreq)); + slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit); + strncpy(ifr.ifr_name, t, IF_NAMESIZE); + strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE); + x = ioctl(sock_fd, SIOCSIFNAME, &ifr); + if (x < 0) + error("Couldn't rename interface %s to %s: %m", t, req_ifname); + else + info("Renamed interface %s to %s", t, req_ifname); + } + return x; } @@ -2152,7 +2167,6 @@ int ppp_available(void) } } - close (s); if (!ok) { slprintf(route_buffer, sizeof(route_buffer), "Sorry - PPP driver version %d.%d.%d is out of date\n", @@ -2162,6 +2176,7 @@ int ppp_available(void) } } } + close(s); return ok; } @@ -2638,7 +2653,10 @@ get_pty(master_fdp, slave_fdp, slave_name, uid) warn("Couldn't unlock pty slave %s: %m", pty_name); #endif if ((sfd = open(pty_name, O_RDWR | O_NOCTTY)) < 0) + { warn("Couldn't open pty slave %s: %m", pty_name); + close(mfd); + } } } #endif /* TIOCGPTN */