X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fmain.c;h=c18ea510582adc7f9365ad2497a7d9a39c4a2072;hb=21c69e670a9f3f0b4cb201849146fd92f78cdeb9;hp=41be5328d4b8d7b7af89935cc66f093a5b932da9;hpb=7f2f0deae2e0055373ccdd995cd3027aca546549;p=ppp.git diff --git a/pppd/main.c b/pppd/main.c index 41be532..c18ea51 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -520,7 +520,7 @@ main(argc, argv) info("Starting link"); } - gettimeofday(&start_time, NULL); + get_time(&start_time); script_unsetenv("CONNECT_TIME"); script_unsetenv("BYTES_SENT"); script_unsetenv("BYTES_RCVD"); @@ -737,12 +737,16 @@ void set_ifunit(iskey) int iskey; { + char ifkey[32]; + if (req_ifname[0] != '\0') slprintf(ifname, sizeof(ifname), "%s", req_ifname); else slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit); info("Using interface %s", ifname); script_setenv("IFNAME", ifname, iskey); + slprintf(ifkey, sizeof(ifkey), "%d", ifunit); + script_setenv("UNIT", ifkey, iskey); if (iskey) { create_pidfile(getpid()); /* write pid to file */ create_linkpidfile(getpid()); @@ -1224,7 +1228,7 @@ reset_link_stats(u) { if (!get_ppp_stats(u, &old_link_stats)) return; - gettimeofday(&start_time, NULL); + get_time(&start_time); } /* @@ -1238,7 +1242,7 @@ update_link_stats(u) char numbuf[32]; if (!get_ppp_stats(u, &link_stats) - || gettimeofday(&now, NULL) < 0) + || get_time(&now) < 0) return; link_connect_time = now.tv_sec - start_time.tv_sec; link_stats_valid = 1; @@ -1285,7 +1289,7 @@ timeout(func, arg, secs, usecs) fatal("Out of memory in timeout()!"); newp->c_arg = arg; newp->c_func = func; - gettimeofday(&timenow, NULL); + get_time(&timenow); newp->c_time.tv_sec = timenow.tv_sec + secs; newp->c_time.tv_usec = timenow.tv_usec + usecs; if (newp->c_time.tv_usec >= 1000000) { @@ -1339,7 +1343,7 @@ calltimeout() while (callout != NULL) { p = callout; - if (gettimeofday(&timenow, NULL) < 0) + if (get_time(&timenow) < 0) fatal("Failed to get time of day: %m"); if (!(p->c_time.tv_sec < timenow.tv_sec || (p->c_time.tv_sec == timenow.tv_sec @@ -1364,7 +1368,7 @@ timeleft(tvp) if (callout == NULL) return NULL; - gettimeofday(&timenow, NULL); + get_time(&timenow); tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec; tvp->tv_usec = callout->c_time.tv_usec - timenow.tv_usec; if (tvp->tv_usec < 0) { @@ -1574,7 +1578,8 @@ safe_fork(int infd, int outfd, int errfd) /* Executing in the child */ sys_close(); #ifdef USE_TDB - tdb_close(pppdb); + if (pppdb != NULL) + tdb_close(pppdb); #endif /* make sure infd, outfd and errfd won't get tromped on below */