aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fchown-0.c')
-rw-r--r--tests/fchown-0.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/fchown-0.c b/tests/fchown-0.c
new file mode 100644
index 0000000..7fdca73
--- /dev/null
+++ b/tests/fchown-0.c
@@ -0,0 +1,34 @@
+/*
+ * https://bugs.gentoo.org/599706
+ *
+ */
+
+#include "headers.h"
+
+int main(int argc, char *argv[])
+{
+ if (argc < 3)
+ return -2;
+
+ uid_t uid = atoi(argv[1]);
+ gid_t gid = atoi(argv[2]);
+ /* The sandbox catches this:
+ *
+ * int fd = open(argv[3], O_RDWR);
+ *
+ * And it /should/ catch this:
+ *
+ * int fd = open(argv[3], O_RDONLY);
+ *
+ * ...but the latter only works when /proc/self/fd/%i
+ * is available.
+ */
+#ifdef SANDBOX_PROC_SELF_FD
+ int fd = open(argv[3], O_RDONLY);
+#else
+ int fd = open(argv[3], O_RDWR);
+#endif
+ int fchown_result = fchown(fd, uid, gid);
+ close(fd);
+ return fchown_result;
+}