Re: Busybox in Debian

2018-01-14 Thread Denys Vlasenko
On Wed, Aug 23, 2017 at 2:43 AM, Ben Hutchings  wrote:
>> > > > On Mon, 2017-08-14 at 16:42 +0200, Denys Vlasenko wrote:
>> > > > > > > run-init
>> > > > >
>> > > > > This tool is doing this:
>> > > >
>> > > > [...]
>> > > > > There is the "switch_root" tool in util-linux which does the
>> > > > > crucial part of this functionality - deleting / remounting /
>> > > > > chrooting.
>> > > > > It is in bbox too.
>> > > >
>> > > > initramfs-tools used to use switch_root if possible, but it
>> > > > didn't
>> > > > support the -d (drop capabilities) option.  Later on we needed
>> > > > validation of the init filename to support symlinks (e.g.
>> > > > /sbin/init ->
>> > > > /lib/systemd/systemd), so I added and used the -n (dry run)
>> > > > option to
>> > > > run-init.  busybox would need to support both of these.
>> > >
>> > > I added run-init to busybox just now, but I don't see -n option
>> > > in
>> > > klibc-2.0.4 source. Can you point me to the source code with -n?
>> >
>> > It's not upstream yet, but in a Debian patch:
>> > https://sources.debian.net/src/klibc/2.0.4-9/debian/patches/run-ini
>> > t-add-dry-run-mode.patch/
>>
>> Done:
>>
>> $ ./busybox run-init
>> BusyBox v1.28.0.git (2017-08-21 18:55:09 CEST) multi-call binary.
>>
>> Usage: run-init [-d CAP,CAP...] [-n] [-c CONSOLE_DEV] NEW_ROOT
>> NEW_INIT [ARGS]
>>
>> Free initramfs and switch to another root fs:
>> chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
>> execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
>>
>> -c DEVReopen stdio to DEV after switch
>> -d CAPS   Drop capabilities
>> -nDry run
>
> Great.  Once these changes are in the Debian package, I can update
> initramfs-tools to make klibc-utils optional.

busybox 1.28.0 is released, it contains the addition of run-init.



Re: Busybox in Debian

2017-08-25 Thread Ben Hutchings
On Wed, 2017-08-23 at 14:36 +0200, Denys Vlasenko wrote:
[...]
> I take you also will need ipconfig, as it seems to be the tool developed
> to handle IP autoconfiguration thingy:
> ip=::
> I'm looking at it right now.
> Can you point me to scripts / other places where it is used in Debian?

So far as I can see, there are no other places it is used.  klibc-utils 
has the only implementation, and the only other package using klibc-
utils is debirf - which doesn't use ipconfig.

Ben.

-- 
Ben Hutchings
One of the nice things about standards is that there are so many of
them.



signature.asc
Description: This is a digitally signed message part


Re: Busybox in Debian

2017-08-23 Thread Denys Vlasenko
On Wed, Aug 23, 2017 at 2:43 AM, Ben Hutchings  wrote:
> On Tue, 2017-08-22 at 10:38 +0200, Denys Vlasenko wrote:
>> > > I added run-init to busybox just now, but I don't see -n option
>> > > in
>> > > klibc-2.0.4 source. Can you point me to the source code with -n?
>> >
>> > It's not upstream yet, but in a Debian patch:
>> > https://sources.debian.net/src/klibc/2.0.4-9/debian/patches/run-ini
>> > t-add-dry-run-mode.patch/
>>
>> Done:
>>
>> $ ./busybox run-init
>> BusyBox v1.28.0.git (2017-08-21 18:55:09 CEST) multi-call binary.
>>
>> Usage: run-init [-d CAP,CAP...] [-n] [-c CONSOLE_DEV] NEW_ROOT
>> NEW_INIT [ARGS]
>>
>> Free initramfs and switch to another root fs:
>> chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
>> execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
>>
>> -c DEVReopen stdio to DEV after switch
>> -d CAPS   Drop capabilities
>> -nDry run
>
> Great.  Once these changes are in the Debian package, I can update
> initramfs-tools to make klibc-utils optional.

I take you also will need ipconfig, as it seems to be the tool developed
to handle IP autoconfiguration thingy:
ip=::
I'm looking at it right now.
Can you point me to scripts / other places where it is used in Debian?



Re: Busybox in Debian

2017-08-22 Thread Ben Hutchings
On Tue, 2017-08-22 at 10:38 +0200, Denys Vlasenko wrote:
> On Mon, Aug 21, 2017 at 8:38 PM, Ben Hutchings 
> wrote:
> > On Mon, 2017-08-21 at 19:40 +0200, Denys Vlasenko wrote:
> > > > On Mon, Aug 14, 2017 at 5:12 PM, Ben Hutchings  > > > g.uk> wrote:
> > > > On Mon, 2017-08-14 at 16:42 +0200, Denys Vlasenko wrote:
> > > > > > > run-init
> > > > > 
> > > > > This tool is doing this:
> > > > 
> > > > [...]
> > > > > There is the "switch_root" tool in util-linux which does the
> > > > > crucial part of this functionality - deleting / remounting /
> > > > > chrooting.
> > > > > It is in bbox too.
> > > > 
> > > > initramfs-tools used to use switch_root if possible, but it
> > > > didn't
> > > > support the -d (drop capabilities) option.  Later on we needed
> > > > validation of the init filename to support symlinks (e.g.
> > > > /sbin/init ->
> > > > /lib/systemd/systemd), so I added and used the -n (dry run)
> > > > option to
> > > > run-init.  busybox would need to support both of these.
> > > 
> > > I added run-init to busybox just now, but I don't see -n option
> > > in
> > > klibc-2.0.4 source. Can you point me to the source code with -n?
> > 
> > It's not upstream yet, but in a Debian patch:
> > https://sources.debian.net/src/klibc/2.0.4-9/debian/patches/run-ini
> > t-add-dry-run-mode.patch/
> 
> Done:
> 
> $ ./busybox run-init
> BusyBox v1.28.0.git (2017-08-21 18:55:09 CEST) multi-call binary.
> 
> Usage: run-init [-d CAP,CAP...] [-n] [-c CONSOLE_DEV] NEW_ROOT
> NEW_INIT [ARGS]
> 
> Free initramfs and switch to another root fs:
> chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
> execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
> 
> -c DEVReopen stdio to DEV after switch
> -d CAPS   Drop capabilities
> -nDry run

Great.  Once these changes are in the Debian package, I can update
initramfs-tools to make klibc-utils optional.

Ben.

-- 
Ben Hutchings
Make three consecutive correct guesses and you will be considered an
expert.



signature.asc
Description: This is a digitally signed message part


Re: Busybox in Debian

2017-08-22 Thread Denys Vlasenko
On Mon, Aug 21, 2017 at 8:38 PM, Ben Hutchings  wrote:
> On Mon, 2017-08-21 at 19:40 +0200, Denys Vlasenko wrote:
>> > On Mon, Aug 14, 2017 at 5:12 PM, Ben Hutchings  
>> > wrote:
>> > On Mon, 2017-08-14 at 16:42 +0200, Denys Vlasenko wrote:
>> > > > > run-init
>> > >
>> > > This tool is doing this:
>> >
>> > [...]
>> > > There is the "switch_root" tool in util-linux which does the
>> > > crucial part of this functionality - deleting / remounting / chrooting.
>> > > It is in bbox too.
>> >
>> > initramfs-tools used to use switch_root if possible, but it didn't
>> > support the -d (drop capabilities) option.  Later on we needed
>> > validation of the init filename to support symlinks (e.g. /sbin/init ->
>> > /lib/systemd/systemd), so I added and used the -n (dry run) option to
>> > run-init.  busybox would need to support both of these.
>>
>> I added run-init to busybox just now, but I don't see -n option in
>> klibc-2.0.4 source. Can you point me to the source code with -n?
>
> It's not upstream yet, but in a Debian patch:
> https://sources.debian.net/src/klibc/2.0.4-9/debian/patches/run-init-add-dry-run-mode.patch/

Done:

$ ./busybox run-init
BusyBox v1.28.0.git (2017-08-21 18:55:09 CEST) multi-call binary.

Usage: run-init [-d CAP,CAP...] [-n] [-c CONSOLE_DEV] NEW_ROOT NEW_INIT [ARGS]

Free initramfs and switch to another root fs:
chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.

-c DEVReopen stdio to DEV after switch
-d CAPS   Drop capabilities
-nDry run



Re: Busybox in Debian

2017-08-21 Thread Ben Hutchings
On Mon, 2017-08-21 at 19:40 +0200, Denys Vlasenko wrote:
> > On Mon, Aug 14, 2017 at 5:12 PM, Ben Hutchings  wrote:
> > On Mon, 2017-08-14 at 16:42 +0200, Denys Vlasenko wrote:
> > > > > run-init
> > > 
> > > This tool is doing this:
> > 
> > [...]
> > > There is the "switch_root" tool in util-linux which does the
> > > crucial part of this functionality - deleting / remounting / chrooting.
> > > It is in bbox too.
> > 
> > initramfs-tools used to use switch_root if possible, but it didn't
> > support the -d (drop capabilities) option.  Later on we needed
> > validation of the init filename to support symlinks (e.g. /sbin/init ->
> > /lib/systemd/systemd), so I added and used the -n (dry run) option to
> > run-init.  busybox would need to support both of these.
> 
> I added run-init to busybox just now, but I don't see -n option in
> klibc-2.0.4 source. Can you point me to the source code with -n?

It's not upstream yet, but in a Debian patch:
https://sources.debian.net/src/klibc/2.0.4-9/debian/patches/run-init-add-dry-run-mode.patch/

Ben.

-- 
Ben Hutchings
Make three consecutive correct guesses and you will be considered an
expert.


signature.asc
Description: This is a digitally signed message part


Re: Busybox in Debian

2017-08-21 Thread Denys Vlasenko
On Mon, Aug 14, 2017 at 5:12 PM, Ben Hutchings  wrote:
> On Mon, 2017-08-14 at 16:42 +0200, Denys Vlasenko wrote:
>> > > run-init
>>
>> This tool is doing this:
> [...]
>> There is the "switch_root" tool in util-linux which does the
>> crucial part of this functionality - deleting / remounting / chrooting.
>> It is in bbox too.
>
> initramfs-tools used to use switch_root if possible, but it didn't
> support the -d (drop capabilities) option.  Later on we needed
> validation of the init filename to support symlinks (e.g. /sbin/init ->
> /lib/systemd/systemd), so I added and used the -n (dry run) option to
> run-init.  busybox would need to support both of these.

I added run-init to busybox just now, but I don't see -n option in
klibc-2.0.4 source. Can you point me to the source code with -n?



Re: Busybox in Debian

2017-08-18 Thread Denys Vlasenko
On Mon, Aug 14, 2017 at 5:12 PM, Ben Hutchings  wrote:
>> If you want "resume" and "ipconfig" in bbox, I can do that.
>
> Go for it.

Added resume, nuke, minips so far.



Re: Busybox in Debian

2017-08-14 Thread Ben Hutchings
On Mon, 2017-08-14 at 16:42 +0200, Denys Vlasenko wrote:
[...]
> > > minips
> 
> It's just mini-ps. Proliferation of reinvented tools
> with slightly different names.

It's not a POSIX-compliant ps implementation.  Anyway, initramfs-tools
doesn't need it.

> > > nuke
> 
> This is "rm -rf -- FILE". Should not be necessary.

klibc-utils doesn't implemnt rm, only nuke.  busybox could install nuke
in the initramfs as a wrapper for rm.

> > > resume
> 
> Writes "maj:min:offset" to /sys/power/resume.
> Looks like this is support for resume from disk?

Correct.

> > > run-init
> 
> This tool is doing this:
[...]
> There is the "switch_root" tool in util-linux which does the
> crucial part of this functionality - deleting / remounting / chrooting.
> It is in bbox too.

initramfs-tools used to use switch_root if possible, but it didn't
support the -d (drop capabilities) option.  Later on we needed
validation of the init filename to support symlinks (e.g. /sbin/init ->
/lib/systemd/systemd), so I added and used the -n (dry run) option to
run-init.  busybox would need to support both of these.

> If you want "resume" and "ipconfig" in bbox, I can do that.

Go for it.

Ben.

-- 
Ben Hutchings
Life is what happens to you while you're busy making other plans.
  - John Lennon



signature.asc
Description: This is a digitally signed message part


Re: Busybox in Debian

2017-08-14 Thread Denys Vlasenko
>> ipconfig

Looks like it is used to run DHCP / BOOTP / RARP
on several interfaces, including a possibility
to run it on _all_ existing interfaces
(excluding loopback and point-to-point).
I see how this can be useful during boot.


>> minips

It's just mini-ps. Proliferation of reinvented tools
with slightly different names.


>> nuke

This is "rm -rf -- FILE". Should not be necessary.


>> resume

Writes "maj:min:offset" to /sys/power/resume.
Looks like this is support for resume from disk?


>> run-init

This tool is doing this:

Usage: exec run-init [-d caps] [-c consoledev] /real-root /sbin/init [args]
/*
 * run_init(realroot, consoledev, drop_caps, init, initargs)
 *
 * This function should be called as the last thing in kinit,
 * from initramfs, it does the following:
 *
 * - Delete all files in the initramfs;
 * - Remounts /real-root onto the root filesystem;
 * - Chroots;
 * - Drops comma-separated list of capabilities;
 * - Opens /dev/console;
 * - Spawns the specified init program (with arguments.)
 *
 * On failure, returns a human-readable error message.
 */

There is the "switch_root" tool in util-linux which does the
crucial part of this functionality - deleting / remounting / chrooting.
It is in bbox too.



If you want "resume" and "ipconfig" in bbox, I can do that.



Re: Busybox in Debian

2017-08-14 Thread Denys Vlasenko
On Mon, Aug 14, 2017 at 3:05 PM, Ben Hutchings  wrote:
> On Mon, 2017-08-14 at 14:55 +0200, Denys Vlasenko wrote:
>> On Sat, Aug 12, 2017 at 4:15 PM, Ben Hutchings 
>> wrote:
>> > On Fri, 2017-08-11 at 14:54 -0400, Chris Boot wrote:
>> > [...]
>> > > - The default initramfs assembly system, initramfs-tools, incorporates
>> > > busybox into the initramfs and it's used until the root filesystem (and
>> > > /usr if separate) is mounted and can be pivot_rooted into. We also use
>> > > parts of klibc in the initramfs, and I'm not yet entirely clear what
>> > > tools in the initramfs are klibc tools, busybox applets or executables
>> > > copied from the running system.
>> >
>> > [...]
>> >
>> > If initramfs-tools is configured to use busybox, busybox installs all
>> > its commands and then klibc-utils installs any commands that are not
>> > already there.  So for any command that they both implement, the
>> > busybox implementation is used.
>>
>> Do you have a list of tools klibc-utils installs?
>
> If busybox is used, then klibc-utils provides these:
>
> chroot
> losetup
> pivot_root

There are such applets in busybox too.
If they are buggy or incompatible (e.g. a missing option),
please let me know.

> halt
> poweroff
> reboot

These applets are in busybox too, but they may do
bbox-specific actions depending on configuration.

If FEATURE_CALL_TELINIT=y, they run "telinit N",
expecting it to know how to signal init.

Otherwise they assume the bbox init is on the system,
and they simply signal it:
SIGUSR1 = halt, SIGUSR2 = poweroff, SIGTERM = reboot.

/* talk to init */
if (!ENABLE_FEATURE_CALL_TELINIT) {
/* bbox init assumed */
rc = kill(1, signals[which]);
} else {
/* SysV style init assumed */
/* runlevels:
 * 0 == shutdown
 * 6 == reboot */
execlp(CONFIG_TELINIT_PATH,
CONFIG_TELINIT_PATH,
which == 2 ? "6" : "0",
(char *)NULL
);
bb_perror_msg_and_die("can't execute '%s'",
CONFIG_TELINIT_PATH);
}


> fstype

What does this do?


> nfsmount

And this one? If ordinary mount can't mount NFS for some reason,
it's interesting to look into that reason. Sometime ago,
kernel grew the ability to mount NFS without funky binary API
in mount syscall, so it's even easier now - mount tool only has to
resolve DNS name to an IP address.

If you are going to play with it, not that you probaly do _not_
need FEATURE_MOUNT_NFS=y: it is
"Support mounting NFS file systems on Linux < 2.6.23" option,
not "You need this, or else NFS mounts will not work".


> ipconfig
> minips
> nuke
> resume
> run-init

These look like klibc-utils inventions?



Re: Busybox in Debian

2017-08-14 Thread Denys Vlasenko
On Sat, Aug 12, 2017 at 4:15 PM, Ben Hutchings  wrote:
> On Fri, 2017-08-11 at 14:54 -0400, Chris Boot wrote:
> [...]
>> - The default initramfs assembly system, initramfs-tools, incorporates
>> busybox into the initramfs and it's used until the root filesystem (and
>> /usr if separate) is mounted and can be pivot_rooted into. We also use
>> parts of klibc in the initramfs, and I'm not yet entirely clear what
>> tools in the initramfs are klibc tools, busybox applets or executables
>> copied from the running system.
> [...]
>
> If initramfs-tools is configured to use busybox, busybox installs all
> its commands and then klibc-utils installs any commands that are not
> already there.  So for any command that they both implement, the
> busybox implementation is used.

Do you have a list of tools klibc-utils installs?



Re: Busybox in Debian

2017-08-14 Thread Ben Hutchings
On Mon, 2017-08-14 at 14:55 +0200, Denys Vlasenko wrote:
> On Sat, Aug 12, 2017 at 4:15 PM, Ben Hutchings 
> wrote:
> > On Fri, 2017-08-11 at 14:54 -0400, Chris Boot wrote:
> > [...]
> > > - The default initramfs assembly system, initramfs-tools, incorporates
> > > busybox into the initramfs and it's used until the root filesystem (and
> > > /usr if separate) is mounted and can be pivot_rooted into. We also use
> > > parts of klibc in the initramfs, and I'm not yet entirely clear what
> > > tools in the initramfs are klibc tools, busybox applets or executables
> > > copied from the running system.
> > 
> > [...]
> > 
> > If initramfs-tools is configured to use busybox, busybox installs all
> > its commands and then klibc-utils installs any commands that are not
> > already there.  So for any command that they both implement, the
> > busybox implementation is used.
> 
> Do you have a list of tools klibc-utils installs?

If busybox is used, then klibc-utils provides these:

chroot
fstype
halt
ipconfig
losetup
minips
nfsmount
nuke
pivot_root
poweroff
reboot
resume
run-init

(not all of which are actually used).

Ben.

-- 
Ben Hutchings
Life is what happens to you while you're busy making other plans.
  - John Lennon



signature.asc
Description: This is a digitally signed message part


Re: Busybox in Debian

2017-08-12 Thread Ben Hutchings
On Fri, 2017-08-11 at 14:54 -0400, Chris Boot wrote:
[...]
> - The default initramfs assembly system, initramfs-tools, incorporates
> busybox into the initramfs and it's used until the root filesystem (and
> /usr if separate) is mounted and can be pivot_rooted into. We also use
> parts of klibc in the initramfs, and I'm not yet entirely clear what
> tools in the initramfs are klibc tools, busybox applets or executables
> copied from the running system.
[...]

If initramfs-tools is configured to use busybox, busybox installs all
its commands and then klibc-utils installs any commands that are not
already there.  So for any command that they both implement, the
busybox implementation is used.

Ben.

-- 
Ben Hutchings
Never put off till tomorrow what you can avoid all together.



signature.asc
Description: This is a digitally signed message part


Re: Busybox in Debian

2017-08-11 Thread Chris Boot
On 11/08/17 14:13, Denys Vlasenko wrote:
>> In the mean time, please let us know if you have any questions.
> What is Debian using bbox for?

Hi Denys,

It's used principally in two places:

- It's bundled in the Debian Installer ramdisk and used as the shell,
bootstrap for D-I and its applets provide most functionality in the
installer environment.

- The default initramfs assembly system, initramfs-tools, incorporates
busybox into the initramfs and it's used until the root filesystem (and
/usr if separate) is mounted and can be pivot_rooted into. We also use
parts of klibc in the initramfs, and I'm not yet entirely clear what
tools in the initramfs are klibc tools, busybox applets or executables
copied from the running system.

There is also a statically linked package that may be useful for
rescuing a damaged system, but its use doesn't appear to be widespread.

As you can see it's actually a critical piece of the puzzle in Debian,
so we're keen to make sure someone is actively taking care of it now
rather than the Debian Installer and/or kernel teams chipping in now and
again to fix the worst of the bugs.

Cheers,
Chris

-- 
Chris Boot
bo...@debian.org
GPG: 8467 53CB 1921 3142 C56D  C918 F5C8 3C05 D9CE 



Re: Busybox in Debian

2017-08-11 Thread Denys Vlasenko
On Fri, Aug 11, 2017 at 7:01 PM, Chris Boot  wrote:
> Hi all,
>
> This is a short note to say that Christoph (CCed) and I are taking over
> packaging of Busybox in Debian. I'm hoping that we will both be fairly
> active in here (the busybox mailing list) from now on.
>
> We've got a lot of work to do to update Busybox in Debian to a more
> modern version, triage bugs, tidy things up and basically make the
> Debian package look alive again.

Great to hear.

> In the mean time, please let us know if you have any questions.

What is Debian using bbox for?



Busybox in Debian

2017-08-11 Thread Chris Boot
Hi all,

This is a short note to say that Christoph (CCed) and I are taking over
packaging of Busybox in Debian. I'm hoping that we will both be fairly
active in here (the busybox mailing list) from now on.

We've got a lot of work to do to update Busybox in Debian to a more
modern version, triage bugs, tidy things up and basically make the
Debian package look alive again. Please bear with us, this won't be a
quick process.

In the mean time, please let us know if you have any questions.

Cheers,
Chris

-- 
Chris Boot
bo...@debian.org
GPG: 8467 53CB 1921 3142 C56D  C918 F5C8 3C05 D9CE 



signature.asc
Description: OpenPGP digital signature