* [LTP] [PATCH] setresuid/setresuid04.c: Add new test
@ 2014-05-15 6:47 Zeng Linggang
2014-05-15 14:11 ` chrubis
0 siblings, 1 reply; 2+ messages in thread
From: Zeng Linggang @ 2014-05-15 6:47 UTC (permalink / raw)
To: ltp-list
1. Set new euid.
2. Create a new file.
3. Verify the file's st_uid is equal to the new euid.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
runtest/ltplite | 1 +
runtest/stress.part3 | 1 +
runtest/syscalls | 2 +
testcases/kernel/syscalls/.gitignore | 2 +
testcases/kernel/syscalls/setresuid/setresuid05.c | 107 ++++++++++++++++++++++
5 files changed, 113 insertions(+)
create mode 100644 testcases/kernel/syscalls/setresuid/setresuid05.c
diff --git a/runtest/ltplite b/runtest/ltplite
index f09c386..4b22444 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -774,6 +774,7 @@ setresuid01 setresuid01
setresuid02 setresuid02
setresuid03 setresuid03
setresuid04 setresuid04
+setresuid05 setresuid05
setreuid01 setreuid01
setreuid02 setreuid02
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 4fe4626..38aaa1d 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -678,6 +678,7 @@ setresuid01 setresuid01
setresuid02 setresuid02
setresuid03 setresuid03
setresuid04 setresuid04
+setresuid05 setresuid05
setreuid01 setreuid01
setreuid02 setreuid02
diff --git a/runtest/syscalls b/runtest/syscalls
index 7a067cd..c294032 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1036,6 +1036,8 @@ setresuid03 setresuid03
setresuid03_16 setresuid03_16
setresuid04 setresuid04
setresuid04_16 setresuid04_16
+setresuid05 setresuid05
+setresuid05_16 setresuid05_16
setreuid01 setreuid01
setreuid01_16 setreuid01_16
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 0a16f74..31d5c1f 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -827,6 +827,8 @@
/setresuid/setresuid03_16
/setresuid/setresuid04
/setresuid/setresuid04_16
+/setresuid/setresuid05
+/setresuid/setresuid05_16
/setreuid/setreuid01
/setreuid/setreuid01_16
/setreuid/setreuid02
diff --git a/testcases/kernel/syscalls/setresuid/setresuid05.c b/testcases/kernel/syscalls/setresuid/setresuid05.c
new file mode 100644
index 0000000..c3c2da4
--- /dev/null
+++ b/testcases/kernel/syscalls/setresuid/setresuid05.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+/*
+ * Test Description:
+ * Verify that,
+ * File system UID is always set to the same value as the (possibly new)
+ * effective UID.
+ */
+
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/stat.h>
+#include "test.h"
+#include "usctest.h"
+#include "safe_macros.h"
+
+char *TCID = "setresuid05";
+int TST_TOTAL = 1;
+static struct passwd *ltpuser;
+static void setup(void);
+static void setresuid_verify(void);
+static void cleanup(void);
+
+int main(int argc, char **argv)
+{
+ int i, lc;
+ char *msg;
+
+ msg = parse_opts(argc, argv, NULL, NULL);
+ if (msg != NULL)
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+ setup();
+
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ tst_count = 0;
+ for (i = 0; i < TST_TOTAL; i++)
+ setresuid_verify();
+ }
+
+ cleanup();
+ tst_exit();
+}
+
+static void setup(void)
+{
+ tst_require_root(NULL);
+
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ TEST_PAUSE;
+
+ tst_tmpdir();
+
+ ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+}
+
+static void setresuid_verify(void)
+{
+ struct stat buf;
+
+ TEST(setresuid(-1, ltpuser->pw_uid, -1));
+
+ if (TEST_RETURN != 0) {
+ tst_resm(TFAIL | TTERRNO, "setresuid failed unexpectedly");
+ return;
+ }
+
+ SAFE_TOUCH(cleanup, "test_file", 0644, NULL);
+
+ SAFE_STAT(cleanup, "test_file", &buf);
+
+ if (ltpuser->pw_uid == buf.st_uid) {
+ tst_resm(TPASS, "setresuid succeeded as expected");
+ } else {
+ tst_resm(TFAIL,
+ "setresuid failed unexpectedly; euid(%d) - st_uid(%d)",
+ ltpuser->pw_uid, buf.st_uid);
+ }
+}
+
+static void cleanup(void)
+{
+ if (seteuid(0) < 0)
+ tst_resm(TWARN | TERRNO, "seteuid failed");
+
+ TEST_CLEANUP;
+
+ tst_rmdir();
+}
--
1.8.4.2
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] setresuid/setresuid04.c: Add new test
2014-05-15 6:47 [LTP] [PATCH] setresuid/setresuid04.c: Add new test Zeng Linggang
@ 2014-05-15 14:11 ` chrubis
0 siblings, 0 replies; 2+ messages in thread
From: chrubis @ 2014-05-15 14:11 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-15 14:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 6:47 [LTP] [PATCH] setresuid/setresuid04.c: Add new test Zeng Linggang
2014-05-15 14:11 ` chrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox