On 11/28/2014 11:33 AM, Han Pingtian wrote:
> On Mon, Nov 24, 2014 at 05:53:32PM +0300, Stanislav Kholmanskikh wrote:
>> Hi.
>>
>> In general, it looks good.
>>
>> I have only one comment, that it's possible that the uid/gid values we pass
>> to the syscall may not fit into UID_T/GID_T. For example, when we get uid of
>> nobody user in runtime and pass it to chown() or etc.
>>
>> Yes, it's more like an artificial case, but it's.
>>
>> We have UID16_CHECK and GID16_CHECK macros to check if the uid/gid fits the
>> compat mode.
>>
>> What do you think about using it in test cases chown01, chown03, chown04,
>> fchown01, fchown03, fchown04, setresgid*, setresuid* ?
>>
>> Thank you.
>
> Please review new patch which included UID16_CHECK and GID16_CHECK.
>
> Thanks.

Hi!

I pushed your patch with TCID_DEFINE added (overlooked it at that time), 
and also pushed a follow-up patch which:
  * fixes setresuid02_16, setresuid03_16, setresuid04_16 - they do 
testing inside their children.
  * explicitly declares setresuid(), setresgid() in compat_16.h. This is 
to manage compilation warnings.

Tested in OL6 with 2.6.39-400.215.11.el6uek.x86_64 and 
2.6.39-400.214.5.el6uek.i686 kernels.

Thank you.


>
>>From f65d580f11791c4b2728018a2f8e52398c25d97a Mon Sep 17 00:00:00 2001
> From: Han Pingtian <ha...@linux.vnet.ibm.com>
> Date: Fri, 21 Nov 2014 15:50:23 +0800
> Subject: [PATCH] fix some syscall tests for 16-bit compat testing
>
> Some syscall testcases have been compiled for 16-bit compat testing,
> but doesn't change the code yet. This fix try to add proper code to let
> them support this testing.
>
> Signed-off-by: Han Pingtian <ha...@linux.vnet.ibm.com>
> ---
>   testcases/kernel/syscalls/chown/chown01.c         |  7 ++++---
>   testcases/kernel/syscalls/chown/chown02.c         |  3 ++-
>   testcases/kernel/syscalls/chown/chown03.c         |  7 ++++---
>   testcases/kernel/syscalls/chown/chown04.c         |  7 ++++---
>   testcases/kernel/syscalls/chown/chown05.c         |  3 ++-
>   testcases/kernel/syscalls/fchown/fchown01.c       |  6 +++++-
>   testcases/kernel/syscalls/fchown/fchown02.c       |  3 ++-
>   testcases/kernel/syscalls/fchown/fchown03.c       |  5 +++--
>   testcases/kernel/syscalls/fchown/fchown04.c       |  6 +++++-
>   testcases/kernel/syscalls/fchown/fchown05.c       |  3 ++-
>   testcases/kernel/syscalls/lchown/lchown03.c       |  6 +++++-
>   testcases/kernel/syscalls/setresgid/setresgid01.c |  7 ++++---
>   testcases/kernel/syscalls/setresgid/setresgid02.c |  9 +++++----
>   testcases/kernel/syscalls/setresgid/setresgid03.c |  7 ++++---
>   testcases/kernel/syscalls/setresgid/setresgid04.c |  5 ++++-
>   testcases/kernel/syscalls/setresuid/setresuid01.c |  9 +++++----
>   testcases/kernel/syscalls/setresuid/setresuid02.c |  7 ++++---
>   testcases/kernel/syscalls/setresuid/setresuid03.c |  8 ++++----
>   testcases/kernel/syscalls/setresuid/setresuid04.c | 11 +++++++----
>   testcases/kernel/syscalls/setresuid/setresuid05.c |  5 ++++-
>   testcases/kernel/syscalls/utils/compat_16.h       | 20 ++++++++++++++++++++
>   21 files changed, 99 insertions(+), 45 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/chown/chown01.c 
> b/testcases/kernel/syscalls/chown/chown01.c
> index ef728e1..5a77a98 100644
> --- a/testcases/kernel/syscalls/chown/chown01.c
> +++ b/testcases/kernel/syscalls/chown/chown01.c
> @@ -117,6 +117,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   char *TCID = "chown01";
>   int TST_TOTAL = 1;
> @@ -145,7 +146,7 @@ int main(int ac, char **av)
>
>               tst_count = 0;
>
> -             TEST(chown(fname, uid, gid));
> +             TEST(CHOWN(cleanup, fname, uid, gid));
>
>               if (TEST_RETURN == -1) {
>                       tst_resm(TFAIL | TTERRNO, "chown(%s, %d,%d) failed",
> @@ -170,8 +171,8 @@ static void setup(void)
>
>       tst_tmpdir();
>
> -     uid = geteuid();
> -     gid = getegid();
> +     UID16_CHECK((uid = geteuid()), "chown", cleanup)
> +     GID16_CHECK((gid = getegid()), "chown", cleanup)
>
>       sprintf(fname, "t_%d", getpid());
>
> diff --git a/testcases/kernel/syscalls/chown/chown02.c 
> b/testcases/kernel/syscalls/chown/chown02.c
> index 339b2e8..30394ec 100644
> --- a/testcases/kernel/syscalls/chown/chown02.c
> +++ b/testcases/kernel/syscalls/chown/chown02.c
> @@ -79,6 +79,7 @@
>
>   #include "test.h"
>   #include "usctest.h"
> +#include "compat_16.h"
>
>   #define FILE_MODE   (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
>   #define NEW_PERMS1  (S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
> @@ -142,7 +143,7 @@ int main(int ac, char **av)
>                        * Call chown(2) with different user id and
>                        * group id (numeric values) to set it on testfile.
>                        */
> -                     TEST(chown(file_name, user_id, group_id));
> +                     TEST(CHOWN(cleanup, file_name, user_id, group_id));
>
>                       if (TEST_RETURN == -1) {
>                               tst_resm(TFAIL | TTERRNO,
> diff --git a/testcases/kernel/syscalls/chown/chown03.c 
> b/testcases/kernel/syscalls/chown/chown03.c
> index 9780c2f..59b1d62 100644
> --- a/testcases/kernel/syscalls/chown/chown03.c
> +++ b/testcases/kernel/syscalls/chown/chown03.c
> @@ -82,6 +82,7 @@
>
>   #include "test.h"
>   #include "usctest.h"
> +#include "compat_16.h"
>
>   #define FILE_MODE   (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
>   #define NEW_PERMS   (S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID)
> @@ -112,10 +113,10 @@ int main(int ac, char **av)
>
>               tst_count = 0;
>
> -             user_id = geteuid();
> -             group_id = getegid();
> +             UID16_CHECK((user_id = geteuid()), "chown", cleanup)
> +             GID16_CHECK((group_id = getegid()), "chown", cleanup)
>
> -             TEST(chown(TESTFILE, -1, group_id));
> +             TEST(CHOWN(cleanup, TESTFILE, -1, group_id));
>
>               if (TEST_RETURN == -1) {
>                       tst_resm(TFAIL | TTERRNO, "chown(%s, ..) failed",
> diff --git a/testcases/kernel/syscalls/chown/chown04.c 
> b/testcases/kernel/syscalls/chown/chown04.c
> index 1459227..b6d7f3d 100644
> --- a/testcases/kernel/syscalls/chown/chown04.c
> +++ b/testcases/kernel/syscalls/chown/chown04.c
> @@ -55,6 +55,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   #define MODE_RWX             (S_IRWXU|S_IRWXG|S_IRWXO)
>   #define FILE_MODE            (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
> @@ -111,14 +112,14 @@ int main(int ac, char **av)
>
>       TEST_EXP_ENOS(exp_enos);
>
> -     user_id = geteuid();
> -     group_id = getegid();
> +     UID16_CHECK((user_id = geteuid()), "chown", cleanup)
> +     GID16_CHECK((group_id = getegid()), "chown", cleanup)
>
>       for (lc = 0; TEST_LOOPING(lc); lc++) {
>               tst_count = 0;
>
>               for (i = 0; i < TST_TOTAL; i++) {
> -                     TEST(chown(tc[i].pathname, user_id, group_id));
> +                     TEST(CHOWN(cleanup, tc[i].pathname, user_id, group_id));
>
>                       if (TEST_RETURN == 0) {
>                               tst_resm(TFAIL, "chown succeeded unexpectedly");
> diff --git a/testcases/kernel/syscalls/chown/chown05.c 
> b/testcases/kernel/syscalls/chown/chown05.c
> index 92e1811..3ec4f13 100644
> --- a/testcases/kernel/syscalls/chown/chown05.c
> +++ b/testcases/kernel/syscalls/chown/chown05.c
> @@ -77,6 +77,7 @@
>
>   #include "test.h"
>   #include "usctest.h"
> +#include "compat_16.h"
>
>   #define FILE_MODE   (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
>   #define TESTFILE    "testfile"
> @@ -121,7 +122,7 @@ int main(int ac, char **av)
>                       user_id = test_cases[i].user_id;
>                       group_id = test_cases[i].group_id;
>
> -                     TEST(chown(TESTFILE, user_id, group_id));
> +                     TEST(CHOWN(cleanup, TESTFILE, user_id, group_id));
>
>                       if (TEST_RETURN == -1) {
>                               tst_resm(TFAIL | TTERRNO, "chown failed");
> diff --git a/testcases/kernel/syscalls/fchown/fchown01.c 
> b/testcases/kernel/syscalls/fchown/fchown01.c
> index be620d7..df74635 100644
> --- a/testcases/kernel/syscalls/fchown/fchown01.c
> +++ b/testcases/kernel/syscalls/fchown/fchown01.c
> @@ -42,6 +42,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   static void setup(void);
>   static void cleanup(void);
> @@ -65,7 +66,10 @@ int main(int ac, char **av)
>
>               tst_count = 0;
>
> -             TEST(fchown(fd, geteuid(), getegid()));
> +             UID16_CHECK(geteuid(), "fchown", cleanup)
> +             GID16_CHECK(getegid(), "fchown", cleanup)
> +
> +             TEST(FCHOWN(cleanup, fd, geteuid(), getegid()));
>
>               if (TEST_RETURN == -1) {
>                       tst_resm(TFAIL | TTERRNO, "fchown failed");
> diff --git a/testcases/kernel/syscalls/fchown/fchown02.c 
> b/testcases/kernel/syscalls/fchown/fchown02.c
> index fd14ba1..0c1782d 100644
> --- a/testcases/kernel/syscalls/fchown/fchown02.c
> +++ b/testcases/kernel/syscalls/fchown/fchown02.c
> @@ -38,6 +38,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   #define FILE_MODE   S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
>   #define NEW_PERMS1  S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID
> @@ -71,7 +72,7 @@ static void verify_fchown(struct test_case *t)
>   {
>       struct stat stat_buf;
>
> -     TEST(fchown(*t->fd, t->user_id, t->group_id));
> +     TEST(FCHOWN(cleanup, *t->fd, t->user_id, t->group_id));
>
>       if (TEST_RETURN == -1) {
>               tst_resm(TFAIL | TTERRNO, "fchown() Fails on %s", t->pathname);
> diff --git a/testcases/kernel/syscalls/fchown/fchown03.c 
> b/testcases/kernel/syscalls/fchown/fchown03.c
> index 3a75093..8c68f12 100644
> --- a/testcases/kernel/syscalls/fchown/fchown03.c
> +++ b/testcases/kernel/syscalls/fchown/fchown03.c
> @@ -41,6 +41,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   #define FILE_MODE (mode_t)(S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
>   #define NEW_PERMS (mode_t)(S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID)
> @@ -75,9 +76,9 @@ int main(int ac, char **av)
>               tst_count = 0;
>
>               user_id = geteuid();
> -             group_id = getegid();
> +             GID16_CHECK((group_id = getegid()), "fchown", cleanup)
>
> -             TEST(fchown(fildes, -1, group_id));
> +             TEST(FCHOWN(cleanup, fildes, -1, group_id));
>
>               if (TEST_RETURN == -1) {
>                       tst_resm(TFAIL, "fchown() on %s Fails, errno=%d",
> diff --git a/testcases/kernel/syscalls/fchown/fchown04.c 
> b/testcases/kernel/syscalls/fchown/fchown04.c
> index 0829944..4fe7fdd 100644
> --- a/testcases/kernel/syscalls/fchown/fchown04.c
> +++ b/testcases/kernel/syscalls/fchown/fchown04.c
> @@ -45,6 +45,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   #define DIR_MODE    (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
>                        S_IXGRP|S_IROTH|S_IXOTH)
> @@ -140,7 +141,10 @@ static void setup(void)
>
>   static void fchown_verify(int i)
>   {
> -     TEST(fchown(*test_cases[i].fd, geteuid(), getegid()));
> +     UID16_CHECK(geteuid(), "fchown", cleanup)
> +     GID16_CHECK(getegid(), "fchown", cleanup)
> +
> +     TEST(FCHOWN(cleanup, *test_cases[i].fd, geteuid(), getegid()));
>
>       if (TEST_RETURN == -1) {
>               if (TEST_ERRNO == test_cases[i].exp_errno) {
> diff --git a/testcases/kernel/syscalls/fchown/fchown05.c 
> b/testcases/kernel/syscalls/fchown/fchown05.c
> index 67a745a..47d5b00 100644
> --- a/testcases/kernel/syscalls/fchown/fchown05.c
> +++ b/testcases/kernel/syscalls/fchown/fchown05.c
> @@ -34,6 +34,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   #define FILE_MODE   S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
>   #define TESTFILE    "testfile"
> @@ -80,7 +81,7 @@ int main(int ac, char **av)
>                       user_id = tc[i].user_id;
>                       group_id = tc[i].group_id;
>
> -                     TEST(fchown(fildes, user_id, group_id));
> +                     TEST(FCHOWN(cleanup, fildes, user_id, group_id));
>
>                       if (TEST_RETURN == -1) {
>                               tst_resm(TFAIL | TTERRNO,
> diff --git a/testcases/kernel/syscalls/lchown/lchown03.c 
> b/testcases/kernel/syscalls/lchown/lchown03.c
> index 9e4d6f9..d70847b 100644
> --- a/testcases/kernel/syscalls/lchown/lchown03.c
> +++ b/testcases/kernel/syscalls/lchown/lchown03.c
> @@ -40,6 +40,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   #define DIR_MODE    (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
>                        S_IXGRP|S_IROTH|S_IXOTH)
> @@ -124,7 +125,10 @@ static void setup(void)
>
>   static void lchown_verify(const struct test_case_t *test)
>   {
> -     TEST(lchown(test->pathname, geteuid(), getegid()));
> +     UID16_CHECK(geteuid(), "lchown", cleanup)
> +     GID16_CHECK(getegid(), "lchown", cleanup)
> +
> +     TEST(LCHOWN(cleanup, test->pathname, geteuid(), getegid()));
>
>       if (TEST_RETURN != -1) {
>               tst_resm(TFAIL, "lchown() returned %ld, expected -1, errno=%d",
> diff --git a/testcases/kernel/syscalls/setresgid/setresgid01.c 
> b/testcases/kernel/syscalls/setresgid/setresgid01.c
> index f9c62a0..440dd43 100644
> --- a/testcases/kernel/syscalls/setresgid/setresgid01.c
> +++ b/testcases/kernel/syscalls/setresgid/setresgid01.c
> @@ -76,6 +76,7 @@
>   #include <unistd.h>
>   #include "test.h"
>   #include "usctest.h"
> +#include "compat_16.h"
>
>   #define EXP_RET_VAL 0
>
> @@ -131,7 +132,7 @@ int main(int argc, char **argv)
>
>               for (testno = 0; testno < TST_TOTAL; ++testno) {
>
> -                     TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
> +                     TEST(SETRESGID(cleanup, *tdat[testno].rgid, 
> *tdat[testno].egid,
>                                      *tdat[testno].sgid));
>
>                       if (TEST_RETURN == EXP_RET_VAL) {
> @@ -195,14 +196,14 @@ void setup(void)
>
>       }
>       root = *passwd_p;
> -     root_gid = root.pw_gid;
> +     GID16_CHECK((root_gid = root.pw_gid), "setresgid", cleanup)
>
>       if ((passwd_p = getpwnam("nobody")) == NULL) {
>               tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
>
>       }
>       nobody = *passwd_p;
> -     nobody_gid = nobody.pw_gid;
> +     GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
>
>       /* Pause if that option was specified
>        * TEST_PAUSE contains the code to fork the test with the -c option.
> diff --git a/testcases/kernel/syscalls/setresgid/setresgid02.c 
> b/testcases/kernel/syscalls/setresgid/setresgid02.c
> index 754fca1..113544e 100644
> --- a/testcases/kernel/syscalls/setresgid/setresgid02.c
> +++ b/testcases/kernel/syscalls/setresgid/setresgid02.c
> @@ -81,6 +81,7 @@
>   #include <unistd.h>
>   #include "test.h"
>   #include "usctest.h"
> +#include "compat_16.h"
>
>   #define EXP_RET_VAL 0
>
> @@ -138,7 +139,7 @@ int main(int argc, char **argv)
>
>               for (testno = 0; testno < TST_TOTAL; ++testno) {
>
> -                     TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
> +                     TEST(SETRESGID(cleanup, *tdat[testno].rgid, 
> *tdat[testno].egid,
>                                      *tdat[testno].sgid));
>
>                       if (TEST_RETURN == EXP_RET_VAL) {
> @@ -202,21 +203,21 @@ void setup(void)
>
>       }
>       root = *passwd_p;
> -     root_gid = root.pw_gid;
> +     GID16_CHECK((root_gid = root.pw_gid), "setresgid", cleanup)
>
>       if ((passwd_p = getpwnam("bin")) == NULL) {
>               tst_brkm(TBROK, NULL, "bin user id doesn't exist");
>
>       }
>       bin = *passwd_p;
> -     bin_gid = bin.pw_gid;
> +     GID16_CHECK((bin_gid = bin.pw_gid), "setresgid", cleanup)
>
>       if ((passwd_p = getpwnam("nobody")) == NULL) {
>               tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
>
>       }
>       nobody = *passwd_p;
> -     nobody_gid = nobody.pw_gid;
> +     GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
>
>       /* Set effective/saved gid to nobody */
>       if (setresgid(-1, nobody_gid, nobody_gid) == -1) {
> diff --git a/testcases/kernel/syscalls/setresgid/setresgid03.c 
> b/testcases/kernel/syscalls/setresgid/setresgid03.c
> index 32d7995..aa67081 100644
> --- a/testcases/kernel/syscalls/setresgid/setresgid03.c
> +++ b/testcases/kernel/syscalls/setresgid/setresgid03.c
> @@ -81,6 +81,7 @@
>   #include <unistd.h>
>   #include "test.h"
>   #include "usctest.h"
> +#include "compat_16.h"
>
>   #define EXP_RET_VAL -1
>   #define EXP_ERRNO   EPERM
> @@ -131,7 +132,7 @@ int main(int argc, char **argv)
>
>               for (testno = 0; testno < TST_TOTAL; ++testno) {
>
> -                     TEST(setresgid(*tdat[testno].rgid, *tdat[testno].egid,
> +                     TEST(SETRESGID(cleanup, *tdat[testno].rgid, 
> *tdat[testno].egid,
>                                      *tdat[testno].sgid));
>
>                       TEST_ERROR_LOG(TEST_ERRNO);
> @@ -207,14 +208,14 @@ void setup(void)
>
>       }
>       bin = *passwd_p;
> -     bin_gid = bin.pw_gid;
> +     GID16_CHECK((bin_gid = bin.pw_gid), "setresgid", cleanup)
>
>       if ((passwd_p = getpwnam("nobody")) == NULL) {
>               tst_brkm(TBROK, NULL, "nobody user id doesn't exist");
>
>       }
>       nobody = *passwd_p;
> -     nobody_gid = nobody.pw_gid;
> +     GID16_CHECK((nobody_gid = nobody.pw_gid), "setresgid", cleanup)
>
>       /* set the expected errnos... */
>       TEST_EXP_ENOS(exp_enos);
> diff --git a/testcases/kernel/syscalls/setresgid/setresgid04.c 
> b/testcases/kernel/syscalls/setresgid/setresgid04.c
> index 4e71910..019aaeb 100644
> --- a/testcases/kernel/syscalls/setresgid/setresgid04.c
> +++ b/testcases/kernel/syscalls/setresgid/setresgid04.c
> @@ -30,6 +30,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   char *TCID = "setresgid04";
>   int TST_TOTAL = 1;
> @@ -70,13 +71,15 @@ static void setup(void)
>       tst_tmpdir();
>
>       ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
> +
> +     GID16_CHECK(ltpuser->pw_gid, "setresgid", cleanup)
>   }
>
>   static void setresgid_verify(void)
>   {
>       struct stat buf;
>
> -     TEST(setresgid(-1, ltpuser->pw_gid, -1));
> +     TEST(SETRESGID(cleanup, -1, ltpuser->pw_gid, -1));
>
>       if (TEST_RETURN != 0) {
>               tst_resm(TFAIL | TTERRNO, "setresgid failed unexpectedly");
> diff --git a/testcases/kernel/syscalls/setresuid/setresuid01.c 
> b/testcases/kernel/syscalls/setresuid/setresuid01.c
> index 39e1ac3..027aee3 100644
> --- a/testcases/kernel/syscalls/setresuid/setresuid01.c
> +++ b/testcases/kernel/syscalls/setresuid/setresuid01.c
> @@ -69,6 +69,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include <errno.h>
> +#include "compat_16.h"
>
>   char *TCID = "setresuid01";
>
> @@ -140,7 +141,7 @@ int main(int ac, char **av)
>
>               for (i = 0; i < TST_TOTAL; i++) {
>                       /* Set the real, effective or user id */
> -                     TEST(setresuid(*test_data[i].real_uid,
> +                     TEST(SETRESUID(cleanup, *test_data[i].real_uid,
>                                      *test_data[i].eff_uid,
>                                      *test_data[i].sav_uid));
>
> @@ -185,13 +186,13 @@ void setup(void)
>       TEST_EXP_ENOS(exp_enos);
>
>       root = *(getpwnam("root"));
> -     root_pw_uid = root.pw_uid;
> +     UID16_CHECK((root_pw_uid = root.pw_uid), "setresuid", cleanup)
>
>       nobody = *(getpwnam("nobody"));
> -     nobody_pw_uid = nobody.pw_uid;
> +     UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
>
>       bin = *(getpwnam("bin"));
> -     bin_pw_uid = bin.pw_uid;
> +     UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
>
>       /* Pause if that option was specified
>        * TEST_PAUSE contains the code to fork the test with the -c option.
> diff --git a/testcases/kernel/syscalls/setresuid/setresuid02.c 
> b/testcases/kernel/syscalls/setresuid/setresuid02.c
> index 0837c9e..bb50633 100644
> --- a/testcases/kernel/syscalls/setresuid/setresuid02.c
> +++ b/testcases/kernel/syscalls/setresuid/setresuid02.c
> @@ -65,6 +65,7 @@
>   #include "usctest.h"
>   #include <errno.h>
>   #include <sys/wait.h>
> +#include "compat_16.h"
>
>   char *TCID = "setresuid02";
>
> @@ -140,7 +141,7 @@ int main(int ac, char **av)
>                       for (i = 0; i < TST_TOTAL; i++) {
>
>                               /* Set the real, effective or saved user id */
> -                             TEST(setresuid(*test_data[i].real_uid,
> +                             TEST(SETRESUID(cleanup, *test_data[i].real_uid,
>                                              *test_data[i].eff_uid,
>                                              *test_data[i].sav_uid));
>
> @@ -196,10 +197,10 @@ void setup(void)
>       }
>
>       nobody = *(getpwnam("nobody"));
> -     nobody_pw_uid = nobody.pw_uid;
> +     UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
>
>       bin = *(getpwnam("bin"));
> -     bin_pw_uid = bin.pw_uid;
> +     UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
>
>       /* Pause if that option was specified
>        * TEST_PAUSE contains the code to fork the test with the -i option.
> diff --git a/testcases/kernel/syscalls/setresuid/setresuid03.c 
> b/testcases/kernel/syscalls/setresuid/setresuid03.c
> index f624253..c679b82 100644
> --- a/testcases/kernel/syscalls/setresuid/setresuid03.c
> +++ b/testcases/kernel/syscalls/setresuid/setresuid03.c
> @@ -150,7 +150,7 @@ int main(int ac, char **av)
>                       for (i = 0; i < TST_TOTAL; i++) {
>
>                               /* Set the real, effective or saved user id */
> -                             TEST(setresuid(*test_data[i].real_uid,
> +                             TEST(SETRESUID(cleanup, *test_data[i].real_uid,
>                                              *test_data[i].eff_uid,
>                                              *test_data[i].sav_uid));
>
> @@ -207,13 +207,13 @@ void setup(void)
>       }
>
>       root = *(getpwnam("root"));
> -     root_pw_uid = root.pw_uid;
> +     UID16_CHECK((root_pw_uid = root.pw_uid), "setresuid", cleanup)
>
>       nobody = *(getpwnam("nobody"));
> -     nobody_pw_uid = nobody.pw_uid;
> +     UID16_CHECK((nobody_pw_uid = nobody.pw_uid), "setresuid", cleanup)
>
>       bin = *(getpwnam("bin"));
> -     bin_pw_uid = bin.pw_uid;
> +     UID16_CHECK((bin_pw_uid = bin.pw_uid), "setresuid", cleanup)
>
>       /* Pause if that option was specified
>        * TEST_PAUSE contains the code to fork the test with the -i option.
> diff --git a/testcases/kernel/syscalls/setresuid/setresuid04.c 
> b/testcases/kernel/syscalls/setresuid/setresuid04.c
> index 140d5f3..49b2616 100644
> --- a/testcases/kernel/syscalls/setresuid/setresuid04.c
> +++ b/testcases/kernel/syscalls/setresuid/setresuid04.c
> @@ -53,6 +53,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include <pwd.h>
> +#include "compat_16.h"
>
>   char *TCID = "setresuid04";
>   int TST_TOTAL = 1;
> @@ -111,8 +112,8 @@ void do_master_child(void)
>               /* Reset tst_count in case we are looping */
>               tst_count = 0;
>
> -             if (setresuid(0, ltpuser->pw_uid, 0) == -1) {
> -                     perror("setfsuid failed");
> +             if (SETRESUID(cleanup, 0, ltpuser->pw_uid, 0) == -1) {
> +                     perror("setresuid failed");
>                       exit(1);
>               }
>
> @@ -176,8 +177,8 @@ void do_master_child(void)
>                *         the file with RDWR permissions.
>                */
>               tst_count++;
> -             if (setresuid(0, 0, 0) == -1) {
> -                     perror("setfsuid failed");
> +             if (SETRESUID(cleanup, 0, 0, 0) == -1) {
> +                     perror("setresuid failed");
>                       exit(1);
>               }
>
> @@ -203,6 +204,8 @@ void setup(void)
>
>       ltpuser = getpwnam(nobody_uid);
>
> +     UID16_CHECK(ltpuser->pw_uid, "setresuid", cleanup)
> +
>       tst_tmpdir();
>
>       sprintf(testfile, "setresuid04file%d.tst", getpid());
> diff --git a/testcases/kernel/syscalls/setresuid/setresuid05.c 
> b/testcases/kernel/syscalls/setresuid/setresuid05.c
> index 8880aeb..81175eb 100644
> --- a/testcases/kernel/syscalls/setresuid/setresuid05.c
> +++ b/testcases/kernel/syscalls/setresuid/setresuid05.c
> @@ -30,6 +30,7 @@
>   #include "test.h"
>   #include "usctest.h"
>   #include "safe_macros.h"
> +#include "compat_16.h"
>
>   char *TCID = "setresuid05";
>   int TST_TOTAL = 1;
> @@ -70,13 +71,15 @@ static void setup(void)
>       tst_tmpdir();
>
>       ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
> +
> +     UID16_CHECK(ltpuser->pw_uid, "setresuid", cleanup)
>   }
>
>   static void setresuid_verify(void)
>   {
>       struct stat buf;
>
> -     TEST(setresuid(-1, ltpuser->pw_uid, -1));
> +     TEST(SETRESUID(cleanup, -1, ltpuser->pw_uid, -1));
>
>       if (TEST_RETURN != 0) {
>               tst_resm(TFAIL | TTERRNO, "setresuid failed unexpectedly");
> diff --git a/testcases/kernel/syscalls/utils/compat_16.h 
> b/testcases/kernel/syscalls/utils/compat_16.h
> index 40bef59..b6a702d 100644
> --- a/testcases/kernel/syscalls/utils/compat_16.h
> +++ b/testcases/kernel/syscalls/utils/compat_16.h
> @@ -127,8 +127,28 @@ int SETREGID(void (cleanup)(void), GID_T rgid, GID_T 
> egid)
>       LTP_CREATE_SYSCALL(setregid, cleanup, rgid, egid);
>   }
>
> +int SETRESUID(void (cleanup)(void), UID_T ruid, UID_T euid, UID_T suid)
> +{
> +     LTP_CREATE_SYSCALL(setresuid, cleanup, ruid, euid, suid);
> +}
> +
> +int SETRESGID(void (cleanup)(void), GID_T rgid, GID_T egid, GID_T sgid)
> +{
> +     LTP_CREATE_SYSCALL(setresgid, cleanup, rgid, egid, sgid);
> +}
> +
> +int FCHOWN(void (cleanup)(void), unsigned int fd, UID_T owner, GID_T group)
> +{
> +     LTP_CREATE_SYSCALL(fchown, cleanup, fd, owner, group);
> +}
> +
>   int LCHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
>   {
>       LTP_CREATE_SYSCALL(lchown, cleanup, path, owner, group);
>   }
> +
> +int CHOWN(void (cleanup)(void), const char *path, UID_T owner, GID_T group)
> +{
> +     LTP_CREATE_SYSCALL(chown, cleanup, path, owner, group);
> +}
>   #endif /* __LTP_COMPAT_16_H__ */
>

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to