LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-02-2023, 07:50 PM   #1
gregors
Member
 
Registered: Mar 2018
Posts: 177

Rep: Reputation: Disabled
Question Execute script after hibernation


Hi there!

I want a user script to check how long the last "hibernation phase" is gone. E.g. the question is "how long is this system awake?"
'uptime' just gives me the time since last boot - and reading the syslog requires a user to be a member of group adm (which I don't want).

TIA

Gregor
 
Old 12-03-2023, 05:29 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,158

Rep: Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377
so you can write a script that runs as a user who is member of that group and execute it with sudo.
You can configure sudo to allow to execute only this script and nothing else.
 
1 members found this post helpful.
Old 12-03-2023, 09:39 AM   #3
gregors
Member
 
Registered: Mar 2018
Posts: 177

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
so you can write a script that runs as a user who is member of that group and execute it with sudo.
You can configure sudo to allow to execute only this script and nothing else.
Thanks for that!

Since I always avoided using sudo I tried something else. SSH is installed on all of my boxes, so why not do a
Code:
ssh root@localhost 'bla'
All I had to do for making this possible was (as root):
Code:
cat /home/$USER/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
So ... I can go on avoiding sudo :-)

Gregor
 
Old 12-03-2023, 09:55 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,158

Rep: Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377
Quote:
Originally Posted by gregors View Post
Thanks for that!

Since I always avoided using sudo I tried something else. SSH is installed on all of my boxes, so why not do a
Code:
ssh root@localhost 'bla'
All I had to do for making this possible was (as root):
Code:
cat /home/$USER/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
So ... I can go on avoiding sudo :-)

Gregor
Yes, you can do that too, just it will give much more rights.
 
Old 12-03-2023, 09:59 AM   #5
gregors
Member
 
Registered: Mar 2018
Posts: 177

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
Yes, you can do that too, just it will give much more rights.
Well, yes. But for me it's just about avoiding sudo (just don't want to learn the "syntax" of sudoers), and all of this happens on a local box at home. My network is not connected to a power plant or something.

So, I don't have any security concerns. Do you?

Gregor

Last edited by gregors; 12-03-2023 at 10:01 AM.
 
Old 12-03-2023, 10:08 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,158

Rep: Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377Reputation: 7377
Quote:
Originally Posted by gregors View Post
Well, yes. But for me it's just about avoiding sudo (just don't want to learn the "syntax" of sudoers), and all of this happens on a local box at home. My network is not connected to a power plant or something.

So, I don't have any security concerns. Do you?

Gregor
That is funny. You don't want to add the user to the group, instead, you will give full access. Ok, I have no concerns.
 
Old 12-03-2023, 02:19 PM   #7
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,854

Rep: Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224Reputation: 1224
sudo is easy. From
man sudoers
Quote:
dgb boulder = (operator) /bin/ls, /bin/kill, /usr/bin/lprm
The user dgb may run /bin/ls, /bin/kill, and /usr/bin/lprm-but only as operator. E.g.,
$ sudo -u operator /bin/ls
Most easy is the ALL wildcard:
Code:
echo "ALL ALL=(ALL) cat /var/log/syslog" > /etc/sudoers.d/readsyslog
Now everybody may do a
Code:
sudo cat /var/log/syslog
And you can further restrict some of the ALLs.
 
Old 12-03-2023, 02:40 PM   #8
gregors
Member
 
Registered: Mar 2018
Posts: 177

Original Poster
Rep: Reputation: Disabled
At a second sight at the hole I'd open and given a hint (https://wiki.debian.org/SystemGroups...ssociated_user) I decided to put $USER in the adm group.

Gregor
 
  


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
Hibernation takes ~10 seconds only once after a reboot; After resume, it takes about 3-4 minutes. geni4u Linux - Laptop and Netbook 10 01-21-2018 01:07 PM
Clients do not run netlogon scripts after wake-up from hibernation DimaA Linux - Networking 0 05-15-2007 06:55 PM
fritz! isdn pcmci card not working after hibernation/standby on suse 10 gematipa SUSE / openSUSE 0 01-05-2006 07:55 AM
pcmcia issues after hibernation ghemard Mandriva 0 03-05-2005 08:48 AM
mdk10 freezes after restoring from hibernation mandrakemikael Mandriva 2 09-10-2004 03:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:34 AM.

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