[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] battery-module: run an command on alarm



Am Thu, 22 Jun 2006 08:11:54 +0900
schrieb Carsten Haitzler (The Rasterman) <raster@rasterman.com>:

> On Wed, 21 Jun 2006 23:00:30 +0200 Stephan Wezel <s.wezel@arcor.de>
> babbled:
> 
> > Hi,
> > i have written a patch with which the battery-module can run an
> > command on alarm.
> > E.g when the battery drops under 10 min remaining time then you
> > can initiate the shutdown of the system.
> > 
> > the command is currently executet via the system-fn call. If it is
> > there a better methode to do it then let me know it.
> > 
> > Regards
> > 
> > Stephan Wezel
> 
> i actually didn't want to do this. running a command is powerful- but
> not very user friendly. the fact is that this feature appeared for a
> reason - to shut down, suspend or such given a condition. being able
> to shut down, suspend etc. from e directly is already a desired thing
> - but this requires punching holes into root access, and i haven't
> done that yet. but the proper solution (imho) is to do this (provide
> e calls in e itself to exit e, restart e, logout, shutdown, reboot,
> suspend, hibernate etc.) then provide a simple config dialog of "at
> X% battery do: nothing, warning dialog, shutdown, suspend, ... etc.".
> as a user should not have to know some obscure incantation to have
> something like this work. it should be a simple choice. then e will
> take care of doing that specific action. (as doing it your way a user
> needs to figure out how to give themselevs root access - sudoers, or
> whatever) and do it in a non-interactive way for these specific
> commands, then actually know these commands etc. i'd rather push that
> off int an abstracted api and a system config that defines what these
> special suid root helper commands do (the system, admin or
> distribution would define it in a system config or at compile time so
> it works with the way their system works - this is specially needed
> for suspend and hibernate at the moment as there are many different
> ways to do that currently unlike shutdown and reboot which are
> standard)
yeah you are right in this case to simplify the choice for the user.
And to gain security so that the user can only do things with
root-rights, for these he has the rights to do it.
I have done this in similar way as gkrellm it does.
I would say everyone who knows how to get root access only(e.g. via
sudo) for the needed command can use this patch :)

Now is the question how would looks like the helper to to the e.g.
shutdown, reboot, suspend, hibernate:

1. They could be standalone helper-programs which gets called from e.
2. Or they could be modules.

The module-way has the capabilities that we can define a API which
doesn't need a call of an external programm to run the helper.

A API could be look like this:

hasRights() 	// ro check if the user has the rights to do the command 
doShutdown()	// to initiate the shutdown
doReboot()	// reboot the machine
etc.

the hasRights could either have an parameter for the command to check
or we have for each command a seperate hasRights<command>-function

> 
> > -- 
> > Ein Ring, sie zu knechten, sie alle zu finden,
> > Ins Dunkel zu treiben und ewig zu binden
> > Im Lande Mordor, wo die Schatten drohn.
> 
> 


-- 
Ein Ring, sie zu knechten, sie alle zu finden,
Ins Dunkel zu treiben und ewig zu binden
Im Lande Mordor, wo die Schatten drohn.