Re: Run script as root without sudo

2021-08-22 Thread grarpamp
> I just hope that in 5 years from now I can find this mailing list post > when I completely forgot the whole thing and can't figure how to make it > work... The collective memories can be there for you... :) See it can often be much easier to find posts after you import the entire FreeBSD Mail A

Re: Run script as root without sudo

2021-08-21 Thread Aristedes Maniatis via freebsd-stable
My goal is to use standard AMI so that upgrading to new FreeBSD releases is easy without a manual process to build a new custom AMI each time. I've submitted a patch to saltstack which allows the bootstrap process to work without sudo on a clean FreeBSD AMI. On Linux the bootstrap script is run

Re: Run script as root without sudo

2021-08-19 Thread Aristedes Maniatis via freebsd-stable
Oh!!! -c is a csh option Someone had to have created that command structure as a practical joke on a co-worker back in about 1975... Let's make the login user optional, but if you opt not to use it the next argument works completely differently. Now that I understand it, I see which par

Re: Run script as root without sudo

2021-08-19 Thread Patrick M. Hausen
Hi Ari, > Am 19.08.2021 um 10:33 schrieb Aristedes Maniatis via freebsd-stable > : > > The man page is very confusing. Yes, it says -c is class. But it also has > examples like this: > [...] > What is -c supposed to do? Everything after the user name is handed to /bin/sh. So it's executing sh

Re: Run script as root without sudo

2021-08-19 Thread Andriy Gapon
On 2021-08-19 11:33, Aristedes Maniatis wrote: > The man page is very confusing. Yes, it says -c is class. But it also > has examples like this: > >  su -m operator -c 'shutdown -p now' > > > > In my testing, this works: > > $ su - root -c 'date' > Thu Aug 19 08:31:53 UTC 2021 > > and this do

Re: Run script as root without sudo

2021-08-19 Thread Aristedes Maniatis via freebsd-stable
The man page is very confusing. Yes, it says -c is class. But it also has examples like this:  su -m operator -c 'shutdown -p now' In my testing, this works: $ su - root -c 'date' Thu Aug 19 08:31:53 UTC 2021 and this does not: $ su - root 'date' date: No such file or directory. What is

Re: Run script as root without sudo

2021-08-19 Thread Andriy Gapon
On 2021-08-19 08:31, Aristedes Maniatis via freebsd-stable wrote: > I've got some scripts which are intended to run on a new EC2 instance > right after it is created. Since the script needs to install packages it > need to run as root. But because I don't have sudo installed at this > point (it is

Re: Run script as root without sudo

2021-08-18 Thread Walter Parker
On Wed, Aug 18, 2021 at 11:36 PM Jonathan Chen wrote: > On Thu, 19 Aug 2021 at 18:25, Aristedes Maniatis wrote: > > > > That would require root to put the file there and then to reboot the > > machine. > > In which case, wouldn't it be simpler to just start a new instance, > install your package

Re: Run script as root without sudo

2021-08-18 Thread Matt Garber
> That would require root to put the file there and then to reboot the > machine. > > Ari As these are EC2 instances, you should be able to use user-data provided to the instance’s configinit (like cloud-init) with firstboot_pkgs_list=“sudo” similar to Colin’s example here[1], and then run your

Re: Run script as root without sudo

2021-08-18 Thread Jonathan Chen
On Thu, 19 Aug 2021 at 18:25, Aristedes Maniatis wrote: > > That would require root to put the file there and then to reboot the > machine. In which case, wouldn't it be simpler to just start a new instance, install your packages by hand, and then take a snapshot of the volume and convert it to a

Re: Run script as root without sudo

2021-08-18 Thread Aristedes Maniatis via freebsd-stable
That would require root to put the file there and then to reboot the machine. Ari On 19/8/21 4:16pm, Jonathan Chen wrote: On Thu, 19 Aug 2021 at 17:33, Aristedes Maniatis via freebsd-stable wrote: [...] How else can I get this script running as root remotely in a completely unattended way?

Re: Run script as root without sudo

2021-08-18 Thread Jonathan Chen
On Thu, 19 Aug 2021 at 17:33, Aristedes Maniatis via freebsd-stable wrote: [...] > How else can I get this script running as root remotely in a completely > unattended way? The way it's usually done is with an rc script in /usr/local/etc/rc.d, eg: /usr/local/etc/rc.d/myscript and add the entry

Run script as root without sudo

2021-08-18 Thread Aristedes Maniatis via freebsd-stable
I've got some scripts which are intended to run on a new EC2 instance right after it is created. Since the script needs to install packages it need to run as root. But because I don't have sudo installed at this point (it is a brand new instance), I've only got 'su' to get root. The script its