summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-libs/libfaketime/Manifest1
-rw-r--r--sys-libs/libfaketime/files/0001-Fake-__clock_gettime-and-similar-calls-using-__.-cal.patch154
-rw-r--r--sys-libs/libfaketime/files/0002-Finish-safe-faking-of-internal-calls.patch40
-rw-r--r--sys-libs/libfaketime/libfaketime-0.9.5.ebuild31
4 files changed, 226 insertions, 0 deletions
diff --git a/sys-libs/libfaketime/Manifest b/sys-libs/libfaketime/Manifest
index 26979ab2..3b3d67ce 100644
--- a/sys-libs/libfaketime/Manifest
+++ b/sys-libs/libfaketime/Manifest
@@ -1,2 +1,3 @@
DIST libfaketime-0.9.1.tar.gz 30398 SHA256 ec3d5b5dcc1de408a9e86afa5dadcca35371c395b7435bf3c2ba5dc89627b43a SHA512 c1c5a60226dcbf56b7c854efae31712c6085bfcef3d55e11731c4ed84da4e08e7667a085f9ab2d507acc6140d76a5e807a741646a9a81d9f138c2be344b3faba WHIRLPOOL acf23a47de2df0322322c490787caa5508b9d856e946061a77d00971b71c385c5321ede863df105bc6875f5fffd04aa46afbc534e46403e9af448d4630664ab4
+DIST libfaketime-0.9.5.tar.gz 46103 SHA256 5e07678d440d632bef012068ca58825402da5ad25954513e785717cc539c213d SHA512 905a72e5798967f8a44bea5d275880d5a5169ee4ad91a54db99fe8fb75b37ec238512e7701f22c1aeda2112e4d3bee7e235e79bd5affca42cd2343270f4706d3 WHIRLPOOL f62e60799cc4b37fe6844a0c7f7f651686e1a47b49a4e2bba4ae3f72bb5a003961d831a1d266255fb077bbe23eef3813ee5b200d68e2b8108091460eb6065ea8
DIST libfaketime-0.9.tar.gz 30174 SHA256 cc3caf05bb6e0c6db6df71236551e3b241787e64878a0cabe6e6603be723cd79 SHA512 6dcce30e093edeb3d72361329c2aa510495f9ab86eac79ee29a1e00f0b657f5a70677e2f7ab67bdad0ef0b0c434718b7a24d6854592518d7ef0c442a68ee5313 WHIRLPOOL 331d21dc4c63c003b3cc763938d991a63d6247af5a7943ce27d23df4e34a89bf1015b907e9e531e85e64fa31da81c628eab96744996a575e056ab4a87f7d44cc
diff --git a/sys-libs/libfaketime/files/0001-Fake-__clock_gettime-and-similar-calls-using-__.-cal.patch b/sys-libs/libfaketime/files/0001-Fake-__clock_gettime-and-similar-calls-using-__.-cal.patch
new file mode 100644
index 00000000..608582b5
--- /dev/null
+++ b/sys-libs/libfaketime/files/0001-Fake-__clock_gettime-and-similar-calls-using-__.-cal.patch
@@ -0,0 +1,154 @@
+From c1cc101f910867191cafa91f52dddf4b8d9bbe9d Mon Sep 17 00:00:00 2001
+From: Balint Reczey <balint@balintreczey.hu>
+Date: Wed, 16 Oct 2013 09:16:05 +0200
+Subject: [PATCH 1/2] Fake __clock_gettime() and similar calls using __...
+ calls
+
+This breaks potential infinite loops.
+---
+ src/libfaketime.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 105 insertions(+), 6 deletions(-)
+
+diff --git a/src/libfaketime.c b/src/libfaketime.c
+index 3ec372b..babda94 100644
+--- a/src/libfaketime.c
++++ b/src/libfaketime.c
+@@ -115,6 +115,9 @@ static int (*real_ftime) (struct timeb *);
+ static int (*real_gettimeofday) (struct timeval *, void *);
+ static int (*real_clock_gettime) (clockid_t clk_id, struct timespec *tp);
+ #ifndef __APPLE__
++static int (*real___ftime) (struct timeb *);
++static int (*real___gettimeofday) (struct timeval *, void *);
++static int (*real___clock_gettime) (clockid_t clk_id, struct timespec *tp);
+ #ifdef FAKE_TIMERS
+ static int (*real_timer_settime_22) (int timerid, int flags, const struct itimerspec *new_value,
+ struct itimerspec * old_value);
+@@ -1865,23 +1868,119 @@ int clock_get_time(clock_serv_t clock_serv, mach_timespec_t *cur_timeclockid_t)
+ #ifdef FAKE_INTERNAL_CALLS
+ int __gettimeofday(struct timeval *tv, void *tz)
+ {
+- return gettimeofday(tv, tz);
++ int result;
++
++ /* sanity check */
++ if (tv == NULL)
++ {
++ return -1;
++ }
++
++ /* Check whether we've got a pointer to the real ftime() function yet */
++ if (NULL == real___gettimeofday)
++ { /* dlsym() failed */
++#ifdef DEBUG
++ (void) fprintf(stderr, "faketime problem: original __gettimeofday() not found.\n");
++#endif
++ return -1; /* propagate error to caller */
++ }
++
++ /* initialize our result with the real current time */
++ DONT_FAKE_TIME(result = (*real___gettimeofday)(tv, tz));
++ if (result == -1) return result; /* original function failed */
++
++ /* pass the real current time to our faking version, overwriting it */
++ result = fake_gettimeofday(tv);
++
++ /* return the result to the caller */
++ return result;
+ }
+
+ int __clock_gettime(clockid_t clk_id, struct timespec *tp)
+ {
+- return clock_gettime(clk_id, tp);
++ int result;
++
++ /* sanity check */
++ if (tp == NULL)
++ {
++ return -1;
++ }
++
++ if (NULL == real___clock_gettime)
++ { /* dlsym() failed */
++#ifdef DEBUG
++ (void) fprintf(stderr, "faketime problem: original __clock_gettime() not found.\n");
++#endif
++ return -1; /* propagate error to caller */
++ }
++
++ /* initialize our result with the real current time */
++ DONT_FAKE_TIME(result = (*real___clock_gettime)(clk_id, tp));
++ if (result == -1) return result; /* original function failed */
++
++ /* pass the real current time to our faking version, overwriting it */
++ result = fake_clock_gettime(clk_id, tp);
++
++ /* return the result to the caller */
++ return result;
+ }
+
+-int __ftime(struct timeb *tp)
++time_t __time(time_t *time_tptr)
+ {
+- return ftime(tp);
++ struct timespec tp;
++ time_t result;
++
++ DONT_FAKE_TIME(result = (*real___clock_gettime)(CLOCK_REALTIME, &tp));
++ if (result == -1) return -1;
++
++ /* pass the real current time to our faking version, overwriting it */
++ (void)fake_clock_gettime(CLOCK_REALTIME, &tp);
++
++ if (time_tptr != NULL)
++ {
++ *time_tptr = tp.tv_sec;
++ }
++ return tp.tv_sec;
+ }
+
+-time_t __time(time_t *time_tptr)
++int __ftime(struct timeb *tb)
+ {
+- return time(time_tptr);
++ struct timespec tp;
++ int result;
++
++ /* sanity check */
++ if (tb == NULL)
++ return 0; /* ftime() always returns 0, see manpage */
++
++ /* Check whether we've got a pointer to the real ftime() function yet */
++ if (NULL == real___ftime)
++ { /* dlsym() failed */
++#ifdef DEBUG
++ (void) fprintf(stderr, "faketime problem: original ftime() not found.\n");
++#endif
++ return 0; /* propagate error to caller */
++ }
++
++ /* initialize our TZ result with the real current time */
++ DONT_FAKE_TIME(result = (*real___ftime)(tb));
++ if (result == -1)
++ {
++ return result;
++ }
++
++ DONT_FAKE_TIME(result = (*real_clock_gettime)(CLOCK_REALTIME, &tp));
++ if (result == -1) return -1;
++
++ /* pass the real current time to our faking version, overwriting it */
++ (void)fake_clock_gettime(CLOCK_REALTIME, &tp);
++
++ tb->time = tp.tv_sec;
++ tb->millitm = tp.tv_nsec / 1000000;
++
++ /* return the result to the caller */
++ return result; /* will always be 0 (see manpage) */
+ }
++
+ #endif
+ #endif
+
+--
+1.9.0
+
diff --git a/sys-libs/libfaketime/files/0002-Finish-safe-faking-of-internal-calls.patch b/sys-libs/libfaketime/files/0002-Finish-safe-faking-of-internal-calls.patch
new file mode 100644
index 00000000..57ed04c2
--- /dev/null
+++ b/sys-libs/libfaketime/files/0002-Finish-safe-faking-of-internal-calls.patch
@@ -0,0 +1,40 @@
+From c719a977a724c4d83a8f850784b95377f61abe78 Mon Sep 17 00:00:00 2001
+From: Balint Reczey <balint@balintreczey.hu>
+Date: Wed, 16 Oct 2013 09:33:50 +0200
+Subject: [PATCH 2/2] Finish safe faking of internal calls
+
+---
+ src/libfaketime.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/src/libfaketime.c b/src/libfaketime.c
+index babda94..1f8a6c4 100644
+--- a/src/libfaketime.c
++++ b/src/libfaketime.c
+@@ -115,9 +115,11 @@ static int (*real_ftime) (struct timeb *);
+ static int (*real_gettimeofday) (struct timeval *, void *);
+ static int (*real_clock_gettime) (clockid_t clk_id, struct timespec *tp);
+ #ifndef __APPLE__
++#ifdef FAKE_INTERNAL_CALLS
+ static int (*real___ftime) (struct timeb *);
+ static int (*real___gettimeofday) (struct timeval *, void *);
+ static int (*real___clock_gettime) (clockid_t clk_id, struct timespec *tp);
++#endif
+ #ifdef FAKE_TIMERS
+ static int (*real_timer_settime_22) (int timerid, int flags, const struct itimerspec *new_value,
+ struct itimerspec * old_value);
+@@ -1390,6 +1392,11 @@ void __attribute__ ((constructor)) ftpl_init(void)
+ real_timer_gettime_22 = dlvsym(RTLD_NEXT, "timer_gettime","GLIBC_2.2");
+ real_timer_gettime_233 = dlvsym(RTLD_NEXT, "timer_gettime","GLIBC_2.3.3");
+ #endif
++#ifdef FAKE_INTERNAL_CALLS
++ real___ftime = dlsym(RTLD_NEXT, "__ftime");
++ real___gettimeofday = dlsym(RTLD_NEXT, "__gettimeofday");
++ real___clock_gettime = dlsym(RTLD_NEXT, "__clock_gettime");
++#endif
+ #endif
+
+ ft_shm_init();
+--
+1.9.0
+
diff --git a/sys-libs/libfaketime/libfaketime-0.9.5.ebuild b/sys-libs/libfaketime/libfaketime-0.9.5.ebuild
new file mode 100644
index 00000000..1cac9585
--- /dev/null
+++ b/sys-libs/libfaketime/libfaketime-0.9.5.ebuild
@@ -0,0 +1,31 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/libfaketime/libfaketime-0.9.5.ebuild,v 1.1 2014/03/06 04:16:56 radhermit Exp $
+
+EAPI=5
+
+inherit eutils toolchain-funcs multilib
+
+DESCRIPTION="Report faked system time to programs"
+HOMEPAGE="http://www.code-wizards.com/projects/libfaketime/ https://github.com/wolfcw/libfaketime/"
+SRC_URI="http://www.code-wizards.com/projects/${PN}/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+src_prepare() {
+ epatch "${FILESDIR}"/0001-Fake-__clock_gettime-and-similar-calls-using-__.-cal.patch
+ epatch "${FILESDIR}"/0002-Finish-safe-faking-of-internal-calls.patch
+ tc-export CC
+}
+
+src_install() {
+ dobin src/faketime
+ doman man/faketime.1
+ exeinto /usr/$(get_libdir)/faketime
+ doexe src/${PN}*.so.*
+ dosym ${PN}.so.1 /usr/$(get_libdir)/faketime/${PN}.so
+ dosym ${PN}MT.so.1 /usr/$(get_libdir)/faketime/${PN}MT.so
+ dodoc NEWS README TODO
+}