#!/bin/gawk
#
-# Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
+# This file is part of caps strace test.
+#
+# Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
BEGIN {
cap = "(0|CAP_[A-Z_]+(\\|CAP_[A-Z_]+)*|CAP_[A-Z_]+(\\|CAP_[A-Z_]+){37}\\|0xffffffc0)"
- r[1] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, \\{" cap ", " cap ", " cap "\\}\\) = 0$"
+ s_efault = "-1 EFAULT (Bad address)"
+ r_efault = "-1 EFAULT \\(Bad address\\)"
+ r_addr = "0x[[:xdigit:]]+"
+ s[1] = "capget(NULL, NULL) = " s_efault
+ r[2] = "^capget\\(" r_addr ", " r_addr "\\) = " r_efault
+ r[3] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, " r_addr "\\) = " r_efault
+ r[4] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, \\{" cap ", " cap ", " cap "\\}\\) = 0$"
capset_data = "{CAP_DAC_OVERRIDE|CAP_WAKE_ALARM, CAP_DAC_READ_SEARCH|CAP_BLOCK_SUSPEND, 0}"
- s[2] = "capset({_LINUX_CAPABILITY_VERSION_3, 0}, " capset_data ") = -1 EPERM (Operation not permitted)"
- s[3] = "+++ exited with 0 +++"
+ s[5] = "capset({_LINUX_CAPABILITY_VERSION_3, 0}, " capset_data ") = -1 EPERM (Operation not permitted)"
+ s[6] = "+++ exited with 0 +++"
- lines = 3
+ lines = 6
fail = 0
}
/*
+ * This file is part of caps strace test.
+ *
* Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
#include "tests.h"
#include <errno.h>
+#include <string.h>
extern int capget(int *, int *);
extern int capset(int *, const int *);
int
main(void)
{
- int unused[6];
const int data[] = { 2, 4, 0, 8, 16, 0 };
const int v3 = 0x20080522;
- int head[] = { v3, 0 };
- if (capget(head, unused))
+ int * const head = tail_alloc(sizeof(int) * 2);
+ head[0] = v3;
+ head[1] = 0;
+ int * const tail_data = tail_alloc(sizeof(data));
+
+ capget(NULL, NULL);
+ capget(head + 2, tail_data);
+ capget(head, tail_data + ARRAY_SIZE(data));
+
+ if (capget(head, tail_data))
perror_msg_and_skip("capget");
if (head[0] != v3)
error_msg_and_skip("capget: v3 expected");
+
+ memcpy(tail_data, data, sizeof(data));
if (capset(head, data) == 0 || errno != EPERM)
perror_msg_and_skip("capset");