This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] fileio.exp FAILs if run as root


On Sat, 2007-12-08 at 20:13 +0100, Jan Kratochvil wrote:
> On Sat, 08 Dec 2007 19:58:05 +0100, Mark Kettenis wrote:
> > > Date: Sat, 8 Dec 2007 19:14:22 +0100
> > > From: Jan Kratochvil <jan.kratochvil@redhat.com>
> > > 
> > > Hi,
> > > 
> > > if you run gdb.base/fileio.exp as UID 0 it will print:
> > > 	FAIL: gdb.base/fileio.exp: Open for write but no write permission returns EACCES
> > > 	FAIL: gdb.base/fileio.exp: Unlinking a file in a directory w/o write access returns EACCES
> > 
> > People running the testsuite as root deserve what they get.  I don't
> > think we should complicate our code to make that possible, especially
> > if it involves calling setuid() which is notoriously unportable.
> 
> OK, this is the other possibility I was considering.

Clever -- but should it be a warning instead of a terminate?

Somebody might have a legitimate reason to run as root, 
even if we can't think of it right now.


> plain text document attachment (gdb-run-root.patch)
> 2007-12-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* lib/gdb.exp: Refuse to run as root.
> 
> --- ./gdb/testsuite/lib/gdb.exp	30 Oct 2007 19:23:18 -0000	1.92
> +++ ./gdb/testsuite/lib/gdb.exp	8 Dec 2007 19:12:00 -0000
> @@ -26,6 +26,14 @@ if {$tool == ""} {
>      exit 2
>  }
>  
> +set uidfile [open "|id -u" r];
> +gets $uidfile uid
> +catch {close $uidfile}
> +if {$uid == 0} {
> +    send_error "Root privileges give false results, run as a regular user!\n"
> +    exit 2
> +}
> +
>  load_lib libgloss.exp
>  
>  global GDB


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]