Discussion:
[OpenWrt-Devel] [PATCH] Creating root default password in buildroot via menuconfig
Ben
2014-05-23 15:29:29 UTC
Permalink
Hi everybody,

to deploy minimal OpenWrt images on multiple routers it is necessary to
set a root password, while building the deployable file.

Therefore i added a patch that is setting a "default" password in the
"/etc/shadow" file of the "base-files" package. It is using the openssl
command of the building host to create the hash of the password.

Here are the diff files for both the current development branch (Barrier
Braker) and the 12.09 branch..please add the patches to both branches,
to be able to use it in the currently stable release as well.


*12.09-branch (http://git.openwrt.org/?p=12.09/openwrt.git;a=summary):*

Signed-off-by: Benjamin Pflueg <***@bensbox.de>
---
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 2152edd..db72656 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -9,6 +9,7 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk
+include $(INCLUDE_DIR)/baseconf.mk

PKG_NAME:=base-files
PKG_RELEASE:=118.2
@@ -113,6 +114,11 @@ define Package/base-files/install
$(1)/etc/openwrt_version \
$(1)/etc/openwrt_release

+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \
+ $(SED) 's/%P/x/g' $(1)/etc/shadow, \
+ $(SED) 's/%P/$(shell $(OPENSSL) passwd -1
$(BASECONF_ROOT_PASSWORD) | $(SED_PLAIN) -e 's/[/.$$^]/\\&/g' |
$(SED_PLAIN) -e 's/\$$/\$$\$$/g')/' $(1)/etc/shadow \
+ )
+
mkdir -p $(1)/CONTROL
mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs
diff --git a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow
index e989890..f35be79 100644
--- a/package/base-files/files/etc/shadow
+++ b/package/base-files/files/etc/shadow
@@ -1,4 +1,4 @@
-root:x:0:0:99999:7:::
+root:%P:0:0:99999:7:::
daemon:*:0:0:99999:7:::
ftp:*:0:0:99999:7:::
network:*:0:0:99999:7:::
diff --git a/package/base-files/image-config.in
b/package/base-files/image-config.in
index 1371356..79dee49 100644
--- a/package/base-files/image-config.in
+++ b/package/base-files/image-config.in
@@ -184,3 +184,19 @@ menuconfig VERSIONOPT
%d .. Distribution name or "openwrt", lowercase
%T .. Target name
%S .. Target/Subtarget name
+
+menuconfig BASECONFOPT
+ bool "Base system configurations" if IMAGEOPT
+ default n
+ help
+ In here you can set configurations like a default root
password.
+ They are suppose to be very basic and default settings
to the
+ vanilla OpenWRT firmware.
+
+ config BASECONF_ROOT_PASSWORD
+ string
+ prompt "Custom default root password" if BASECONFOPT
+ help
+ Usually the firmware does not have the root
password set.
+ Here you can set a default one, that will be in
effect
+ even after a factory reset.
diff --git a/rules.mk b/rules.mk
index e657eec..8c5d2c2 100644
--- a/rules.mk
+++ b/rules.mk
@@ -182,9 +182,11 @@ TARGET_AR:=$(TARGET_CROSS)ar
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(if $(CONFIG_INSTALL_LIBSTDCPP),$(TARGET_CROSS)g++,no)
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed
+SED:=$(SED_PLAIN) -i -e
CP:=cp -fpR
LN:=ln -sf
+OPENSSL:=openssl

INSTALL_BIN:=install -m0755
INSTALL_DIR:=install -d -m0755
diff --git a/include/baseconf.mk b/include/baseconf.mk
new file mode 100644
index 0000000..ad8db58
--- /dev/null
+++ b/include/baseconf.mk
@@ -0,0 +1,6 @@
+
+PKG_CONFIG_DEPENDS += \
+ CONFIG_BASECONF_ROOT_PASSWORD
+
+BASECONF_ROOT_PASSWORD:=$(call qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)




*devel-branch (http://git.openwrt.org/?p=openwrt.git;a=summary):*

Signed-off-by: Benjamin Pflueg <***@bensbox.de>
---
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 207af35..494047e 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -9,6 +9,7 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/version.mk
include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/baseconf.mk

PKG_NAME:=base-files
PKG_RELEASE:=152
@@ -113,6 +114,11 @@ define Package/base-files/install
$(1)/etc/openwrt_version \
$(1)/etc/openwrt_release

+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \
+ $(SED) 's/%P/x/g' $(1)/etc/shadow, \
+ $(SED) 's/%P/$(shell $(OPENSSL) passwd -1
$(BASECONF_ROOT_PASSWORD) | $(SED_PLAIN) -e 's/[/.$$^]/\\&/g' |
$(SED_PLAIN) -e 's/\$$/\$$\$$/g')/' $(1)/etc/shadow \
+ )
+
mkdir -p $(1)/CONTROL
mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs
diff --git a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow
index 4b4154f..f35be79 100644
--- a/package/base-files/files/etc/shadow
+++ b/package/base-files/files/etc/shadow
@@ -1,4 +1,4 @@
-root::0:0:99999:7:::
+root:%P:0:0:99999:7:::
daemon:*:0:0:99999:7:::
ftp:*:0:0:99999:7:::
network:*:0:0:99999:7:::
diff --git a/package/base-files/image-config.in
b/package/base-files/image-config.in
index a9eb78c..2f2e22a 100644
--- a/package/base-files/image-config.in
+++ b/package/base-files/image-config.in
@@ -221,3 +221,19 @@ menuconfig SMIMEOPT
Path to a file containing the passphrase for the signing key.
If the signing key is not encrypted and does not
require a passphrase,
this option may be left blank.
+
+menuconfig BASECONFOPT
+ bool "Base system configurations" if IMAGEOPT
+ default n
+ help
+ In here you can set configurations like a default root password.
+ They are suppose to be very basic and default settings to the
+ vanilla OpenWRT firmware.
+
+ config BASECONF_ROOT_PASSWORD
+ string
+ prompt "Custom default root password" if BASECONFOPT
+ help
+ Usually the firmware does not have the root password set.
+ Here you can set a default one, that will be in effect
+ even after a factory reset.
diff --git a/rules.mk b/rules.mk
index a84636a..ef8ef2f 100644
--- a/rules.mk
+++ b/rules.mk
@@ -196,10 +196,12 @@ TARGET_AR:=$(TARGET_CROSS)ar
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(TARGET_CROSS)g++
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed
+SED:=$(SED_PLAIN) -i -e
CP:=cp -fpR
LN:=ln -sf
XARGS:=xargs -r
+OPENSSL:=openssl

INSTALL_BIN:=install -m0755
INSTALL_DIR:=install -d -m0755
diff --git a/include/baseconf.mk b/include/baseconf.mk
new file mode 100644
index 0000000..ad8db58
--- /dev/null
+++ b/include/baseconf.mk
@@ -0,0 +1,6 @@
+
+PKG_CONFIG_DEPENDS += \
+ CONFIG_BASECONF_ROOT_PASSWORD
+
+BASECONF_ROOT_PASSWORD:=$(call qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)


Cheers,
Ben
Ben
2014-06-02 07:24:08 UTC
Permalink
Hi everybody,

to deploy minimal OpenWrt images on multiple routers it is necessary to
set a root password, while building the deployable file.

Therefore i added a patch that is setting a "default" password in the
"/etc/shadow" file of the "base-files" package. It is using the openssl
command of the building host to create the hash of the password.

Here are the diff files for both the current development branch (Barrier
Braker) and the 12.09 branch..please add the patches to both branches,
to be able to use it in the currently stable release as well.


*12.09-branch (http://git.openwrt.org/?p=12.09/openwrt.git;a=summary):*

Signed-off-by: Benjamin Pflueg <***@bensbox.de>
---
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 2152edd..db72656 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -9,6 +9,7 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk
+include $(INCLUDE_DIR)/baseconf.mk

PKG_NAME:=base-files
PKG_RELEASE:=118.2
@@ -113,6 +114,11 @@ define Package/base-files/install
$(1)/etc/openwrt_version \
$(1)/etc/openwrt_release

+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \
+ $(SED) 's/%P/x/g' $(1)/etc/shadow, \
+ $(SED) 's/%P/$(shell $(OPENSSL) passwd -1
$(BASECONF_ROOT_PASSWORD) | $(SED_PLAIN) -e 's/[/.$$^]/\\&/g' |
$(SED_PLAIN) -e 's/\$$/\$$\$$/g')/' $(1)/etc/shadow \
+ )
+
mkdir -p $(1)/CONTROL
mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs
diff --git a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow
index e989890..f35be79 100644
--- a/package/base-files/files/etc/shadow
+++ b/package/base-files/files/etc/shadow
@@ -1,4 +1,4 @@
-root:x:0:0:99999:7:::
+root:%P:0:0:99999:7:::
daemon:*:0:0:99999:7:::
ftp:*:0:0:99999:7:::
network:*:0:0:99999:7:::
diff --git a/package/base-files/image-config.in
b/package/base-files/image-config.in
index 1371356..79dee49 100644
--- a/package/base-files/image-config.in
+++ b/package/base-files/image-config.in
@@ -184,3 +184,19 @@ menuconfig VERSIONOPT
%d .. Distribution name or "openwrt", lowercase
%T .. Target name
%S .. Target/Subtarget name
+
+menuconfig BASECONFOPT
+ bool "Base system configurations" if IMAGEOPT
+ default n
+ help
+ In here you can set configurations like a default root
password.
+ They are suppose to be very basic and default settings
to the
+ vanilla OpenWRT firmware.
+
+ config BASECONF_ROOT_PASSWORD
+ string
+ prompt "Custom default root password" if BASECONFOPT
+ help
+ Usually the firmware does not have the root
password set.
+ Here you can set a default one, that will be in
effect
+ even after a factory reset.
diff --git a/rules.mk b/rules.mk
index e657eec..8c5d2c2 100644
--- a/rules.mk
+++ b/rules.mk
@@ -182,9 +182,11 @@ TARGET_AR:=$(TARGET_CROSS)ar
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(if $(CONFIG_INSTALL_LIBSTDCPP),$(TARGET_CROSS)g++,no)
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed
+SED:=$(SED_PLAIN) -i -e
CP:=cp -fpR
LN:=ln -sf
+OPENSSL:=openssl

INSTALL_BIN:=install -m0755
INSTALL_DIR:=install -d -m0755
diff --git a/include/baseconf.mk b/include/baseconf.mk
new file mode 100644
index 0000000..ad8db58
--- /dev/null
+++ b/include/baseconf.mk
@@ -0,0 +1,6 @@
+
+PKG_CONFIG_DEPENDS += \
+ CONFIG_BASECONF_ROOT_PASSWORD
+
+BASECONF_ROOT_PASSWORD:=$(call qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)
Ben
2014-06-02 07:26:00 UTC
Permalink
Hi everybody,

to deploy minimal OpenWrt images on multiple routers it is necessary to
set a root password, while building the deployable file.

Therefore i added a patch that is setting a "default" password in the
"/etc/shadow" file of the "base-files" package. It is using the openssl
command of the building host to create the hash of the password.

Here are the diff files for both the current development branch (Barrier
Braker) and the 12.09 branch..please add the patches to both branches,
to be able to use it in the currently stable release as well.


*devel-branch (http://git.openwrt.org/?p=openwrt.git;a=summary):*

Signed-off-by: Benjamin Pflueg <***@bensbox.de>
---
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 207af35..494047e 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -9,6 +9,7 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/version.mk
include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/baseconf.mk

PKG_NAME:=base-files
PKG_RELEASE:=152
@@ -113,6 +114,11 @@ define Package/base-files/install
$(1)/etc/openwrt_version \
$(1)/etc/openwrt_release

+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \
+ $(SED) 's/%P/x/g' $(1)/etc/shadow, \
+ $(SED) 's/%P/$(shell $(OPENSSL) passwd -1
$(BASECONF_ROOT_PASSWORD) | $(SED_PLAIN) -e 's/[/.$$^]/\\&/g' |
$(SED_PLAIN) -e 's/\$$/\$$\$$/g')/' $(1)/etc/shadow \
+ )
+
mkdir -p $(1)/CONTROL
mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs
diff --git a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow
index 4b4154f..f35be79 100644
--- a/package/base-files/files/etc/shadow
+++ b/package/base-files/files/etc/shadow
@@ -1,4 +1,4 @@
-root::0:0:99999:7:::
+root:%P:0:0:99999:7:::
daemon:*:0:0:99999:7:::
ftp:*:0:0:99999:7:::
network:*:0:0:99999:7:::
diff --git a/package/base-files/image-config.in
b/package/base-files/image-config.in
index a9eb78c..2f2e22a 100644
--- a/package/base-files/image-config.in
+++ b/package/base-files/image-config.in
@@ -221,3 +221,19 @@ menuconfig SMIMEOPT
Path to a file containing the passphrase for the signing key.
If the signing key is not encrypted and does not
require a passphrase,
this option may be left blank.
+
+menuconfig BASECONFOPT
+ bool "Base system configurations" if IMAGEOPT
+ default n
+ help
+ In here you can set configurations like a default root password.
+ They are suppose to be very basic and default settings to the
+ vanilla OpenWRT firmware.
+
+ config BASECONF_ROOT_PASSWORD
+ string
+ prompt "Custom default root password" if BASECONFOPT
+ help
+ Usually the firmware does not have the root password set.
+ Here you can set a default one, that will be in effect
+ even after a factory reset.
diff --git a/rules.mk b/rules.mk
index a84636a..ef8ef2f 100644
--- a/rules.mk
+++ b/rules.mk
@@ -196,10 +196,12 @@ TARGET_AR:=$(TARGET_CROSS)ar
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(TARGET_CROSS)g++
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed
+SED:=$(SED_PLAIN) -i -e
CP:=cp -fpR
LN:=ln -sf
XARGS:=xargs -r
+OPENSSL:=openssl

INSTALL_BIN:=install -m0755
INSTALL_DIR:=install -d -m0755
diff --git a/include/baseconf.mk b/include/baseconf.mk
new file mode 100644
index 0000000..ad8db58
--- /dev/null
+++ b/include/baseconf.mk
@@ -0,0 +1,6 @@
+
+PKG_CONFIG_DEPENDS += \
+ CONFIG_BASECONF_ROOT_PASSWORD
+
+BASECONF_ROOT_PASSWORD:=$(call qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)
John Crispin
2014-06-02 07:44:40 UTC
Permalink
what is the difference between this and the previous version of the
patch ?

John
Post by Ben
Hi everybody,
to deploy minimal OpenWrt images on multiple routers it is
necessary to set a root password, while building the deployable
file.
Therefore i added a patch that is setting a "default" password in
the "/etc/shadow" file of the "base-files" package. It is using the
openssl command of the building host to create the hash of the
password.
Here are the diff files for both the current development branch
(Barrier Braker) and the 12.09 branch..please add the patches to
both branches, to be able to use it in the currently stable release
as well.
*devel-branch (http://git.openwrt.org/?p=openwrt.git;a=summary):*
a/package/base-files/Makefile b/package/base-files/Makefile index
207af35..494047e 100644 --- a/package/base-files/Makefile +++
$(TOPDIR)/rules.mk include $(INCLUDE_DIR)/version.mk include
$(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/baseconf.mk
Package/base-files/install $(1)/etc/openwrt_version \
$(1)/etc/openwrt_release
+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \ + $(SED)
's/%P/x/g' $(1)/etc/shadow, \ + $(SED) 's/%P/$(shell
$(OPENSSL) passwd -1 $(BASECONF_ROOT_PASSWORD) | $(SED_PLAIN) -e
's/[/.$$^]/\\&/g' | $(SED_PLAIN) -e 's/\$$/\$$\$$/g')/'
$(1)/etc/shadow \ + ) + mkdir -p $(1)/CONTROL mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs diff --git
a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow index 4b4154f..f35be79
100644 --- a/package/base-files/files/etc/shadow +++
network:*:0:0:99999:7::: diff --git
a/package/base-files/image-config.in
b/package/base-files/image-config.in index a9eb78c..2f2e22a 100644
--- a/package/base-files/image-config.in +++
menuconfig SMIMEOPT Path to a file containing the passphrase for
the signing key. If the signing key is not encrypted and does not
require a passphrase, this option may be left blank. + +menuconfig
BASECONFOPT + bool "Base system configurations" if IMAGEOPT +
default n + help + In here you can set configurations
like a default root password. + They are suppose to be very
basic and default settings to the + vanilla OpenWRT
firmware. + + config BASECONF_ROOT_PASSWORD + string +
prompt "Custom default root password" if BASECONFOPT + help
+ Usually the firmware does not have the root password
set. + Here you can set a default one, that will be in
effect + even after a factory reset. diff --git
a/rules.mk b/rules.mk index a84636a..ef8ef2f 100644 --- a/rules.mk
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(TARGET_CROSS)g++
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed +SED:=$(SED_PLAIN) -i -e
CP:=cp -fpR LN:=ln -sf XARGS:=xargs -r +OPENSSL:=openssl
INSTALL_BIN:=install -m0755 INSTALL_DIR:=install -d -m0755 diff
--git a/include/baseconf.mk b/include/baseconf.mk new file mode
100644 index 0000000..ad8db58 --- /dev/null +++
CONFIG_BASECONF_ROOT_PASSWORD + +BASECONF_ROOT_PASSWORD:=$(call
qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)
_______________________________________________ openwrt-devel
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Ben
2014-06-02 08:45:15 UTC
Permalink
In case you meant my other mail from today, there are minor changes, to
make the patch run between the 12.09-branch and the current development
branch.

If you meant my mail from may, there is no difference.
In the "Send patch" guide it just said, there might be a flaw in the way
i send the patch, if i get no response. I thought it might be, because
both patches are in the same mail, so i reformatted it.

I am sorry, if i used "RESEND" in the wrong way or if i was not patient
enough in the first place.. :)

Cheers!
Post by John Crispin
what is the difference between this and the previous version of the
patch ?
John
Post by Ben
Hi everybody,
to deploy minimal OpenWrt images on multiple routers it is
necessary to set a root password, while building the deployable
file.
Therefore i added a patch that is setting a "default" password in
the "/etc/shadow" file of the "base-files" package. It is using the
openssl command of the building host to create the hash of the
password.
Here are the diff files for both the current development branch
(Barrier Braker) and the 12.09 branch..please add the patches to
both branches, to be able to use it in the currently stable release
as well.
*devel-branch (http://git.openwrt.org/?p=openwrt.git;a=summary):*
a/package/base-files/Makefile b/package/base-files/Makefile index
207af35..494047e 100644 --- a/package/base-files/Makefile +++
$(TOPDIR)/rules.mk include $(INCLUDE_DIR)/version.mk include
$(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/baseconf.mk
Package/base-files/install $(1)/etc/openwrt_version \
$(1)/etc/openwrt_release
+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \ + $(SED)
's/%P/x/g' $(1)/etc/shadow, \ + $(SED) 's/%P/$(shell
$(OPENSSL) passwd -1 $(BASECONF_ROOT_PASSWORD) | $(SED_PLAIN) -e
's/[/.$$^]/\\&/g' | $(SED_PLAIN) -e 's/\$$/\$$\$$/g')/'
$(1)/etc/shadow \ + ) + mkdir -p $(1)/CONTROL mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs diff --git
a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow index 4b4154f..f35be79
100644 --- a/package/base-files/files/etc/shadow +++
network:*:0:0:99999:7::: diff --git
a/package/base-files/image-config.in
b/package/base-files/image-config.in index a9eb78c..2f2e22a 100644
--- a/package/base-files/image-config.in +++
menuconfig SMIMEOPT Path to a file containing the passphrase for
the signing key. If the signing key is not encrypted and does not
require a passphrase, this option may be left blank. + +menuconfig
BASECONFOPT + bool "Base system configurations" if IMAGEOPT +
default n + help + In here you can set configurations
like a default root password. + They are suppose to be very
basic and default settings to the + vanilla OpenWRT
firmware. + + config BASECONF_ROOT_PASSWORD + string +
prompt "Custom default root password" if BASECONFOPT + help
+ Usually the firmware does not have the root password
set. + Here you can set a default one, that will be in
effect + even after a factory reset. diff --git
a/rules.mk b/rules.mk index a84636a..ef8ef2f 100644 --- a/rules.mk
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(TARGET_CROSS)g++
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed +SED:=$(SED_PLAIN) -i -e
CP:=cp -fpR LN:=ln -sf XARGS:=xargs -r +OPENSSL:=openssl
INSTALL_BIN:=install -m0755 INSTALL_DIR:=install -d -m0755 diff
--git a/include/baseconf.mk b/include/baseconf.mk new file mode
100644 index 0000000..ad8db58 --- /dev/null +++
CONFIG_BASECONF_ROOT_PASSWORD + +BASECONF_ROOT_PASSWORD:=$(call
qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)
_______________________________________________ openwrt-devel
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
John Crispin
2014-06-02 08:49:37 UTC
Permalink
Post by Ben
In case you meant my other mail from today, there are minor
changes, to make the patch run between the 12.09-branch and the
current development branch.
If you meant my mail from may, there is no difference. In the "Send
patch" guide it just said, there might be a flaw in the way i send
the patch, if i get no response. I thought it might be, because
both patches are in the same mail, so i reformatted it.
I am sorry, if i used "RESEND" in the wrong way or if i was not
patient enough in the first place.. :)
Cheers!
i missed the RESEND in the subject :) i made a list of patches that
need a merge and your was on it, so i just wondered if i should use
this or the other one ...

John
Post by Ben
Post by John Crispin
what is the difference between this and the previous version of
the patch ?
John
Post by Ben
Hi everybody,
to deploy minimal OpenWrt images on multiple routers it is
necessary to set a root password, while building the
deployable file.
Therefore i added a patch that is setting a "default" password
in the "/etc/shadow" file of the "base-files" package. It is
using the openssl command of the building host to create the
hash of the password.
Here are the diff files for both the current development
branch (Barrier Braker) and the 12.09 branch..please add the
patches to both branches, to be able to use it in the currently
stable release as well.
*devel-branch
(http://git.openwrt.org/?p=openwrt.git;a=summary):*
a/package/base-files/Makefile b/package/base-files/Makefile
index 207af35..494047e 100644 --- a/package/base-files/Makefile
$(TOPDIR)/rules.mk include $(INCLUDE_DIR)/version.mk include
$(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/baseconf.mk
define Package/base-files/install $(1)/etc/openwrt_version \
$(1)/etc/openwrt_release
+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \ +
$(SED) 's/%P/x/g' $(1)/etc/shadow, \ + $(SED)
's/%P/$(shell $(OPENSSL) passwd -1 $(BASECONF_ROOT_PASSWORD) |
$(SED_PLAIN) -e 's/[/.$$^]/\\&/g' | $(SED_PLAIN) -e
's/\$$/\$$\$$/g')/' $(1)/etc/shadow \ + ) + mkdir -p
$(1)/CONTROL mkdir -p $(1)/dev mkdir -p $(1)/etc/crontabs diff
--git a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow index 4b4154f..f35be79
100644 --- a/package/base-files/files/etc/shadow +++
network:*:0:0:99999:7::: diff --git
a/package/base-files/image-config.in
b/package/base-files/image-config.in index a9eb78c..2f2e22a
100644 --- a/package/base-files/image-config.in +++
menuconfig SMIMEOPT Path to a file containing the passphrase
for the signing key. If the signing key is not encrypted and
does not require a passphrase, this option may be left blank. +
+menuconfig BASECONFOPT + bool "Base system configurations"
if IMAGEOPT + default n + help + In here you can set
configurations like a default root password. + They are
suppose to be very basic and default settings to the +
vanilla OpenWRT firmware. + + config BASECONF_ROOT_PASSWORD
+ string + prompt "Custom default root password" if
BASECONFOPT + help + Usually the firmware
does not have the root password set. + Here you can
set a default one, that will be in effect + even
after a factory reset. diff --git a/rules.mk b/rules.mk index
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(TARGET_CROSS)g++
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed +SED:=$(SED_PLAIN) -i
-e CP:=cp -fpR LN:=ln -sf XARGS:=xargs -r +OPENSSL:=openssl
INSTALL_BIN:=install -m0755 INSTALL_DIR:=install -d -m0755
diff --git a/include/baseconf.mk b/include/baseconf.mk new file
mode 100644 index 0000000..ad8db58 --- /dev/null +++
\ + CONFIG_BASECONF_ROOT_PASSWORD +
+BASECONF_ROOT_PASSWORD:=$(call
qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)
_______________________________________________ openwrt-devel
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
Post by Ben
Post by John Crispin
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________ openwrt-devel
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Ben
2014-06-02 08:54:48 UTC
Permalink
If you took the patch from my first mail, you can leave it the way it is.
I just wanted to make sure, that nobody needed to dig through the mail,
to get both patches.

Thanks! :)
Post by John Crispin
Post by Ben
In case you meant my other mail from today, there are minor
changes, to make the patch run between the 12.09-branch and the
current development branch.
If you meant my mail from may, there is no difference. In the "Send
patch" guide it just said, there might be a flaw in the way i send
the patch, if i get no response. I thought it might be, because
both patches are in the same mail, so i reformatted it.
I am sorry, if i used "RESEND" in the wrong way or if i was not
patient enough in the first place.. :)
Cheers!
i missed the RESEND in the subject :) i made a list of patches that
need a merge and your was on it, so i just wondered if i should use
this or the other one ...
John
Post by Ben
Post by John Crispin
what is the difference between this and the previous version of
the patch ?
John
Post by Ben
Hi everybody,
to deploy minimal OpenWrt images on multiple routers it is
necessary to set a root password, while building the
deployable file.
Therefore i added a patch that is setting a "default" password
in the "/etc/shadow" file of the "base-files" package. It is
using the openssl command of the building host to create the
hash of the password.
Here are the diff files for both the current development
branch (Barrier Braker) and the 12.09 branch..please add the
patches to both branches, to be able to use it in the currently
stable release as well.
*devel-branch
(http://git.openwrt.org/?p=openwrt.git;a=summary):*
a/package/base-files/Makefile b/package/base-files/Makefile
index 207af35..494047e 100644 --- a/package/base-files/Makefile
$(TOPDIR)/rules.mk include $(INCLUDE_DIR)/version.mk include
$(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/baseconf.mk
define Package/base-files/install $(1)/etc/openwrt_version \
$(1)/etc/openwrt_release
+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \ +
$(SED) 's/%P/x/g' $(1)/etc/shadow, \ + $(SED)
's/%P/$(shell $(OPENSSL) passwd -1 $(BASECONF_ROOT_PASSWORD) |
$(SED_PLAIN) -e 's/[/.$$^]/\\&/g' | $(SED_PLAIN) -e
's/\$$/\$$\$$/g')/' $(1)/etc/shadow \ + ) + mkdir -p
$(1)/CONTROL mkdir -p $(1)/dev mkdir -p $(1)/etc/crontabs diff
--git a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow index 4b4154f..f35be79
100644 --- a/package/base-files/files/etc/shadow +++
network:*:0:0:99999:7::: diff --git
a/package/base-files/image-config.in
b/package/base-files/image-config.in index a9eb78c..2f2e22a
100644 --- a/package/base-files/image-config.in +++
menuconfig SMIMEOPT Path to a file containing the passphrase
for the signing key. If the signing key is not encrypted and
does not require a passphrase, this option may be left blank. +
+menuconfig BASECONFOPT + bool "Base system configurations"
if IMAGEOPT + default n + help + In here you can set
configurations like a default root password. + They are
suppose to be very basic and default settings to the +
vanilla OpenWRT firmware. + + config BASECONF_ROOT_PASSWORD
+ string + prompt "Custom default root password" if
BASECONFOPT + help + Usually the firmware
does not have the root password set. + Here you can
set a default one, that will be in effect + even
after a factory reset. diff --git a/rules.mk b/rules.mk index
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(TARGET_CROSS)g++
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed +SED:=$(SED_PLAIN) -i
-e CP:=cp -fpR LN:=ln -sf XARGS:=xargs -r +OPENSSL:=openssl
INSTALL_BIN:=install -m0755 INSTALL_DIR:=install -d -m0755
diff --git a/include/baseconf.mk b/include/baseconf.mk new file
mode 100644 index 0000000..ad8db58 --- /dev/null +++
\ + CONFIG_BASECONF_ROOT_PASSWORD +
+BASECONF_ROOT_PASSWORD:=$(call
qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)
_______________________________________________ openwrt-devel
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
Post by Ben
Post by John Crispin
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________ openwrt-devel
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Ben
2014-07-14 09:23:45 UTC
Permalink
Hi all,

since i didn't hear anything about this in the last 6 weeks i like to
ask, if there are any problems/concerns to add this?
I would be more than happy to help :)

Thanks alot and have a nice week!
Ben
Post by Ben
Hi everybody,
to deploy minimal OpenWrt images on multiple routers it is necessary
to set a root password, while building the deployable file.
Therefore i added a patch that is setting a "default" password in the
"/etc/shadow" file of the "base-files" package. It is using the
openssl command of the building host to create the hash of the password.
Here are the diff files for both the current development branch
(Barrier Braker) and the 12.09 branch..please add the patches to both
branches, to be able to use it in the currently stable release as well.
*devel-branch (http://git.openwrt.org/?p=openwrt.git;a=summary):*
---
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 207af35..494047e 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -9,6 +9,7 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/version.mk
include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/baseconf.mk
PKG_NAME:=base-files
PKG_RELEASE:=152
@@ -113,6 +114,11 @@ define Package/base-files/install
$(1)/etc/openwrt_version \
$(1)/etc/openwrt_release
+ $(if $(filter $(BASECONF_ROOT_PASSWORD),x), \
+ $(SED) 's/%P/x/g' $(1)/etc/shadow, \
+ $(SED) 's/%P/$(shell $(OPENSSL) passwd -1
$(BASECONF_ROOT_PASSWORD) | $(SED_PLAIN) -e 's/[/.$$^]/\\&/g' |
$(SED_PLAIN) -e 's/\$$/\$$\$$/g')/' $(1)/etc/shadow \
+ )
+
mkdir -p $(1)/CONTROL
mkdir -p $(1)/dev
mkdir -p $(1)/etc/crontabs
diff --git a/package/base-files/files/etc/shadow
b/package/base-files/files/etc/shadow
index 4b4154f..f35be79 100644
--- a/package/base-files/files/etc/shadow
+++ b/package/base-files/files/etc/shadow
@@ -1,4 +1,4 @@
diff --git a/package/base-files/image-config.in
b/package/base-files/image-config.in
index a9eb78c..2f2e22a 100644
--- a/package/base-files/image-config.in
+++ b/package/base-files/image-config.in
@@ -221,3 +221,19 @@ menuconfig SMIMEOPT
Path to a file containing the passphrase for the signing key.
If the signing key is not encrypted and does not
require a passphrase,
this option may be left blank.
+
+menuconfig BASECONFOPT
+ bool "Base system configurations" if IMAGEOPT
+ default n
+ help
+ In here you can set configurations like a default root password.
+ They are suppose to be very basic and default settings to the
+ vanilla OpenWRT firmware.
+
+ config BASECONF_ROOT_PASSWORD
+ string
+ prompt "Custom default root password" if BASECONFOPT
+ help
+ Usually the firmware does not have the root password set.
+ Here you can set a default one, that will be in effect
+ even after a factory reset.
diff --git a/rules.mk b/rules.mk
index a84636a..ef8ef2f 100644
--- a/rules.mk
+++ b/rules.mk
@@ -196,10 +196,12 @@ TARGET_AR:=$(TARGET_CROSS)ar
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_CXX:=$(TARGET_CROSS)g++
KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+SED_PLAIN:=$(STAGING_DIR_HOST)/bin/sed
+SED:=$(SED_PLAIN) -i -e
CP:=cp -fpR
LN:=ln -sf
XARGS:=xargs -r
+OPENSSL:=openssl
INSTALL_BIN:=install -m0755
INSTALL_DIR:=install -d -m0755
diff --git a/include/baseconf.mk b/include/baseconf.mk
new file mode 100644
index 0000000..ad8db58
--- /dev/null
+++ b/include/baseconf.mk
@@ -0,0 +1,6 @@
+
+PKG_CONFIG_DEPENDS += \
+ CONFIG_BASECONF_ROOT_PASSWORD
+
+BASECONF_ROOT_PASSWORD:=$(call qstrip,$(CONFIG_BASECONF_ROOT_PASSWORD))
+BASECONF_ROOT_PASSWORD:=$(if
$(BASECONF_ROOT_PASSWORD),$(BASECONF_ROOT_PASSWORD),x)
_______________________________________________
openwrt-devel mailing list
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Loading...