You are not logged in.

#1 2010-01-28 21:10:41

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

[SOLVED]Is it possible to shutdown as user without sudo?

Hi, I'm installing Arch and openbox on my fathers laptop. I want to make a menu entry that shuts down the computer, without requiring password, but when launching shutdown as a normal user i get

$ shutdown
shutdown: you must be root to do that

I don't want to install sudo and give him sudo privilegies, so I cannot use sudo and sudo=nopasswd for him.
It didn't help to chmod +x either, as it seems like it is something in the /sbin/shutdown program that hates everybody but root.

Last edited by hatten (2010-02-07 11:06:17)

Offline

#2 2010-01-28 21:18:37

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: [SOLVED]Is it possible to shutdown as user without sudo?

Have you checked aur? there seems to be some packages that do what you want to do. Search for: shutdown

Offline

#3 2010-01-28 21:21:21

NeoXP
Member
From: MS Matrix
Registered: 2009-01-09
Posts: 206
Website

Re: [SOLVED]Is it possible to shutdown as user without sudo?

hatten wrote:

Hi, I'm installing Arch and openbox on my fathers laptop. I want to make a menu entry that shuts down the computer, without requiring password, but when launching shutdown as a normal user i get

$ shutdown
shutdown: you must be root to do that

I don't want to install sudo and give him sudo privilegies, so I cannot use sudo and sudo=nopasswd for him.
It didn't help to chmod +x either, as it seems like it is something in the /sbin/shutdown program that hates everybody but root.

I made a couple of entries in my .bashrc

alias halt='sudo halt'
alias reboot='sudo reboot'
alias hibernate='sudo pm-hibernate'
alias suspend='sudo pm-suspend'

Offcourse you have to edit your sudoers file to execute the commands without entering a password.


Arch x86_64 on HP 6820s and on HP nx9420. Registered Linux User 350155, since 24-03-2004
"Everyone said that it could not be done, until someone came along who didn't know that."

Offline

#4 2010-01-28 21:40:59

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED]Is it possible to shutdown as user without sudo?

hatten wrote:

I don't want to install sudo and give him sudo privilegies

Installing sudo does not give anyone sudo privileges - configuring it does. Set it up to give him access to 'sudo shutdown' only.

Offline

#5 2010-01-28 21:50:40

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: [SOLVED]Is it possible to shutdown as user without sudo?

tomk wrote:
hatten wrote:

I don't want to install sudo and give him sudo privilegies

Installing sudo does not give anyone sudo privileges - configuring it does. Set it up to give him access to 'sudo shutdown' only.

ah well, it's still another package on the system. I'll check AUR too and see if I find something nice and simple.

Offline

#6 2010-01-28 22:22:58

jean-paul
Member
From: Germany
Registered: 2007-03-26
Posts: 61

Re: [SOLVED]Is it possible to shutdown as user without sudo?

If you have installed dbus, try this

Entry = "reboot ..." { Actions = "Exec dbus-send --system --print-reply --dest='org.freedesktop.Hal' /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Reboot" &}

Entry = "shutdown" { Actions = "Exec dbus-send --system --print-reply --dest='org.freedesktop.Hal' /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown" &}

I use this in pekwm and I'm able to reboot / shutdown as USER with any password or sudo.

Jean-Paul

Last edited by jean-paul (2010-01-28 22:23:40)


I'm root. if you see me smile, you'd better have a backup!! smile

Offline

#7 2010-01-28 23:37:03

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: [SOLVED]Is it possible to shutdown as user without sudo?

hal is being deprecated, so the correct way to shutdown with dbus is using consolekit. However I suspect hatten won't have it installed if he is that reluctant to install even sudo...


"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page

Offline

#8 2010-01-29 14:39:08

lymphatik
Member
From: Somewhere else
Registered: 2009-03-07
Posts: 119

Re: [SOLVED]Is it possible to shutdown as user without sudo?

I think you just need to add yourself to the power group. Have a look at the wiki. And if still doesn't work add ck-launch-session in your xinit.

http://wiki.archlinux.org/index.php/LXD … _from_LXDE
http://wiki.archlinux.org/index.php/GNO … GNOME_menu

Last edited by lymphatik (2010-01-29 14:40:58)

Offline

#9 2010-01-29 15:51:32

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: [SOLVED]Is it possible to shutdown as user without sudo?

lymphatik wrote:

I think you just need to add yourself to the power group. Have a look at the wiki. And if still doesn't work add ck-launch-session in your xinit.

http://wiki.archlinux.org/index.php/LXD … _from_LXDE
http://wiki.archlinux.org/index.php/GNO … GNOME_menu

I'll try the first option, if that doesn't work I'll go with sudo


@PirateJonno; I have dbus installed, but it's always more interesting to try and solve things without installing additional packages, no matter how small they are. =p

Offline

#10 2010-01-29 15:54:17

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 801

Re: [SOLVED]Is it possible to shutdown as user without sudo?

Pressing the power button for a few seconds usually works for "users"

Offline

#11 2010-01-29 20:51:18

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: [SOLVED]Is it possible to shutdown as user without sudo?

vacant wrote:

Pressing the power button for a few seconds usually works for "users"

lmao, not with a computer I'm fixing!

Offline

#12 2010-01-29 21:10:00

brebs
Member
Registered: 2007-04-03
Posts: 3,456

Re: [SOLVED]Is it possible to shutdown as user without sudo?

See thread.

It's a mess. Raving lunatics are the only people who write this crap for free, because the competent devs get paid good money for writing for Windows roll

Offline

#13 2010-01-29 21:29:49

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819

Re: [SOLVED]Is it possible to shutdown as user without sudo?

vacant wrote:

Pressing the power button for a few seconds usually works for "users"

Well if that's how you 'shut down' your computer I think we'll see a lot of topics from your side in the future.

You don't push the power button for a few seconds unless you do a hard shutdown. You can set up an ACPI action - either through your DE's backend or through ACPI directly - to shut down cleanly, but that only involves pushing that button once, and certainly not more than a second. You push, you release. You do not hold.

I repeat: You do not hold.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#14 2010-01-29 21:58:01

some-guy94
Member
Registered: 2009-08-15
Posts: 360

Re: [SOLVED]Is it possible to shutdown as user without sudo?

Offline

#15 2010-02-04 04:29:13

broch
Banned
From: L.A. California
Registered: 2006-11-13
Posts: 975

Re: [SOLVED]Is it possible to shutdown as user without sudo?

devicekit? hal?

what about simple ACL?
1) create group e.g. shutdown
2) give it rights you want
3) assign group shutdown to /sbin/halt
4) configure access
5) run:
halt -p
to poweroff machine

this is simple old way that works without weird scripts invoking hal or whateverkit.
no need for sudo either if you don't want to install it

hope this will help

Last edited by broch (2010-02-04 04:29:39)

Offline

#16 2010-02-04 05:52:40

falbani
Member
From: Buenos Aires - Argentina
Registered: 2010-02-02
Posts: 16

Re: [SOLVED]Is it possible to shutdown as user without sudo?

broch wrote:

what about simple ACL?
1) create group e.g. shutdown
2) give it rights you want
3) assign group shutdown to /sbin/halt
4) configure access
5) run:
halt -p
to poweroff machine

this is simple old way that works without weird scripts invoking hal or whateverkit.
no need for sudo either if you don't want to install it

Did not work for me. I followed your steps but with the "power" group.

> ls /sbin/halt 
-rwxr-xr-x 1 root power 9,9K abr 30  2009 /sbin/halt
> reboot
reboot: must be superuser.

Offline

#17 2010-02-04 06:40:43

broch
Banned
From: L.A. California
Registered: 2006-11-13
Posts: 975

Re: [SOLVED]Is it possible to shutdown as user without sudo?

run:
chmod u+s /sbin/shutdown
to get
ls -l /sbin/halt
-rwsr-x--- 1 root shutdown 9.9K Apr 30  2009 /sbin/halt

shutdown group (you) must run program with root privileges, then it will work

hope this will help

Offline

#18 2010-02-04 06:58:59

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: [SOLVED]Is it possible to shutdown as user without sudo?

man sudoers

Offline

#19 2010-02-04 13:16:58

broch
Banned
From: L.A. California
Registered: 2006-11-13
Posts: 975

Re: [SOLVED]Is it possible to shutdown as user without sudo?

tomd123 wrote:

man sudoers

...
ant the title says:

Is it possible to shutdown as user without sudo?

Offline

#20 2010-02-04 15:00:34

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: [SOLVED]Is it possible to shutdown as user without sudo?

I went with the simple sudo chmod +s, it's a single user system that's regularly updated so I'm not especially afraid of unwanted shutdowns.
But thanks for all suggestions, I'll maybe need them some day!

Offline

#21 2010-02-07 02:39:35

falbani
Member
From: Buenos Aires - Argentina
Registered: 2010-02-02
Posts: 16

Re: [SOLVED]Is it possible to shutdown as user without sudo?

broch wrote:

run:
chmod u+s /sbin/shutdown
to get
ls -l /sbin/halt
-rwsr-x--- 1 root shutdown 9.9K Apr 30  2009 /sbin/halt

shutdown group (you) must run program with root privileges, then it will work

hope this will help

I'm surely doing something obvious wrong.

with root:

> ls /sbin/shutdown
-rwsr-s--- 1 root power 18K abr 30 2009 /sbin/shutdown

with my user:

> reboot
reboot: must be superuser.

(my user belongs to "power")

Offline

#22 2010-02-07 03:22:12

broch
Banned
From: L.A. California
Registered: 2006-11-13
Posts: 975

Re: [SOLVED]Is it possible to shutdown as user without sudo?

mm..
you have not set executable permission so user will not be able to execute command:
mine:
ls -l /sbin/halt
-rwsr-x--- 1 root shutdown 9.9K Apr 30  2009 /sbin/halt
yours:
ls /sbin/shutdown
-rwsr-s--- 1 root power 18K abr 30 2009 /sbin/shutdown

anyway, I suggest to modify ACL for /sbin/halt
it is useful

other that this, I am not sure what to suggest.
Once you set ownership correctly reboot and poweroff works: from terminal window, from console. Does not matter user can shutdown machine without providing root password or using sudo.

You can also try hatten's suggestion (#20)

I am sorry that this is not working for you but I don't know how else

Offline

#23 2010-02-07 04:29:30

falbani
Member
From: Buenos Aires - Argentina
Registered: 2010-02-02
Posts: 16

Re: [SOLVED]Is it possible to shutdown as user without sudo?

Many thanks; it worked.

hatten: consider editing the title of the first post for adding [SOLVED] at the beginning.

Offline

#24 2010-02-07 11:06:30

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: [SOLVED]Is it possible to shutdown as user without sudo?

falbani wrote:

Many thanks; it worked.

hatten: consider editing the title of the first post for adding [SOLVED] at the beginning.

ah sorry, done.

Offline

Board footer

Powered by FluxBB