]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/main.c
change link_connect_time to unsigned
[ppp.git] / pppd / main.c
index c6ba438a43576f021ce86721a0171a51b55d043b..e24e08bfc806130605cca9f73b5b840ceab0f8d5 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: main.c,v 1.113 2002/05/21 17:26:49 dfs Exp $"
+#define RCSID  "$Id: main.c,v 1.118 2002/10/27 12:19:58 fcusack Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -84,7 +84,6 @@ char hostname[MAXNAMELEN];    /* Our hostname */
 static char pidfilename[MAXPATHLEN];   /* name of pid file */
 static char linkpidfile[MAXPATHLEN];   /* name of linkname pid file */
 char ppp_devnam[MAXPATHLEN];   /* name of PPP tty (maybe ttypx) */
-char remote_number[MAXNAMELEN]; /* Remote telephone number, if available */
 uid_t uid;                     /* Our real user-id */
 struct notifier *pidchange = NULL;
 struct notifier *phasechange = NULL;
@@ -147,7 +146,7 @@ int ngroups;                        /* How many groups valid in groups */
 static struct timeval start_time;      /* Time when link was started. */
 
 struct pppd_stats link_stats;
-int link_connect_time;
+unsigned link_connect_time;
 int link_stats_valid;
 
 /*
@@ -361,10 +360,19 @@ main(argc, argv)
        init_pr_log(NULL, LOG_INFO);
        print_options(pr_log, NULL);
        end_pr_log();
-       if (dryrun)
-           die(0);
     }
 
+    /*
+     * Early check for remote number authorization.
+     */
+    if (!auth_number()) {
+       warn("calling number %q is not authorized", remote_number);
+       exit(EXIT_CNID_AUTH_FAILED);
+    }
+
+    if (dryrun)
+       die(0);
+
     /*
      * Initialize system-dependent stuff.
      */
@@ -1108,11 +1116,11 @@ update_link_stats(u)
     link_connect_time = now.tv_sec - start_time.tv_sec;
     link_stats_valid = 1;
 
-    slprintf(numbuf, sizeof(numbuf), "%d", link_connect_time);
+    slprintf(numbuf, sizeof(numbuf), "%u", link_connect_time);
     script_setenv("CONNECT_TIME", numbuf, 0);
-    slprintf(numbuf, sizeof(numbuf), "%d", link_stats.bytes_out);
+    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_out);
     script_setenv("BYTES_SENT", numbuf, 0);
-    slprintf(numbuf, sizeof(numbuf), "%d", link_stats.bytes_in);
+    slprintf(numbuf, sizeof(numbuf), "%u", link_stats.bytes_in);
     script_setenv("BYTES_RCVD", numbuf, 0);
 }