All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] provide real error message when trying to run xm as non root
@ 2005-07-26 14:41 Sean Dague
  2005-07-26 14:52 ` Andrew Thompson
  0 siblings, 1 reply; 4+ messages in thread
From: Sean Dague @ 2005-07-26 14:41 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1545 bytes --]

This patch prevents you from getting a screen full of stack trace when
trying to run commands like xm list as a normal user, and instead provides a
helpful error message.


Signed-off-by: Sean Dague <sean@dague.net>

Diffstat output:
 main.py |    7 +++++++
 1 files changed, 7 insertions(+)

diff -r 48aed1403fe3 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py	Fri Jul 22 16:44:33 2005
+++ b/tools/python/xen/xm/main.py	Tue Jul 26 10:31:24 2005
@@ -11,6 +11,13 @@
 
 from xen.xend import PrettyPrint
 from xen.xend import sxp
+# this is a nasty place to stick this in, but required because
+# log file access is set up via a 5 deep import chain.  This
+# ensures the user sees a useful message instead of a stack trace
+if os.getuid() != 0:
+    print "xm requires root access to execute, please try again as root"
+    sys.exit(1)
+
 from xen.xend.XendClient import XendError, server
 from xen.xend.XendClient import main as xend_client_main
 from xen.xm import create, destroy, migrate, shutdown, sysrq


	-Sean

-- 
__________________________________________________________________

Sean Dague                                       Mid-Hudson Valley
sean at dague dot net                            Linux Users Group
http://dague.net                                 http://mhvlug.org

There is no silver bullet.  Plus, werewolves make better neighbors
than zombies, and they tend to keep the vampire population down.
__________________________________________________________________

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] provide real error message when trying to run xm as non root
  2005-07-26 14:41 [PATCH] provide real error message when trying to run xm as non root Sean Dague
@ 2005-07-26 14:52 ` Andrew Thompson
  2005-07-26 15:09   ` Sean Dague
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Thompson @ 2005-07-26 14:52 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]

Sean Dague wrote:
> This patch prevents you from getting a screen full of stack trace when
> trying to run commands like xm list as a normal user, and instead provides a
> helpful error message.

+1, Admirable. (non-binding/non-voter/non-commiter)

> Signed-off-by: Sean Dague <sean@dague.net>
> 
> Diffstat output:
>  main.py |    7 +++++++
>  1 files changed, 7 insertions(+)
> 
> diff -r 48aed1403fe3 tools/python/xen/xm/main.py
> --- a/tools/python/xen/xm/main.py	Fri Jul 22 16:44:33 2005
> +++ b/tools/python/xen/xm/main.py	Tue Jul 26 10:31:24 2005
> @@ -11,6 +11,13 @@
>  
>  from xen.xend import PrettyPrint
>  from xen.xend import sxp
> +# this is a nasty place to stick this in, but required because
> +# log file access is set up via a 5 deep import chain.  This
> +# ensures the user sees a useful message instead of a stack trace
> +if os.getuid() != 0:
> +    print "xm requires root access to execute, please try again as root"
> +    sys.exit(1)
> +
>  from xen.xend.XendClient import XendError, server
>  from xen.xend.XendClient import main as xend_client_main
>  from xen.xm import create, destroy, migrate, shutdown, sysrq

Please allow me to show my possible ignorance...

Is there no better way to test for elevated privileges?
Would it be unreasonable to think xm maintenance tasks could be handed 
off to members of a non-root group?

-- 
Andrew Thompson
http://aktzero.com/

[-- Attachment #2: andrewkt.vcf --]
[-- Type: text/x-vcard, Size: 153 bytes --]

begin:vcard
fn:Andrew Thompson
n:Thompson;Andrew
email;internet:andrewkt@aktzero.com
x-mozilla-html:FALSE
url:http://aktzero.com/
version:2.1
end:vcard


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] provide real error message when trying to run xm as non root
  2005-07-26 14:52 ` Andrew Thompson
@ 2005-07-26 15:09   ` Sean Dague
  2005-07-26 15:35     ` aq
  0 siblings, 1 reply; 4+ messages in thread
From: Sean Dague @ 2005-07-26 15:09 UTC (permalink / raw)
  To: Andrew Thompson; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 2723 bytes --]

On Tue, Jul 26, 2005 at 10:52:35AM -0400, Andrew Thompson wrote:
> Sean Dague wrote:
> >This patch prevents you from getting a screen full of stack trace when
> >trying to run commands like xm list as a normal user, and instead provides 
> >a
> >helpful error message.
> 
> +1, Admirable. (non-binding/non-voter/non-commiter)
> 
> >Signed-off-by: Sean Dague <sean@dague.net>
> >
> >Diffstat output:
> > main.py |    7 +++++++
> > 1 files changed, 7 insertions(+)
> >
> >diff -r 48aed1403fe3 tools/python/xen/xm/main.py
> >--- a/tools/python/xen/xm/main.py	Fri Jul 22 16:44:33 2005
> >+++ b/tools/python/xen/xm/main.py	Tue Jul 26 10:31:24 2005
> >@@ -11,6 +11,13 @@
> > 
> > from xen.xend import PrettyPrint
> > from xen.xend import sxp
> >+# this is a nasty place to stick this in, but required because
> >+# log file access is set up via a 5 deep import chain.  This
> >+# ensures the user sees a useful message instead of a stack trace
> >+if os.getuid() != 0:
> >+    print "xm requires root access to execute, please try again as root"
> >+    sys.exit(1)
> >+
> > from xen.xend.XendClient import XendError, server
> > from xen.xend.XendClient import main as xend_client_main
> > from xen.xm import create, destroy, migrate, shutdown, sysrq
> 
> Please allow me to show my possible ignorance...
> 
> Is there no better way to test for elevated privileges?
> Would it be unreasonable to think xm maintenance tasks could be handed 
> off to members of a non-root group?

Unfortunately the root problem comes from the fact that xm writes to the
xend log file directly, and in unprivileged state, throws an exception
because it doesn't have write access to that file.  The 2nd part of this
problem is that this exception is buried down a whole series of 5 level
magical import object creation paths, and hence is very hard to reasonably
get to from the xm main().

I'm sure you *could* reorder xm code to make this a strict perms check, but
the level of spagetti sorting to get there may not really be worth it.  I
also think you'd have to remove the direct logging from xm to be able to do
priv seperate between xm and xend, and that is really strewn throughout all
the code.

	-Sean

-- 
__________________________________________________________________

Sean Dague                                       Mid-Hudson Valley
sean at dague dot net                            Linux Users Group
http://dague.net                                 http://mhvlug.org

There is no silver bullet.  Plus, werewolves make better neighbors
than zombies, and they tend to keep the vampire population down.
__________________________________________________________________

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] provide real error message when trying to run xm as non root
  2005-07-26 15:09   ` Sean Dague
@ 2005-07-26 15:35     ` aq
  0 siblings, 0 replies; 4+ messages in thread
From: aq @ 2005-07-26 15:35 UTC (permalink / raw)
  To: Andrew Thompson, xen-devel

On 7/27/05, Sean Dague <sean@dague.net> wrote:
> On Tue, Jul 26, 2005 at 10:52:35AM -0400, Andrew Thompson wrote:
> > Sean Dague wrote:
> > >This patch prevents you from getting a screen full of stack trace when
> > >trying to run commands like xm list as a normal user, and instead provides
> > >a
> > >helpful error message.
> >
> > +1, Admirable. (non-binding/non-voter/non-commiter)
> >
> > >Signed-off-by: Sean Dague <sean@dague.net>
> > >
> > >Diffstat output:
> > > main.py |    7 +++++++
> > > 1 files changed, 7 insertions(+)
> > >
> > >diff -r 48aed1403fe3 tools/python/xen/xm/main.py
> > >--- a/tools/python/xen/xm/main.py    Fri Jul 22 16:44:33 2005
> > >+++ b/tools/python/xen/xm/main.py    Tue Jul 26 10:31:24 2005
> > >@@ -11,6 +11,13 @@
> > >
> > > from xen.xend import PrettyPrint
> > > from xen.xend import sxp
> > >+# this is a nasty place to stick this in, but required because
> > >+# log file access is set up via a 5 deep import chain.  This
> > >+# ensures the user sees a useful message instead of a stack trace
> > >+if os.getuid() != 0:
> > >+    print "xm requires root access to execute, please try again as root"
> > >+    sys.exit(1)
> > >+
> > > from xen.xend.XendClient import XendError, server
> > > from xen.xend.XendClient import main as xend_client_main
> > > from xen.xm import create, destroy, migrate, shutdown, sysrq
> >
> > Please allow me to show my possible ignorance...
> >
> > Is there no better way to test for elevated privileges?
> > Would it be unreasonable to think xm maintenance tasks could be handed
> > off to members of a non-root group?
> 
> Unfortunately the root problem comes from the fact that xm writes to the
> xend log file directly, and in unprivileged state, throws an exception
> because it doesn't have write access to that file.  The 2nd part of this
> problem is that this exception is buried down a whole series of 5 level
> magical import object creation paths, and hence is very hard to reasonably
> get to from the xm main().
> 

yes, most of the problem comes from the fact that most call to
XendRoot.py is to get xend configuations (in xend-config.sxp), but too
bad XendRoot has another function: to open a log file, wich is the job
of root.

actually i had a patch to split XendRoot.py (to make a new
XendConfig.py) and convert most call to XendRoot to XendConfig, but
never have a chance to submit it. probably i will give another attempt
this weekend.


regards,
aq

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-26 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-26 14:41 [PATCH] provide real error message when trying to run xm as non root Sean Dague
2005-07-26 14:52 ` Andrew Thompson
2005-07-26 15:09   ` Sean Dague
2005-07-26 15:35     ` aq

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.