summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2011-08-26 07:54:30 -0700
committerAaron Plattner <aplattner@nvidia.com>2011-08-28 19:35:12 -0700
commit2f7f7db37fee4098e8bb98af1f4973a83de9ceae (patch)
treedadd3454af564eb40ea9619e856791e9bc8e38fe
parentbd60c0f398d3c2c04f4bea5f62b3593fb0ccc920 (diff)
xts5: XWriteBitmapFile-3: Report UNTESTED instead of FAIL when run as root
This test creates a directory, makes it non-writable, then calls XWriteBitmapFile to attempt to write to it, expecting it to fail with BitmapOpenFailed. This works fine when run as a normal user, but when run as root, writing the file succeeds anyway. Check the euid and bail out with UNTESTED if it's root. Reported-by: Abhinav Shukla <abhinavs@nvidia.com> Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--xts5/Xlib17/XWriteBitmapFile.m7
1 files changed, 7 insertions, 0 deletions
diff --git a/xts5/Xlib17/XWriteBitmapFile.m b/xts5/Xlib17/XWriteBitmapFile.m
index 63cbf766..f784fea9 100644
--- a/xts5/Xlib17/XWriteBitmapFile.m
+++ b/xts5/Xlib17/XWriteBitmapFile.m
@@ -313,6 +313,13 @@ Verify that a BitmapOpenFailed error occurred.
>>CODE
int ret;
+/* Writing won't fail even if the permissions say it should if we're root. */
+ if(geteuid() == 0) {
+ report("File permissions cannot be tested as root.");
+ UNTESTED;
+ return;
+ }
+
/* Create a suitable bitmap. */
/* Create an unwritable directory. */
if(mkdir(XWBF_DIR, XWBF_MODE)) {