The officially official Devuan Forum!

You are not logged in.

#1 2022-06-26 16:45:33

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Running a privileged command at login.

I'm using Devuan GNU/Linux 5 with runit.

I want to run a 'sudo' command at login. I guess it needs to be
started as a root command without having to provide a password.
How could i do that?

Last edited by chomwitt (2022-06-26 16:50:55)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#2 2022-06-26 17:03:50

MiyoLinux
Member
Registered: 2016-12-05
Posts: 1,323  

Re: Running a privileged command at login.

Are you familiar with cron jobs? That's one way to do it. smile


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

#3 2022-06-26 17:12:02

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Running a privileged command at login.

chomwitt wrote:

I want to run a 'sudo' command at login.

Why do you want to do that? What are you trying to achieve?

See also https://xyproblem.info/


Brianna Ghey — Rest In Power

Offline

#4 2022-06-26 17:16:01

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

MiyoLinux wrote:

Are you familiar with cron jobs? That's one way to do it. smile

I know it's purpose, not familiar but i'll manage.

I tried that so far:

$ less /etc/profile.d/enableqemunetworking.sh
#!/bin/sh
virsh net-start default   &

but didnt work..
@HeadonStick i try to enable qemu networking but the command only works with sudo.

Last edited by chomwitt (2022-06-26 17:18:00)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#5 2022-06-26 17:28:08

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Running a privileged command at login.

The command can be added to /etc/rc.local but that feels hacky af.

Have you tried

# virsh net-autostart default

^ I think that should enable it to auto start without having to run your command.

Reference: https://libvirt.org/sources/virshcmdref … start.html


Brianna Ghey — Rest In Power

Offline

#6 2022-06-26 17:47:33

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

@Head_on_a_Stick Thanks! that worked.
I wonder why thought the script in /etc/profile.d/enableqemunetworking.sh  didnt seem to work.


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#7 2022-06-26 17:54:57

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Running a privileged command at login.

Was the script executable?


Brianna Ghey — Rest In Power

Offline

#8 2022-06-27 14:03:09

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

I made it executable but still nothing.

#!/bin/sh

export TESTPROFILEDOTD=1970
virsh net-start default   &

The test var is changed but not the net default state.
I suspect that virt-manager and libvirtd process must have started first.


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#9 2022-06-27 14:08:48

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: Running a privileged command at login.

virsh is a libvirt client, so yes, libvirtd must be started in order for virsh to work..
although this https://dev1galaxy.org/viewtopic.php?pid=36441#p36441 makes your command unnecessary.. (you can also change this from virt-manager/GUI).

Offline

#10 2022-06-27 16:17:01

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

xinomilo wrote:

virsh is a libvirt client, so yes, libvirtd must be started in order for virsh to work..
although this https://dev1galaxy.org/viewtopic.php?pid=36441#p36441 makes your command unnecessary.. (you can also change this from virt-manager/GUI).

Yes i understand that. But i was curious to see if indeed a 'root' command can be executed in profile.d
So i could make the script wait and poll the processes and when libvirt is executed then to execute the command!

Last edited by chomwitt (2022-06-27 17:39:03)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#11 2022-06-27 17:12:32

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Running a privileged command at login.

Head_on_a_Stick wrote:

Was the script executable?

Sorry, that was a stupid question. Files in /etc/profile.d/ are sourced rather than executed. D'oh!


Brianna Ghey — Rest In Power

Offline

#12 2022-06-27 17:43:05

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

Head_on_a_Stick wrote:
Head_on_a_Stick wrote:

Was the script executable?

Sorry, that was a stupid question. Files in /etc/profile.d/ are sourced rather than executed. D'oh!

That explains why other scripts in profile.d werent executable.

Generaly i realized that profile.d is for preparing the system wide enviroment (of bash only or more generally ?)
So a more sound approach would be to start libvirtd and then make sure the default networking is enabled .


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#13 2022-06-27 17:49:15

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

xinomilo wrote:

.. (you can also change this from virt-manager/GUI).

From where ? From general options or a VM options ? I didnt find anything.


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#14 2022-06-27 17:57:44

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

Reading here https://www.linuxfromscratch.org/blfs/v … ofile.html
it seems that profile.d is for scripts that set up the shell enviroments.
So if i wanted to setup an application and it's initial set up i should do it from somewhere else.
But i've just read an askubuntu post where network config is attempted from a profile.d script.

Last edited by chomwitt (2022-06-27 18:00:11)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#15 2022-06-27 17:58:05

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: Running a privileged command at login.

chomwitt wrote:

From where ? From general options or a VM options ? I didnt find anything.

Connection Options.
if you already connected virt-manager to local libvirtd : choose that (qemu:///system) connection and :
(menu) Edit -> Connection Details -> Virtual Networks tab -> choose network, and check "Autostart On Boot"  on network Details.

Offline

#16 2022-06-27 18:02:59

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

xinomilo wrote:
chomwitt wrote:

From where ? From general options or a VM options ? I didnt find anything.

Connection Options.
if you already connected virt-manager to local libvirtd : choose that (qemu:///system) connection and :
(menu) Edit -> Connection Details -> Virtual Networks tab -> choose network, and check "Autostart On Boot"  on network Details.

I found it. Thanks!


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

#17 2022-06-27 23:46:50

chomwitt
Member
Registered: 2019-09-24
Posts: 116  

Re: Running a privileged command at login.

Interestingly invocation section of man page of bash dont refer to profile.d .
So maybe it started as a distro practice that stuck  and now it's used a a global config-set up space ?
I found an interesting discussion here.

It seems that profile.d is used in some distros that use some shells that parse that folder for application specifics setups.

In my devuan installation:

/etc/profile.d$ ls
bash_completion.sh       flatpak.sh  gawk.sh      vte.csh  gawk.csh    vte-2.91.sh

But that wont work in a case like mine but only if libvirtd was reading some shell enviroment
variable to determine what net setup to enable when started.

So i guess profile.d is one way to setup an 'enviroment' for applications that would look to certain env variables.
If an app looks only to a config file profile.d it's not needed.

In my case i found first here  about a command that fixes
a network error in virt-manager. Now as @xinomilo told me that can be set either with a terminal command or a gui setting   that changes a relative setting.

I propably was unlucky finding only the first 'solution'  that make me understand that a command fixes an error . But now it seems it's just an application
setting that propably sitting in a config file and there are two ways to change that 'file' and propably to edit it by a text editor.
And maybe virt-manager shouldnt either report it as an error! That small detail could have put me into a different fix mentality and not in the 'config' mentality.

To sum it up. It was a setting issue masqueraded as a  pseudo 'correct functioning' issue.

Last edited by chomwitt (2022-06-28 00:31:49)


Devuan(Chimaera)(Daedalus)  DS+WM: XorgX11server+StumpVM

Offline

Board footer