You are not logged in.

#1 2011-06-03 00:05:50

sweetthdevil
Member
Registered: 2009-10-20
Posts: 417

removing certain power?

Hi all,

I would like to remove the power to a certain user to either logout, reboot, or shut-down - basically I must have the operating system running between a given time.

So ideally I would have a script running at log on for that given user to disable those function until a certain time.

for a bit of background info I am using my pc with my web cam as a security recording device over night - and one of my house mate is using it while I am away at work - which I do not mind.


I am not sure how to approach the issue given the fact I want it completely invisible for the user - so I.E. no sudo password to type

Looking forward for your assistance,

Offline

#2 2011-06-03 00:32:01

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: removing certain power?

create a copy of /etc/sudoers and disallow your housemate's user from issuing whatever commands you don't want him to issue (reboot, halt, init etc). Keep his user in the 'real' /etc/sudoers. THEN create a small script that swaps the two versions - then run that script via cron whenever you need to change permissions out.


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#3 2011-06-03 00:42:08

sweetthdevil
Member
Registered: 2009-10-20
Posts: 417

Re: removing certain power?

Many thanks for your reply,

two questions:

- In order to create a script swapping those two sudoers file, surely the root password input or the sudo password is needed?
- in the sudoers file I only have those line to change, so how can I modify it to remove such power? (see below for the lines)

root ALL=(ALL) ALL

%sudo    ALL=(ALL) ALL

Or the alrternative, could be to ask for a password between those time to all user,

Looking forward for your reply,

Last edited by sweetthdevil (2011-06-03 00:46:14)

Offline

#4 2011-06-03 09:21:06

sweetthdevil
Member
Registered: 2009-10-20
Posts: 417

Re: removing certain power?

Alternatively,

I was looking into gnome-shell extension (I just added an extension to show the power menu - for my user) So can we modify that extension to then display those menu or not depending on real time? I.E. display menu between 8am and 7pm then the rest do not display?



source: http://blog.fpmurphy.com/2011/05/more-g … ation.html

const St = imports.gi.St;
const Main = imports.ui.main;
const PopupMenu = imports.ui.popupMenu;
const Shell = imports.gi.Shell;
const Lang = imports.lang;
const Gettext = imports.gettext.domain('gnome-shell');
const _ = Gettext.gettext;

function updateSuspend(object, pspec, item) {
    item.actor.visible = object.get_can_suspend();
}

function updateHibernate(object, pspec, item) {
    item.actor.visible = object.get_can_hibernate();
}

function onSuspendActivate(item) {
    Main.overview.hide();

    this._screenSaverProxy.LockRemote(Lang.bind(this, function() {
        this._upClient.suspend_sync(null);
    }));
}

function onHibernateActivate(item) {
    Main.overview.hide();

    this._screenSaverProxy.LockRemote(Lang.bind(this, function() {
        this._upClient.hibernate_sync(null);
    }));
}

function changeUserMenu()
{
    let children = this.menu._getMenuItems();
    for (let i = 0; i < children.length; i++) {
         let item = children[i];
         if (item.label) {
              let _label = item.label.get_text();
              // global.log("menu label: " + _label);
              if (_label == _("Suspend"))
                   item.destroy();
         }
    }

    let item = new PopupMenu.PopupMenuItem(_("Suspend"));
    item.connect('activate', Lang.bind(this, onSuspendActivate));
    this._upClient.connect('notify::can-suspend', Lang.bind(this, updateSuspend, item));
    updateSuspend(this._upClient, null, item);
    this.menu.addMenuItem(item);

    item = new PopupMenu.PopupMenuItem(_("Hibernate"));
    item.connect('activate', Lang.bind(this, onHibernateActivate));
    this._upClient.connect('notify::can-hibernate', Lang.bind(this, updateHibernate, item));
    updateHibernate(this._upClient, null, item);
    this.menu.addMenuItem(item);

    item = new PopupMenu.PopupMenuItem(_("Power Off..."));
    item.connect('activate', Lang.bind(this, function() {
        this._session.ShutdownRemote();
    }));
    this.menu.addMenuItem(item);

}

function main(metadata) {

    // Post 3.0  let statusMenu = Main.panel._userMenu;
    let statusMenu = Main.panel._statusmenu;
    changeUserMenu.call(statusMenu);

}

Offline

#5 2011-06-03 16:49:28

sweetthdevil
Member
Registered: 2009-10-20
Posts: 417

Re: removing certain power?

FYI I had a reply from the mailing list of Gnome, the following command will disable those commands

gsettings set org.gnome.desktop.lockdown disable-log-out true

Offline

Board footer

Powered by FluxBB