[PATCH xts] xts5: XWriteBitmapFile-3: Report UNTESTED instead of FAIL when run as root

Peter Hutterer peter.hutterer at who-t.net
Sun Aug 28 18:48:47 PDT 2011


On Fri, Aug 26, 2011 at 08:04:50AM -0700, Aaron Plattner wrote:
> 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 at nvidia.com>
> Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
> ---
>  xts5/Xlib17/XWriteBitmapFile.m |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/xts5/Xlib17/XWriteBitmapFile.m b/xts5/Xlib17/XWriteBitmapFile.m
> index 63cbf76..f784fea 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)) {
> -- 
> 1.7.4.1

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
  Peter


More information about the xorg-devel mailing list