Use gettimeofday() directly instead of via the gettime() wrapper.
This commit is contained in:
@@ -45,7 +45,7 @@ DEFS = @OSDEFS@
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
LTOBJS = alloc.lo atobool.lo fileops.lo fmt_string.lo gettime.lo \
|
||||
LTOBJS = alloc.lo atobool.lo fileops.lo fmt_string.lo \
|
||||
lbuf.lo list.lo term.lo zero_bytes.lo @COMMON_OBJS@
|
||||
|
||||
all: libcommon.la
|
||||
@@ -64,7 +64,6 @@ alloc.lo: $(srcdir)/alloc.c $(incdir)/compat.h $(incdir)/alloc.h $(incdir)/error
|
||||
atobool.lo: $(srcdir)/atobool.c $(incdir)/compat.h $(incdir)/missing.h $(top_builddir)/config.h
|
||||
fileops.lo: $(srcdir)/fileops.c $(incdir)/fileops.h $(top_builddir)/config.h
|
||||
fmt_string.lo: $(srcdir)/fmt_string.c $(incdir)/compat.h $(top_builddir)/config.h
|
||||
gettime.lo: $(srcdir)/gettime.c $(incdir)/compat.h $(top_builddir)/config.h
|
||||
lbuf.lo: $(srcdir)/lbuf.c $(incdir)/compat.h $(incdir)/alloc.h $(incdir)/error.h $(incdir)/missing.h $(incdir)/lbuf.h $(top_builddir)/config.h
|
||||
list.lo: $(srcdir)/list.c $(incdir)/compat.h $(incdir)/list.h $(incdir)/error.h $(top_builddir)/config.h
|
||||
term.lo: $(srcdir)/term.c $(incdir)/compat.h $(top_builddir)/config.h
|
||||
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, 2008, 2010
|
||||
* Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
/*
|
||||
* Get the current time via gettimeofday() for systems with
|
||||
* timespecs in struct stat or, otherwise, using time().
|
||||
*/
|
||||
int
|
||||
gettime(struct timeval *tv)
|
||||
{
|
||||
return gettimeofday(tv, NULL);
|
||||
}
|
@@ -38,8 +38,6 @@
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
extern int gettime(struct timeval *);
|
||||
|
||||
static unsigned int get_random(void);
|
||||
static void seed_random(void);
|
||||
|
||||
@@ -113,7 +111,7 @@ seed_random(void)
|
||||
/*
|
||||
* Seed from time of day and process id multiplied by small primes.
|
||||
*/
|
||||
(void) gettime(&tv);
|
||||
(void) gettimeofday(&tv, NULL);
|
||||
seed = (tv.tv_sec % 10000) * 523 + tv.tv_usec * 13 +
|
||||
(getpid() % 1000) * 983;
|
||||
SRAND(seed);
|
||||
|
@@ -250,9 +250,6 @@ char *sudo_getepw(const struct passwd *);
|
||||
/* zero_bytes.c */
|
||||
void zero_bytes(volatile void *, size_t);
|
||||
|
||||
/* gettime.c */
|
||||
int gettime(struct timeval *);
|
||||
|
||||
/* sudo_nss.c */
|
||||
void display_privs(struct sudo_nss_list *, struct passwd *);
|
||||
int display_cmnd(struct sudo_nss_list *, struct passwd *);
|
||||
|
@@ -338,9 +338,9 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
|
||||
* XPG4 specifies that vi's exit value is a function of the
|
||||
* number of errors during editing (?!?!).
|
||||
*/
|
||||
gettime(&tv1);
|
||||
gettimeofday(&tv1, NULL);
|
||||
if (run_command(editor, av) != -1) {
|
||||
gettime(&tv2);
|
||||
gettimeofday(&tv2, NULL);
|
||||
/*
|
||||
* Sanity checks.
|
||||
*/
|
||||
|
@@ -207,9 +207,6 @@ int sudo_edit(struct command_details *details, char *argv[], char *envp[]);
|
||||
/* parse_args.c */
|
||||
void usage(int) __attribute__((__noreturn__));
|
||||
|
||||
/* gettime.c */
|
||||
int gettime(struct timeval *);
|
||||
|
||||
/* selinux.c */
|
||||
int selinux_restore_tty(void);
|
||||
int selinux_setup(const char *role, const char *type, const char *ttyn,
|
||||
|
@@ -244,7 +244,7 @@ sudo_edit(struct command_details *command_details, char *argv[], char *envp[])
|
||||
* Run the editor with the invoking user's creds,
|
||||
* keeping track of the time spent in the editor.
|
||||
*/
|
||||
gettime(&tv1);
|
||||
gettimeofday(&tv1, NULL);
|
||||
memcpy(&editor_details, command_details, sizeof(editor_details));
|
||||
editor_details.uid = user_details.uid;
|
||||
editor_details.euid = user_details.uid;
|
||||
@@ -253,7 +253,7 @@ sudo_edit(struct command_details *command_details, char *argv[], char *envp[])
|
||||
editor_details.ngroups = user_details.ngroups;
|
||||
editor_details.groups = user_details.groups;
|
||||
rval = run_command(&editor_details, nargv, envp);
|
||||
gettime(&tv2);
|
||||
gettimeofday(&tv2, NULL);
|
||||
|
||||
/* Copy contents of temp files to real ones */
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
|
Reference in New Issue
Block a user