diff options
Diffstat (limited to 'sunrpc')
-rw-r--r-- | sunrpc/auth_des.c | 19 | ||||
-rw-r--r-- | sunrpc/auth_unix.c | 9 | ||||
-rw-r--r-- | sunrpc/create_xid.c | 6 | ||||
-rw-r--r-- | sunrpc/svcauth_des.c | 7 |
4 files changed, 25 insertions, 16 deletions
diff --git a/sunrpc/auth_des.c b/sunrpc/auth_des.c index 5b6f985bc2..d26820a701 100644 --- a/sunrpc/auth_des.c +++ b/sunrpc/auth_des.c @@ -41,6 +41,7 @@ #include <rpc/xdr.h> #include <netinet/in.h> /* XXX: just to get htonl() and ntohl() */ #include <sys/socket.h> +#include <time.h> #include <shlib-compat.h> #define MILLION 1000000L @@ -246,15 +247,15 @@ authdes_marshal (AUTH *auth, XDR *xdrs) int status; int len; register int32_t *ixdr; - struct timeval tval; + struct timespec now; /* * Figure out the "time", accounting for any time difference * with the server if necessary. */ - __gettimeofday (&tval, (struct timezone *) NULL); - ad->ad_timestamp.tv_sec = tval.tv_sec + ad->ad_timediff.tv_sec; - ad->ad_timestamp.tv_usec = tval.tv_usec + ad->ad_timediff.tv_usec; + __clock_gettime (CLOCK_REALTIME, &now); + ad->ad_timestamp.tv_sec = now.tv_sec + ad->ad_timediff.tv_sec; + ad->ad_timestamp.tv_usec = (now.tv_nsec / 1000) + ad->ad_timediff.tv_usec; if (ad->ad_timestamp.tv_usec >= MILLION) { ad->ad_timestamp.tv_usec -= MILLION; @@ -445,21 +446,23 @@ authdes_destroy (AUTH *auth) static bool_t synchronize (struct sockaddr *syncaddr, struct rpc_timeval *timep) { - struct timeval mytime; + struct timespec mytime; struct rpc_timeval timeout; + long int myusec; timeout.tv_sec = RTIME_TIMEOUT; timeout.tv_usec = 0; if (rtime ((struct sockaddr_in *) syncaddr, timep, &timeout) < 0) return FALSE; - __gettimeofday (&mytime, (struct timezone *) NULL); + __clock_gettime (CLOCK_REALTIME, &mytime); timep->tv_sec -= mytime.tv_sec; - if (mytime.tv_usec > timep->tv_usec) + myusec = mytime.tv_nsec / 1000; + if (myusec > timep->tv_usec) { timep->tv_sec -= 1; timep->tv_usec += MILLION; } - timep->tv_usec -= mytime.tv_usec; + timep->tv_usec -= myusec; return TRUE; } diff --git a/sunrpc/auth_unix.c b/sunrpc/auth_unix.c index b035fdd870..ff0d2eb933 100644 --- a/sunrpc/auth_unix.c +++ b/sunrpc/auth_unix.c @@ -43,6 +43,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <time.h> #include <libintl.h> #include <sys/param.h> #include <wchar.h> @@ -96,7 +97,7 @@ authunix_create (char *machname, uid_t uid, gid_t gid, int len, { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; - struct timeval now; + struct timespec now; XDR xdrs; AUTH *auth; struct audata *au; @@ -122,7 +123,7 @@ no_memory: /* * fill in param struct from the given params */ - (void) __gettimeofday (&now, (struct timezone *) 0); + __clock_gettime (CLOCK_REALTIME, &now); aup.aup_time = now.tv_sec; aup.aup_machname = machname; aup.aup_uid = uid; @@ -276,7 +277,7 @@ authunix_refresh (AUTH *auth) { struct audata *au = AUTH_PRIVATE (auth); struct authunix_parms aup; - struct timeval now; + struct timespec now; XDR xdrs; int stat; @@ -297,7 +298,7 @@ authunix_refresh (AUTH *auth) goto done; /* update the time and serialize in place */ - (void) __gettimeofday (&now, (struct timezone *) 0); + __clock_gettime (CLOCK_REALTIME, &now); aup.aup_time = now.tv_sec; xdrs.x_op = XDR_ENCODE; XDR_SETPOS (&xdrs, 0); diff --git a/sunrpc/create_xid.c b/sunrpc/create_xid.c index 1339615a1b..c692c1eb92 100644 --- a/sunrpc/create_xid.c +++ b/sunrpc/create_xid.c @@ -39,10 +39,10 @@ _create_xid (void) pid_t pid = getpid (); if (is_initialized != pid) { - struct timeval now; + struct timespec now; - __gettimeofday (&now, (struct timezone *) 0); - __srand48_r (now.tv_sec ^ now.tv_usec ^ pid, + __clock_gettime (CLOCK_REALTIME, &now); + __srand48_r (now.tv_sec ^ now.tv_nsec ^ pid, &__rpc_lrand48_data); is_initialized = pid; } diff --git a/sunrpc/svcauth_des.c b/sunrpc/svcauth_des.c index c5a512d6f8..7607abc818 100644 --- a/sunrpc/svcauth_des.c +++ b/sunrpc/svcauth_des.c @@ -44,6 +44,7 @@ #include <limits.h> #include <string.h> #include <stdint.h> +#include <time.h> #include <sys/param.h> #include <netinet/in.h> #include <rpc/rpc.h> @@ -295,7 +296,11 @@ _svcauth_des (register struct svc_req *rqst, register struct rpc_msg *msg) debug ("timestamp before last seen"); return AUTH_REJECTEDVERF; /* replay */ } - __gettimeofday (¤t, (struct timezone *) NULL); + { + struct timespec now; + __clock_gettime (CLOCK_REALTIME, &now); + TIMESPEC_TO_TIMEVAL (¤t, &now); + } current.tv_sec -= window; /* allow for expiration */ if (!BEFORE (¤t, ×tamp)) { |