* [PATCH v2 0/6] Various fixes and improvements to initscripts
@ 2014-07-17 21:56 Ben Shelton
2014-07-17 21:56 ` [PATCH v2 1/6] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE Ben Shelton
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Ben Shelton @ 2014-07-17 21:56 UTC (permalink / raw)
To: openembedded-core
This patch series contains fixes and improvements we've made to several init
scripts. These changes have been thoroughly tested on Dylan and ported to
master.
Changes made in v2:
- Updated /etc/timestamp generated at build time to use seconds accuracy
- Added a patch I missed the first time to source /etc/default/urandom
from /etc/init.d/urandom
The following changes since commit a449598a839e677e2a094aa4bd9a68003de6e42e:
bdwgc: Add PACKAGECONFIG for libatomic-ops (2014-07-17 15:04:07 +0100)
are available in the git repository at:
git://github.com/ni/openembedded-core dev/bshelton/upstream_initscripts
https://github.com/ni/openembedded-core/tree/dev/bshelton/upstream_initscripts
Blair Elliott (1):
initscripts: save /etc/timestamp with seconds accuracy
Ken Sharp (1):
initscripts: Use current date as an additional source of entropy
Richard Tollerton (4):
initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE
initscripts: parametrize random seed file location
initscripts: make hostname.sh coreutils-compatible
initscripts: Add support for /etc/default/urandom
meta/classes/image.bbclass | 2 +-
.../initscripts/initscripts-1.0/bootmisc.sh | 12 +++++++++---
.../initscripts/initscripts-1.0/hostname.sh | 2 +-
.../initscripts/initscripts-1.0/save-rtc.sh | 2 +-
.../initscripts/initscripts-1.0/urandom | 21 ++++++++++++---------
5 files changed, 24 insertions(+), 15 deletions(-)
--
2.0.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/6] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE
2014-07-17 21:56 [PATCH v2 0/6] Various fixes and improvements to initscripts Ben Shelton
@ 2014-07-17 21:56 ` Ben Shelton
2014-07-17 21:56 ` [PATCH v2 2/6] initscripts: save /etc/timestamp with seconds accuracy Ben Shelton
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Ben Shelton @ 2014-07-17 21:56 UTC (permalink / raw)
To: openembedded-core
From: Richard Tollerton <rich.tollerton@ni.com>
busybox sysctl may lack the "-q" setting, so simulate it with redirects.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 3b5a47f..5211824 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -36,7 +36,12 @@ if [ -f "${SYSCTL_CONF}" ]
then
if [ -x "/sbin/sysctl" ]
then
- /sbin/sysctl -p "${SYSCTL_CONF}"
+ # busybox sysctl does not support -q
+ VERBOSE_REDIR="1>/dev/null"
+ if [ "${VERBOSE}" != "no" ]; then
+ VERBOSE_REDIR="1>&1"
+ fi
+ eval /sbin/sysctl -p "${SYSCTL_CONF}" $VERBOSE_REDIR
else
echo "To have ${SYSCTL_CONF} applied during boot, install package <procps>."
fi
--
2.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/6] initscripts: save /etc/timestamp with seconds accuracy
2014-07-17 21:56 [PATCH v2 0/6] Various fixes and improvements to initscripts Ben Shelton
2014-07-17 21:56 ` [PATCH v2 1/6] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE Ben Shelton
@ 2014-07-17 21:56 ` Ben Shelton
2014-07-20 22:56 ` Richard Purdie
2014-07-17 21:56 ` [PATCH v2 3/6] initscripts: parametrize random seed file location Ben Shelton
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Ben Shelton @ 2014-07-17 21:56 UTC (permalink / raw)
To: openembedded-core
From: Blair Elliott <blair.elliott@ni.com>
Currently, /etc/timestamp is saved with minutes accuracy. To increase
the accuracy, modify the save-rtc.sh and bootmisc.sh scripts to save and
read /etc/timestamp respectively with seconds accuracy.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/classes/image.bbclass | 2 +-
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 5 +++--
meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index a03b880..772c3ed 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -359,7 +359,7 @@ set_image_autologin () {
# Can be use to create /etc/timestamp during image construction to give a reasonably
# sane default time setting
rootfs_update_timestamp () {
- date -u +%4Y%2m%2d%2H%2M >${IMAGE_ROOTFS}/etc/timestamp
+ date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
}
# Prevent X from being started
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 5211824..ccc7f9f 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -66,10 +66,11 @@ fi
test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
if test -e /etc/timestamp
then
- SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M`
+ SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`
read TIMESTAMP < /etc/timestamp
if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
- date -u ${TIMESTAMP#????}${TIMESTAMP%????????}
+ # format the timestamp as date expects it (2m2d2H2M4Y.2S)
+ date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
fi
fi
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh b/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
index 1f804e2..b038fc5 100644
--- a/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
@@ -10,4 +10,4 @@
### END INIT INFO
# Update the timestamp
-date -u +%4Y%2m%2d%2H%2M > /etc/timestamp
+date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp
--
2.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/6] initscripts: parametrize random seed file location
2014-07-17 21:56 [PATCH v2 0/6] Various fixes and improvements to initscripts Ben Shelton
2014-07-17 21:56 ` [PATCH v2 1/6] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE Ben Shelton
2014-07-17 21:56 ` [PATCH v2 2/6] initscripts: save /etc/timestamp with seconds accuracy Ben Shelton
@ 2014-07-17 21:56 ` Ben Shelton
2014-07-17 21:56 ` [PATCH v2 4/6] initscripts: Use current date as an additional source of entropy Ben Shelton
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Ben Shelton @ 2014-07-17 21:56 UTC (permalink / raw)
To: openembedded-core
From: Richard Tollerton <rich.tollerton@ni.com>
Currently, the random seed file location is hardcoded to
/var/lib/urandom/random-seed. Refactor it to a parameter
(RANDOM_SEED_FILE) so the file location is defined in only one place.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/urandom | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/urandom b/meta/recipes-core/initscripts/initscripts-1.0/urandom
index eb3a7c3..a0549de 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/urandom
+++ b/meta/recipes-core/initscripts/initscripts-1.0/urandom
@@ -12,6 +12,9 @@
### END INIT INFO
test -c /dev/urandom || exit 0
+
+RANDOM_SEED_FILE=/var/lib/urandom/random-seed
+
. /etc/default/rcS
case "$1" in
@@ -19,13 +22,13 @@ case "$1" in
test "$VERBOSE" != no && echo "Initializing random number generator..."
# Load and then save 512 bytes,
# which is the size of the entropy pool
- if test -f /var/lib/urandom/random-seed
+ if test -f "$RANDOM_SEED_FILE"
then
- cat /var/lib/urandom/random-seed >/dev/urandom
+ cat "$RANDOM_SEED_FILE" >/dev/urandom
fi
- rm -f /var/lib/urandom/random-seed
+ rm -f "$RANDOM_SEED_FILE"
umask 077
- dd if=/dev/urandom of=/var/lib/urandom/random-seed count=1 \
+ dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
>/dev/null 2>&1 || echo "urandom start: failed."
umask 022
;;
@@ -34,7 +37,7 @@ case "$1" in
# see documentation in linux/drivers/char/random.c
test "$VERBOSE" != no && echo "Saving random seed..."
umask 077
- dd if=/dev/urandom of=/var/lib/urandom/random-seed count=1 \
+ dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
>/dev/null 2>&1 || echo "urandom stop: failed."
;;
*)
--
2.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/6] initscripts: Use current date as an additional source of entropy
2014-07-17 21:56 [PATCH v2 0/6] Various fixes and improvements to initscripts Ben Shelton
` (2 preceding siblings ...)
2014-07-17 21:56 ` [PATCH v2 3/6] initscripts: parametrize random seed file location Ben Shelton
@ 2014-07-17 21:56 ` Ben Shelton
2014-07-17 21:56 ` [PATCH v2 5/6] initscripts: make hostname.sh coreutils-compatible Ben Shelton
2014-07-17 21:56 ` [PATCH v2 6/6] initscripts: Add support for /etc/default/urandom Ben Shelton
5 siblings, 0 replies; 8+ messages in thread
From: Ben Shelton @ 2014-07-17 21:56 UTC (permalink / raw)
To: openembedded-core
From: Ken Sharp <ken.sharp@ni.com>
If the seed file is empty or does not exist, the date is an extremely
poor backup source of entropy, but it is better than nothing.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/urandom | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/urandom b/meta/recipes-core/initscripts/initscripts-1.0/urandom
index a0549de..ec4ef61 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/urandom
+++ b/meta/recipes-core/initscripts/initscripts-1.0/urandom
@@ -20,12 +20,11 @@ RANDOM_SEED_FILE=/var/lib/urandom/random-seed
case "$1" in
start|"")
test "$VERBOSE" != no && echo "Initializing random number generator..."
- # Load and then save 512 bytes,
- # which is the size of the entropy pool
- if test -f "$RANDOM_SEED_FILE"
- then
- cat "$RANDOM_SEED_FILE" >/dev/urandom
- fi
+ # Load and then save 512 bytes, which is the size of the entropy
+ # pool. Also load the current date, in case the seed file is
+ # empty.
+ ( date +%s.%N; [ -f "$RANDOM_SEED_FILE" ] && cat "$RANDOM_SEED_FILE" ) \
+ >/dev/urandom
rm -f "$RANDOM_SEED_FILE"
umask 077
dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
--
2.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/6] initscripts: make hostname.sh coreutils-compatible
2014-07-17 21:56 [PATCH v2 0/6] Various fixes and improvements to initscripts Ben Shelton
` (3 preceding siblings ...)
2014-07-17 21:56 ` [PATCH v2 4/6] initscripts: Use current date as an additional source of entropy Ben Shelton
@ 2014-07-17 21:56 ` Ben Shelton
2014-07-17 21:56 ` [PATCH v2 6/6] initscripts: Add support for /etc/default/urandom Ben Shelton
5 siblings, 0 replies; 8+ messages in thread
From: Ben Shelton @ 2014-07-17 21:56 UTC (permalink / raw)
To: openembedded-core
From: Richard Tollerton <rich.tollerton@ni.com>
inetutils and busybox hostname utils support `hostname -F`; coreutils
hostname doesn't. So just use `cat` instead.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/hostname.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh b/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh
index 78fb91c..95287cc 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh
@@ -16,7 +16,7 @@ fi
# Busybox hostname doesn't support -b so we need implement it on our own
if [ -f /etc/hostname ];then
- hostname -F /etc/hostname
+ hostname `cat /etc/hostname`
elif [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" -o ! -z "`echo $HOSTNAME | sed -n '/^[0-9]*\.[0-9].*/p'`" ] ; then
hostname localhost
fi
--
2.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 6/6] initscripts: Add support for /etc/default/urandom
2014-07-17 21:56 [PATCH v2 0/6] Various fixes and improvements to initscripts Ben Shelton
` (4 preceding siblings ...)
2014-07-17 21:56 ` [PATCH v2 5/6] initscripts: make hostname.sh coreutils-compatible Ben Shelton
@ 2014-07-17 21:56 ` Ben Shelton
5 siblings, 0 replies; 8+ messages in thread
From: Ben Shelton @ 2014-07-17 21:56 UTC (permalink / raw)
To: openembedded-core
From: Richard Tollerton <rich.tollerton@ni.com>
Source /etc/default/urandom if present. This allows the rootfs to
remain read-only while enabling the user to override the location of the
random seed file.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/urandom | 1 +
1 file changed, 1 insertion(+)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/urandom b/meta/recipes-core/initscripts/initscripts-1.0/urandom
index ec4ef61..af1625b 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/urandom
+++ b/meta/recipes-core/initscripts/initscripts-1.0/urandom
@@ -16,6 +16,7 @@ test -c /dev/urandom || exit 0
RANDOM_SEED_FILE=/var/lib/urandom/random-seed
. /etc/default/rcS
+[ -f /etc/default/urandom ] && . /etc/default/urandom
case "$1" in
start|"")
--
2.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/6] initscripts: save /etc/timestamp with seconds accuracy
2014-07-17 21:56 ` [PATCH v2 2/6] initscripts: save /etc/timestamp with seconds accuracy Ben Shelton
@ 2014-07-20 22:56 ` Richard Purdie
0 siblings, 0 replies; 8+ messages in thread
From: Richard Purdie @ 2014-07-20 22:56 UTC (permalink / raw)
To: Ben Shelton; +Cc: openembedded-core
On Thu, 2014-07-17 at 16:56 -0500, Ben Shelton wrote:
> From: Blair Elliott <blair.elliott@ni.com>
>
> Currently, /etc/timestamp is saved with minutes accuracy. To increase
> the accuracy, modify the save-rtc.sh and bootmisc.sh scripts to save and
> read /etc/timestamp respectively with seconds accuracy.
>
> Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
> Signed-off-by: Ben Shelton <ben.shelton@ni.com>
> ---
> meta/classes/image.bbclass | 2 +-
> meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 5 +++--
> meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh | 2 +-
> 3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index a03b880..772c3ed 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -359,7 +359,7 @@ set_image_autologin () {
> # Can be use to create /etc/timestamp during image construction to give a reasonably
> # sane default time setting
> rootfs_update_timestamp () {
> - date -u +%4Y%2m%2d%2H%2M >${IMAGE_ROOTFS}/etc/timestamp
> + date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
> }
>
> # Prevent X from being started
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 5211824..ccc7f9f 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -66,10 +66,11 @@ fi
> test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
> if test -e /etc/timestamp
> then
> - SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M`
> + SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`
> read TIMESTAMP < /etc/timestamp
> if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
> - date -u ${TIMESTAMP#????}${TIMESTAMP%????????}
> + # format the timestamp as date expects it (2m2d2H2M4Y.2S)
> + date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
> test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
> fi
> fi
The syntax above doesn't appear to work with busybox:
/etc/init.d/rc: /etc/rcS.d/S55bootmisc.sh: line 73: syntax error: bad substitution
:(
Cheers,
Richard
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-07-20 22:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-17 21:56 [PATCH v2 0/6] Various fixes and improvements to initscripts Ben Shelton
2014-07-17 21:56 ` [PATCH v2 1/6] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE Ben Shelton
2014-07-17 21:56 ` [PATCH v2 2/6] initscripts: save /etc/timestamp with seconds accuracy Ben Shelton
2014-07-20 22:56 ` Richard Purdie
2014-07-17 21:56 ` [PATCH v2 3/6] initscripts: parametrize random seed file location Ben Shelton
2014-07-17 21:56 ` [PATCH v2 4/6] initscripts: Use current date as an additional source of entropy Ben Shelton
2014-07-17 21:56 ` [PATCH v2 5/6] initscripts: make hostname.sh coreutils-compatible Ben Shelton
2014-07-17 21:56 ` [PATCH v2 6/6] initscripts: Add support for /etc/default/urandom Ben Shelton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.