Skip to contentSkip to conversation

Add option to copy config file to rootfs

PATCH New Nathaniel Roach 5 participants 9 messages Jul 31, 2014 – Aug 1, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

BR2_CONFIG_COPY copies the config file to /etc/buildroot.config as 0600 during target-finalize after overlay copy, but before post-build script install.

---
Changes v1 to v2
- Corrected wording of config helper message (Thomas De Schampheleire)
- Moved order in menu to reflect actual order of the operation

---
 Makefile         |  4 ++++
 system/Config.in | 11 +++++++++++
 2 files changed, 15 insertions(+)
Makefile +4 -0
index 022beea..cc49291 100644
@@ -614,6 +614,10 @@ endif
 			--chmod=Du+w --exclude .empty --exclude '*~' \
 			$(d)/ $(TARGET_DIR)$(sep))
 
+ifeq ($(BR2_CONFIG_COPY),y)
+	$(INSTALL) -m 0600 .config $(TARGET_DIR)/etc/buildroot.config
+endif
+
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
 		$(call MESSAGE,"Executing post-build script $(s)"); \
 		$(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
system/Config.in +11 -0
index e7e146a..a1ff23f 100644
@@ -339,6 +339,17 @@ config BR2_ROOTFS_OVERLAY
 	  They are copied as-is into the rootfs, excluding files ending with
 	  ~ and .git, .svn and .hg directories.
 
+config BR2_CONFIG_COPY
+	bool "Copy buildroot .config file to rootfs"
+	help
+	  Copies the buildroot .config file into the rootfs.
+	  This may be useful for debugging.
+
+	  It will be put in /etc/buildroot.config with a mode of 0600
+
+	  However, be wary that it will contain the root password
+	  (if set) and other possibly sensitive data.
+
 config BR2_ROOTFS_POST_BUILD_SCRIPT
 	string "Custom scripts to run before creating filesystem images"
 	default ""
Signature · 1 line
2.0.1
#1 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

Nathaniel, All,

On 2014-07-31 23:26 +0800, Nathaniel Roach spake thusly:

Quoted 3 lines

BR2_CONFIG_COPY copies the config file to /etc/buildroot.config as 0600 during target-finalize after overlay copy, but before post-build script install.

I wonder what would be the use-case for this?

I think the case where one would want this file in the generated filesystem is a corner case, and that it would be better served with a post-build script.

Regards,
Yann E. MORIN.

Quoted 53 lines

---
Changes v1 to v2
- Corrected wording of config helper message (Thomas De Schampheleire)
- Moved order in menu to reflect actual order of the operation

---
 Makefile         |  4 ++++
 system/Config.in | 11 +++++++++++
 2 files changed, 15 insertions(+)
Makefile +4 -0
index 022beea..cc49291 100644
@@ -614,6 +614,10 @@ endif
 			--chmod=Du+w --exclude .empty --exclude '*~' \
 			$(d)/ $(TARGET_DIR)$(sep))
 
+ifeq ($(BR2_CONFIG_COPY),y)
+	$(INSTALL) -m 0600 .config $(TARGET_DIR)/etc/buildroot.config
+endif
+
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
 		$(call MESSAGE,"Executing post-build script $(s)"); \
 		$(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
system/Config.in +11 -0
index e7e146a..a1ff23f 100644
@@ -339,6 +339,17 @@ config BR2_ROOTFS_OVERLAY
 	  They are copied as-is into the rootfs, excluding files ending with
 	  ~ and .git, .svn and .hg directories.
 
+config BR2_CONFIG_COPY
+	bool "Copy buildroot .config file to rootfs"
+	help
+	  Copies the buildroot .config file into the rootfs.
+	  This may be useful for debugging.
+
+	  It will be put in /etc/buildroot.config with a mode of 0600
+
+	  However, be wary that it will contain the root password
+	  (if set) and other possibly sensitive data.
+
 config BR2_ROOTFS_POST_BUILD_SCRIPT
 	string "Custom scripts to run before creating filesystem images"
 	default ""
Signature · 6 lines
2.0.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

"Yann E. MORIN" <[email protected]> schreef:

Quoted 8 lines

Nathaniel, All,

On 2014-07-31 23:26 +0800, Nathaniel Roach spake thusly:

Quoted 3 lines

BR2_CONFIG_COPY copies the config file to /etc/buildroot.config as 0600 during target-finalize after overlay copy, but before post-build script install.

I wonder what would be the use-case for this?

What is the use case in crosstool-NG to save the
configuration and log alongside the toolchain? Or what about the /proc/config.gz feature of the Linux kernel?
It allows people that receive the generated images to
easily inspect and reproduce the configuration.

One doesn't even need to think about legal counter- arguments here: even within the same company it
can be useful to be able to inspect the configuration of a running system...

Quoted 4 lines

I think the case where one would want this file in the generated filesystem is a corner case, and that it would be better served with a post-build script.

I think this is a feature that deserves to be in Buildroot
directly. Just like rootfs-overlay used to be
something that people had to do manually from their
post build script, but later became a supported
feature because many people found it useful, or the
feature to set the root password, this is something that is generally useful by many users, even those
that don't fully know how to use the post build script
to it's full ability, or did not yet realize the usefulness
of the saving of the configuration.

Best regards,
Thomas

#3 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

Dear Thomas De Schampheleire,

Quoted 4 lines · Thomas De Schampheleire
Quoted 3 lines

I think the case where one would want this file in the generated filesystem is a corner case, and that it would be better served with a post-build script.

Quoted 9 lines

I think this is a feature that deserves to be in Buildroot directly. Just like rootfs-overlay used to be
something that people had to do manually from their
post build script, but later became a supported
feature because many people found it useful, or the feature to set the root password, this is something that is
generally useful by many users, even those that don't fully know how to use the post build script to it's full ability, or did not yet realize the usefulness of the saving of the configuration.

I don't really have a strong opinion on whether we should have this feature or not, but what bothers me is adding yet another global config option just for a small thing like that.

If we were to include the .config file in the rootfs, could we do it unconditionally? Or would the .config file size be problematic?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

Thomas Petazzoni <[email protected]> schreef:

Quoted 18 lines

Dear Thomas De Schampheleire,

Quoted 4 lines · Thomas De Schampheleire
Quoted 3 lines

I think the case where one would want this file in the generated filesystem is a corner case, and that it would be better served with a post-build script.

Quoted 9 lines

I think this is a feature that deserves to be in Buildroot directly. Just like rootfs-overlay used to be
something that people had to do manually from their
post build script, but later became a supported
feature because many people found it useful, or the feature to set the root password, this is something that is
generally useful by many users, even those that don't fully know how to use the post build script to it's full ability, or did not yet realize the usefulness of the saving of the configuration.

Quoted 6 lines

I don't really have a strong opinion on whether we should have this feature or not, but what bothers me is adding yet another global config option just for a small thing like that.

If we were to include the .config file in the rootfs, could we do it unconditionally? Or would the .config file size be problematic?

Not do much the size, but as specified in the help text
the potential root password will be readable too. So if you get a hand on the rootfs image, you can determine the password very easily, which is probably not acceptable by all.

Best regards,
Thomas

#5 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

Thomas?, All,

On 2014-07-31 20:40 +0200, Thomas De Schampheleire spake thusly:

Quoted 18 lines

Thomas Petazzoni <[email protected]> schreef:

Quoted 17 lines

Dear Thomas De Schampheleire,

Quoted 13 lines · Thomas De Schampheleire
Quoted 3 lines

I think the case where one would want this file in the generated filesystem is a corner case, and that it would be better served with a post-build script.

I think this is a feature that deserves to be in Buildroot directly. Just like rootfs-overlay used to be
something that people had to do manually from their
post build script, but later became a supported
feature because many people found it useful, or the feature to set the root password, this is something that is
generally useful by many users, even those that don't fully know how to use the post build script to it's full ability, or did not yet realize the usefulness of the saving of the configuration.

<sarcastic>
Great! Let's include in Buildroot all the cruft that a post-build script can do.
</sarcastic>

Sorry for the rant, really, but we introduced post-build scripts for a
reason: so that users can further customise their rootfs with whatever they want to put/remove/tweak in there, without polluting Buildroot with border-line behaviours.

And the root password, since you're speaking about it, is part of the behaviour of the target system. The .config is just sitting there, and serves no purpose in the running of the target system.

(crosstool-NG: everyone can make mistakes in their infancy! ;-) )

Quoted 4 lines
Quoted 4 lines

I don't really have a strong opinion on whether we should have this feature or not, but what bothers me is adding yet another global config option just for a small thing like that.

Quoted 8 lines
Quoted 2 lines

If we were to include the .config file in the rootfs, could we do it unconditionally? Or would the .config file size be problematic?

Not do much the size, but as specified in the help text
the potential root password will be readable too. So if you get a hand on the rootfs image, you can determine the password very easily, which is probably not acceptable by all.

That, plus the fact the .config will also contain info from the packages in br2-external, too, which might be a bit sensitive, and a definitive no-no for production images.

And I still believe this is more of a convenience option for internal use, or for development reasons. Production images will most probably never ever have this file in them (no more would they have /proc/config.gz either.)

So:
1. _I_ still _think_ this should be handled in a post-build script;
2. if we were to ever have this, this should *not* be unconditional;
3. it should default to 'n';
4. I will never ack this. :-p

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#6 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

"Yann E. MORIN" <[email protected]> schreef:

Quoted 60 lines

Thomas?, All,

On 2014-07-31 20:40 +0200, Thomas De Schampheleire spake thusly:

Quoted 18 lines

Thomas Petazzoni <[email protected]> schreef:

Quoted 17 lines

Dear Thomas De Schampheleire,

Quoted 13 lines · Thomas De Schampheleire
Quoted 3 lines

I think the case where one would want this file in the generated filesystem is a corner case, and that it would be better served with a post-build script.

I think this is a feature that deserves to be in Buildroot directly. Just like rootfs-overlay used to be
something that people had to do manually from their
post build script, but later became a supported
feature because many people found it useful, or the feature to set the root password, this is something that is
generally useful by many users, even those that don't fully know how to use the post build script to it's full ability, or did not yet realize the usefulness of the saving of the configuration.

<sarcastic>
Great! Let's include in Buildroot all the cruft that a post-build script can do.
</sarcastic>

Sorry for the rant, really, but we introduced post-build scripts for a
reason: so that users can further customise their rootfs with whatever they want to put/remove/tweak in there, without polluting Buildroot with border-line behaviours.

And the root password, since you're speaking about it, is part of the behaviour of the target system. The .config is just sitting there, and serves no purpose in the running of the target system.

(crosstool-NG: everyone can make mistakes in their infancy! ;-) )

Quoted 4 lines
Quoted 4 lines

I don't really have a strong opinion on whether we should have this feature or not, but what bothers me is adding yet another global config option just for a small thing like that.

Quoted 8 lines
Quoted 2 lines

If we were to include the .config file in the rootfs, could we do it unconditionally? Or would the .config file size be problematic?

Not do much the size, but as specified in the help text
the potential root password will be readable too. So if you get a hand on the rootfs image, you can determine the password very easily, which is probably not acceptable by all.

That, plus the fact the .config will also contain info from the packages in br2-external, too, which might be a bit sensitive, and a definitive no-no for production images.

And I still believe this is more of a convenience option for internal use, or for development reasons. Production images will most probably never ever have this file in them (no more would they have /proc/config.gz either.)

Quoted 5 lines

So:
1. _I_ still _think_ this should be handled in a post-build script;
2. if we were to ever have this, this should *not* be unconditional;
3. it should default to 'n';
4. I will never ack this. :-p

/me backs down... :-)

#7 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

In reply to Nathaniel Roach

Hi Nathaniel,

Quoted 18 lines · Nathaniel Roach

BR2_CONFIG_COPY copies the config file to /etc/buildroot.config as 0600 during target-finalize after overlay copy, but before post-build script install.

---
Changes v1 to v2
- Corrected wording of config helper message (Thomas De Schampheleire)
- Moved order in menu to reflect actual order of the operation

---
 Makefile         |  4 ++++
 system/Config.in | 11 +++++++++++
 2 files changed, 15 insertions(+)
Makefile +0 -0
index 022beea..cc49291 100644

Makefile endif · line 618

Quoted 5 lines
Makefile +2 -0
@@ -614,6 +614,10 @@ endif
                        --chmod=Du+w --exclude .empty --exclude '*~' \
                        $(d)/ $(TARGET_DIR)$(sep))
 
+ifeq ($(BR2_CONFIG_COPY),y)
+       $(INSTALL) -m 0600 .config $(TARGET_DIR)/etc/buildroot.config

Before you do the copy, would it be worth doing a savedefconfig (or like) activity to cleanup the .config file? Then the file on target would be much easier to read if you manually had to view it.

Thanks!

Signature · 3 lines
Matthew L Weber / Sr Software Engineer / Platform Software
matthew.weber at rockwellcollins.com
www.rockwellcollins.com
#8 lore raw

PATCH v2 1/1 Add option to copy config file to rootfs

In reply to Nathaniel Roach

Dear Nathaniel Roach,

Quoted 4 lines · Nathaniel Roach

BR2_CONFIG_COPY copies the config file to /etc/buildroot.config as 0600 during target-finalize after overlay copy, but before post-build script install.

Quoted 8 lines

---
Changes v1 to v2
- Corrected wording of config helper message (Thomas De Schampheleire)
- Moved order in menu to reflect actual order of the operation

---
 Makefile         |  4 ++++
 system/Config.in | 11 +++++++++++
 2 files changed, 15 insertions(+)

Thanks for the proposal, but apparently there's no really a consensus around it and there's a very simple way to do the same using a post-build script, so I've marked the patch as Rejected in patchwork.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com