LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 09-29-2020, 03:08 AM   #1
platypo
Member
 
Registered: Sep 2015
Distribution: Debian, Archlinux
Posts: 140

Rep: Reputation: Disabled
Shutdown - why does it work?


I've been having trouble with scheduled shutdown in Debian 10 and i've lost track of how it works.
As far as i understand /sbin/shutdown now points to systemctl. I can't execute ´shutdown´ even when using the su command though /sbin is set as part of roots PATH in /etc/profile
Code:
if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
Shouldn't this make it available for root at least?
However i made a script for scheduled shutdown using ´systemctl poweroff´ directly
The script does what it's intended to do without any further authentication when logged in locally. When logged in via ssh i get:
Code:
<user>@debian:~$ ./pc-shutdown.sh 0
<user>@debian:~$ Failed to set wall message, ignoring: Interactive authentication required.
Failed to power off system via logind: Interactive authentication required.
Failed to start poweroff.target: Interactive authentication required.
See system logs and 'systemctl status poweroff.target' for details.
´systemctl poweroff´ istelf works without password locally and needs two authentications when logged in via ssh, Once for a wall message then for systemctl poweroff.
I wonder why the script works without privileges when logged in locally in the first place.

Last edited by platypo; 09-29-2020 at 03:13 AM.
 
Old 09-29-2020, 04:22 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Without seeing what's inside pc-shutdown.sh, I can't say much. Obviously, systemctl wants authentication as root, i.e. the root password.

Are you sure that systemctl poweroff works without password when called from a nonprivileged user?
 
Old 09-29-2020, 04:36 AM   #3
platypo
Member
 
Registered: Sep 2015
Distribution: Debian, Archlinux
Posts: 140

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Without seeing what's inside pc-shutdown.sh, I can't say much. Obviously, systemctl wants authentication as root, i.e. the root password.

Are you sure that systemctl poweroff works without password when called from a nonprivileged user?
I just tested it again, systemctl poweroff works without sudo or any other authentication when logged into the terminal-app on tty7 as on any other tty as unprivileged user.
The script goes:
Code:
(
sleep $1
systemctl poweroff
)&
wich chmod 755

Last edited by platypo; 09-29-2020 at 04:39 AM.
 
Old 09-29-2020, 05:09 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,923

Rep: Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319Reputation: 7319
probably: https://unix.stackexchange.com/quest...-systemctl-pow
this is a policy setting
 
Old 09-29-2020, 05:20 AM   #5
platypo
Member
 
Registered: Sep 2015
Distribution: Debian, Archlinux
Posts: 140

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
That explains the unprivileged execution. But why the password-prompt when logged in remotely?

Last edited by platypo; 09-29-2020 at 05:23 AM.
 
Old 09-29-2020, 09:47 AM   #6
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Shutdown works as expected on my Debian systems, both Buster and Sid. I haven't tried systemctl poweroff.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the default powerstate (e.g. S3,S4,S5) for the command 'shutdown -hP' or 'shutdown -hH' or 'shutdown -h' badbetty Slackware 6 11-12-2017 12:18 AM
[SOLVED] shutdown works, but /lib/systemd/system/shutdown.target does not. kaz2100 Debian 3 08-06-2014 03:28 AM
User shutdown - 'cp -i -p shutdown /usr/sbin/shutdown2 - why does this not work, can? mitchellray Linux - Desktop 4 03-20-2009 09:31 PM
My Linux box does not shutdown i do when i do /sbin/shutdown -h now yawe_frek Linux - Hardware 6 09-14-2007 07:48 AM
SENDMAIL - Why does it not work when i shutdown xinetd adamrau Linux - Software 2 10-22-2001 10:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 07:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration