public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsandbox/wrapper-funcs/, tests/
Date: Sat, 23 Oct 2021 22:19:47 +0000 (UTC)	[thread overview]
Message-ID: <1635027483.afa38c053de48152beef9d8bf6726a4710bcba58.vapier@gentoo> (raw)

commit:     afa38c053de48152beef9d8bf6726a4710bcba58
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 23 07:25:25 2021 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Oct 23 22:18:03 2021 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=afa38c05

libsandbox: add 64-bit time_t wrappers

This intercepts the C library 64-bit time_t interfaces.  The syscall
trace side will need more work first.

Bug: https://bugs.gentoo.org/751241
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsandbox/symbols.h.in                  |  5 +++++
 libsandbox/wrapper-funcs/__futimesat64.c | 13 +++++++++++++
 libsandbox/wrapper-funcs/__lutimes64.c   | 13 +++++++++++++
 libsandbox/wrapper-funcs/__utime64.c     | 13 +++++++++++++
 libsandbox/wrapper-funcs/__utimensat64.c | 13 +++++++++++++
 libsandbox/wrapper-funcs/__utimes64.c    | 13 +++++++++++++
 libsandbox/wrapper-funcs/futimesat.c     |  4 +++-
 libsandbox/wrapper-funcs/lutimes.c       |  4 +++-
 libsandbox/wrapper-funcs/utime.c         |  4 +++-
 libsandbox/wrapper-funcs/utimensat.c     |  4 +++-
 libsandbox/wrapper-funcs/utimes.c        |  4 +++-
 tests/local.mk                           |  2 ++
 tests/test-skel-0.c                      |  4 ++--
 tests/utimensat64-0.c                    |  3 +++
 tests/utimensat64-1.sh                   |  9 +++++++++
 tests/utimensat64.at                     |  1 +
 tests/utimensat64_static-0.c             |  1 +
 tests/utimensat64_static-1.sh            | 10 ++++++++++
 tests/utimensat64_static.at              |  1 +
 19 files changed, 114 insertions(+), 7 deletions(-)

diff --git a/libsandbox/symbols.h.in b/libsandbox/symbols.h.in
index 0fe6eca..40c04e3 100644
--- a/libsandbox/symbols.h.in
+++ b/libsandbox/symbols.h.in
@@ -74,9 +74,14 @@ lremovexattr
 setxattr
 lsetxattr
 utime
+__utime64
 utimes
+__utimes64
 utimensat
+__utimensat64
 futimesat
+__futimesat64
 lutimes
+__lutimes64
 fork
 vfork

diff --git a/libsandbox/wrapper-funcs/__futimesat64.c b/libsandbox/wrapper-funcs/__futimesat64.c
new file mode 100644
index 0000000..9ad791e
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__futimesat64.c
@@ -0,0 +1,13 @@
+/*
+ * __futimesat64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE_AT(SB_NR_FUTIMESAT, STRING_NAME, dirfd, filename, 0)
+#include "futimesat.c"

diff --git a/libsandbox/wrapper-funcs/__lutimes64.c b/libsandbox/wrapper-funcs/__lutimes64.c
new file mode 100644
index 0000000..edab47c
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__lutimes64.c
@@ -0,0 +1,13 @@
+/*
+ * __lutimes64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE(SB_NR_LUTIMES, STRING_NAME, filename)
+#include "lutimes.c"

diff --git a/libsandbox/wrapper-funcs/__utime64.c b/libsandbox/wrapper-funcs/__utime64.c
new file mode 100644
index 0000000..4e1b573
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__utime64.c
@@ -0,0 +1,13 @@
+/*
+ * __utime64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE(SB_NR_UTIME, STRING_NAME, filename)
+#include "utime.c"

diff --git a/libsandbox/wrapper-funcs/__utimensat64.c b/libsandbox/wrapper-funcs/__utimensat64.c
new file mode 100644
index 0000000..4ef1c69
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__utimensat64.c
@@ -0,0 +1,13 @@
+/*
+ * __utimensat64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE_AT(SB_NR_UTIMENSAT, STRING_NAME, dirfd, filename, flags)
+#include "utimensat.c"

diff --git a/libsandbox/wrapper-funcs/__utimes64.c b/libsandbox/wrapper-funcs/__utimes64.c
new file mode 100644
index 0000000..3fa6688
--- /dev/null
+++ b/libsandbox/wrapper-funcs/__utimes64.c
@@ -0,0 +1,13 @@
+/*
+ * __utimes64() wrapper.
+ *
+ * Copyright 1999-2021 Gentoo Foundation
+ * Licensed under the GPL-2
+ */
+
+/*
+ * NB: Reusing the 32-bit time interface isn't entirely correct as the 64-bit time interface uses a
+ * different structure, but we never decode the time values in sandbox, so it doesn't matter to use.
+ */
+#define WRAPPER_SAFE() _SB_SAFE(SB_NR_UTIMES, STRING_NAME, filename)
+#include "utimes.c"

diff --git a/libsandbox/wrapper-funcs/futimesat.c b/libsandbox/wrapper-funcs/futimesat.c
index 6f6481b..bc1a966 100644
--- a/libsandbox/wrapper-funcs/futimesat.c
+++ b/libsandbox/wrapper-funcs/futimesat.c
@@ -7,5 +7,7 @@
 
 #define WRAPPER_ARGS_PROTO int dirfd, const char *filename, const struct timeval times[2]
 #define WRAPPER_ARGS dirfd, filename, times
-#define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, 0)
+#ifndef WRAPPER_SAFE
+# define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, 0)
+#endif
 #include "__wrapper_simple.c"

diff --git a/libsandbox/wrapper-funcs/lutimes.c b/libsandbox/wrapper-funcs/lutimes.c
index 3192a33..fb9ae68 100644
--- a/libsandbox/wrapper-funcs/lutimes.c
+++ b/libsandbox/wrapper-funcs/lutimes.c
@@ -7,5 +7,7 @@
 
 #define WRAPPER_ARGS_PROTO const char *filename, const struct timeval times[2]
 #define WRAPPER_ARGS filename, times
-#define WRAPPER_SAFE() SB_SAFE(filename)
+#ifndef WRAPPER_SAFE
+# define WRAPPER_SAFE() SB_SAFE(filename)
+#endif
 #include "__wrapper_simple.c"

diff --git a/libsandbox/wrapper-funcs/utime.c b/libsandbox/wrapper-funcs/utime.c
index f0a6814..4bbf374 100644
--- a/libsandbox/wrapper-funcs/utime.c
+++ b/libsandbox/wrapper-funcs/utime.c
@@ -7,5 +7,7 @@
 
 #define WRAPPER_ARGS_PROTO const char *filename, const struct utimbuf *times
 #define WRAPPER_ARGS filename, times
-#define WRAPPER_SAFE() SB_SAFE(filename)
+#ifndef WRAPPER_SAFE
+# define WRAPPER_SAFE() SB_SAFE(filename)
+#endif
 #include "__wrapper_simple.c"

diff --git a/libsandbox/wrapper-funcs/utimensat.c b/libsandbox/wrapper-funcs/utimensat.c
index 840ff18..3baf89c 100644
--- a/libsandbox/wrapper-funcs/utimensat.c
+++ b/libsandbox/wrapper-funcs/utimensat.c
@@ -7,5 +7,7 @@
 
 #define WRAPPER_ARGS_PROTO int dirfd, const char *filename, const struct timespec times[2], int flags
 #define WRAPPER_ARGS dirfd, filename, times, flags
-#define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, flags)
+#ifndef WRAPPER_SAFE
+# define WRAPPER_SAFE() SB_SAFE_AT(dirfd, filename, flags)
+#endif
 #include "__wrapper_simple.c"

diff --git a/libsandbox/wrapper-funcs/utimes.c b/libsandbox/wrapper-funcs/utimes.c
index b117895..902c6f5 100644
--- a/libsandbox/wrapper-funcs/utimes.c
+++ b/libsandbox/wrapper-funcs/utimes.c
@@ -7,5 +7,7 @@
 
 #define WRAPPER_ARGS_PROTO const char *filename, const struct timeval times[2]
 #define WRAPPER_ARGS filename, times
-#define WRAPPER_SAFE() SB_SAFE(filename)
+#ifndef WRAPPER_SAFE
+# define WRAPPER_SAFE() SB_SAFE(filename)
+#endif
 #include "__wrapper_simple.c"

diff --git a/tests/local.mk b/tests/local.mk
index aa2acac..86a8a65 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -81,7 +81,9 @@ check_PROGRAMS += \
 	%D%/unlinkat-0 \
 	%D%/utime-0 \
 	%D%/utimensat-0 \
+	%D%/utimensat64-0 \
 	%D%/utimensat_static-0 \
+	%D%/utimensat64_static-0 \
 	%D%/utimes-0 \
 	%D%/vfork-0 \
 	\

diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c
index 96e42ae..de88cf4 100644
--- a/tests/test-skel-0.c
+++ b/tests/test-skel-0.c
@@ -144,8 +144,8 @@ struct timespec *parse_timespec(const char *s)
 	if (!strcmp(s, "NOW")) {
 		times->tv_sec = time(0);
 	} else {
-		long sec = 0, nsec = 0;
-		sscanf(s, "%li,%li", &sec, &nsec);
+		int64_t sec = 0, nsec = 0;
+		sscanf(s, "%" PRIi64 ",%" PRIi64, &sec, &nsec);
 		times->tv_sec = sec;
 		times->tv_nsec = nsec;
 	}

diff --git a/tests/utimensat64-0.c b/tests/utimensat64-0.c
new file mode 100644
index 0000000..bbacef5
--- /dev/null
+++ b/tests/utimensat64-0.c
@@ -0,0 +1,3 @@
+#define _TIME_BITS 64
+#define _FILE_OFFSET_BITS 64
+#include "utimensat-0.c"

diff --git a/tests/utimensat64-1.sh b/tests/utimensat64-1.sh
new file mode 100755
index 0000000..2aebc5f
--- /dev/null
+++ b/tests/utimensat64-1.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# basic functionality check
+
+addwrite $PWD
+
+touch -r / file || exit 1
+utimensat64-0 0 AT_FDCWD . NULL 0 || exit 1
+utimensat64-0 0 AT_FDCWD file NULL 0 || exit 1
+[ file -nt / ]

diff --git a/tests/utimensat64.at b/tests/utimensat64.at
new file mode 100644
index 0000000..081d7d2
--- /dev/null
+++ b/tests/utimensat64.at
@@ -0,0 +1 @@
+SB_CHECK(1)

diff --git a/tests/utimensat64_static-0.c b/tests/utimensat64_static-0.c
new file mode 100644
index 0000000..73e7602
--- /dev/null
+++ b/tests/utimensat64_static-0.c
@@ -0,0 +1 @@
+#include "utimensat64-0.c"

diff --git a/tests/utimensat64_static-1.sh b/tests/utimensat64_static-1.sh
new file mode 100755
index 0000000..7b0355c
--- /dev/null
+++ b/tests/utimensat64_static-1.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# basic functionality check
+[ "${at_xfail}" = "yes" ] && exit 77 # see trace-0
+
+addwrite $PWD
+
+touch -r / file || exit 1
+utimensat64_static-0 0 AT_FDCWD . NULL 0 || exit 1
+utimensat64_static-0 0 AT_FDCWD file NULL 0 || exit 1
+[ file -nt / ]

diff --git a/tests/utimensat64_static.at b/tests/utimensat64_static.at
new file mode 100644
index 0000000..081d7d2
--- /dev/null
+++ b/tests/utimensat64_static.at
@@ -0,0 +1 @@
+SB_CHECK(1)


             reply	other threads:[~2021-10-23 22:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-23 22:19 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-12-22  3:41 [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsandbox/wrapper-funcs/, tests/ Mike Gilbert
2024-12-22  3:49 [gentoo-commits] proj/sandbox:stable-2.x commit in: tests/, libsandbox/, libsandbox/wrapper-funcs/ Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master commit in: libsandbox/, libsandbox/wrapper-funcs/, tests/ Mike Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1635027483.afa38c053de48152beef9d8bf6726a4710bcba58.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox