mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH 0/2] improve type design in the login banner
@ 2017-11-30 23:31 Roland Hieber
  2017-11-30 23:31 ` [ptxdist] [PATCH 1/2] install_replace_figlet: allow escaping the figlet output Roland Hieber
  2017-11-30 23:31 ` [ptxdist] [PATCH 2/2] rootfs: correctly escape /etc/issue figlets Roland Hieber
  0 siblings, 2 replies; 3+ messages in thread
From: Roland Hieber @ 2017-11-30 23:31 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

Every time I look at the login prompt, the banner looks a bit off. It's
not much, but it's enough for me to notice and sigh internally at the
unroundness and leakiness of the letters, and I find the letters a bit
hard to parse.

The reason for this appearance is that backslashes in the banner output
are replaced by backticks when it is written to /etc/issue, probably as
a quick-fix to avoid variable expansion by getty.

This patch series brings the login banner back to its usual appearance.
Judge for yourself:

Before:
     ____                        _                   _
    |  _ ` ___ _ __   __ _ _   _| |_ _ __ ___  _ __ (_)_  __
    | |_) / _ ` '_ ` / _` | | | | __| '__/ _ `| '_ `| ` `/ /
    |  __/  __/ | | | (_| | |_| | |_| | | (_) | | | | |>  <
    |_|   `___|_| |_|`__, |`__,_|`__|_|  `___/|_| |_|_/_/`_`
                     |___/
     ____  _     _             _  ___ _
    |  _ `(_)___| |_ _ __ ___ | |/ (_) |_
    | | | | / __| __| '__/ _ `| ' /| | __|
    | |_| | `__ ` |_| | | (_) | . `| | |_
    |____/|_|___/`__|_|  `___/|_|`_`_|`__|

After:
     ____                        _                   _
    |  _ \ ___ _ __   __ _ _   _| |_ _ __ ___  _ __ (_)_  __
    | |_) / _ \ '_ \ / _` | | | | __| '__/ _ \| '_ \| \ \/ /
    |  __/  __/ | | | (_| | |_| | |_| | | (_) | | | | |>  <
    |_|   \___|_| |_|\__, |\__,_|\__|_|  \___/|_| |_|_/_/\_\
                     |___/
     ____  _     _             _  ___ _
    |  _ \(_)___| |_ _ __ ___ | |/ (_) |_
    | | | | / __| __| '__/ _ \| ' /| | __|
    | |_| | \__ \ |_| | | (_) | . \| | |_
    |____/|_|___/\__|_|  \___/|_|\_\_|\__|


Roland Hieber (2):
  install_replace_figlet: allow escaping the figlet output
  rootfs: correctly escape /etc/issue figlets

 rules/post/install.make           |  4 +++-
 rules/rootfs.make                 |  6 ++++--
 scripts/lib/ptxd_make_xpkg_pkg.sh | 20 ++++++++++++++++++--
 3 files changed, 25 insertions(+), 5 deletions(-)

-- 
2.15.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ptxdist] [PATCH 1/2] install_replace_figlet: allow escaping the figlet output
  2017-11-30 23:31 [ptxdist] [PATCH 0/2] improve type design in the login banner Roland Hieber
@ 2017-11-30 23:31 ` Roland Hieber
  2017-11-30 23:31 ` [ptxdist] [PATCH 2/2] rootfs: correctly escape /etc/issue figlets Roland Hieber
  1 sibling, 0 replies; 3+ messages in thread
From: Roland Hieber @ 2017-11-30 23:31 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

All known gettys in PTXdist allow inserting variables into /etc/issue by
prefixing certain characters with backslashes (e.g. a literal '\v'
expands to the kernel version from uname -v). In this case, '\'s in the
figlet output must be escaped accordingly so they are displayed as '\'s
on the screen.

For readability, refactor the code into a new local function. Then
add a new parameter describing the escape mode ('etcissue' or none, the
default) as a new, fifth parameter to install_replace_figlet. Currently,
install_replace_figlet is only used in rootfs.make on /etc/issue, and
the chance that we break existing code with the new default should be
small.

Signed-off-by: Roland Hieber <rohieb@rohieb.name>
---
 rules/post/install.make           |  4 +++-
 scripts/lib/ptxd_make_xpkg_pkg.sh | 20 ++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/rules/post/install.make b/rules/post/install.make
index c40e36eb6..c0e24569e 100644
--- a/rules/post/install.make
+++ b/rules/post/install.make
@@ -301,14 +301,16 @@ install_replace = \
 # $2: filename
 # $3: placeholder
 # $4: value
+# $5: escape mode (empty or 'etcissue')
 #
 install_replace_figlet = \
 	XPKG=$(subst _,-,$(strip $(1)));							\
 	FILE=$(strip $(2));									\
 	PLACEHOLDER=$(strip $(3));								\
 	VALUE=$(strip $(4));									\
+	ESCAPEMODE=$(strip $(5));									\
 	$(call install_check, install_replace);							\
-	echo "ptxd_install_replace_figlet '$$FILE' '$$PLACEHOLDER' '$$VALUE'" >> "$(STATEDIR)/$$XPKG.cmds"
+	echo "ptxd_install_replace_figlet '$$FILE' '$$PLACEHOLDER' '$$VALUE' '$$ESCAPEMODE'" >> "$(STATEDIR)/$$XPKG.cmds"
 
 #
 # install_script_replace
diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
index 4efc31630..eb3452e3a 100644
--- a/scripts/lib/ptxd_make_xpkg_pkg.sh
+++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
@@ -567,6 +567,7 @@ ptxd_install_replace_figlet() {
     local dst="$1"
     local placeholder="$2"
     local value="$3"
+    local escapemode="$4"
     local -a dirs ndirs pdirs sdirs ddirs
     local mod_nfs mod_rw
 
@@ -578,8 +579,23 @@ install replace figlet:
 " &&
 
     ptxd_exist "${dirs[@]/%/${dst}}" &&
-    figlet="$(figlet -d "${PTXDIST_SYSROOT_HOST}/share/figlet" -- "${value}" | \
-	awk '{ gsub("\\\\", "`"); if ($0 !~ "^ *$") printf("%s\\n", $0) }')" && #`
+    ptxd_figlet_helper() {
+        local value="$1"
+        local escapemode="$2"
+        figlet -d "${PTXDIST_SYSROOT_HOST}/share/figlet" -- "${value}" | \
+        case "$escapemode" in
+            # a lot of leaning toothpicks because we need to escape a literal
+            # '\' with '\\' on multiple levels:
+            # - one level for the string inside awk: \\\\\\\\\\\\\\\\ -> \\\\\\\\
+            # - one level for the shell string after sed -e:          -> \\\\
+            # - one level for the s expression inside sed:            -> \\
+            # - and finally, one level for /etc/issue:                -> \
+            etcissue)	awk '{ gsub("\\\\", "\\\\\\\\\\\\\\\\"); print }' ;;
+            *)		;;
+        esac | \
+        awk '{ if ($0 !~ "^ *$") printf("%s\\n", $0) }'  # newlines for sed
+    } &&
+    figlet="$(ptxd_figlet_helper "$value" "$escapemode")" &&
     sed -i -e "s#${placeholder}#${figlet}#g" "${dirs[@]/%/${dst}}" ||
 
     ptxd_install_error "install_replace failed!"
-- 
2.15.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ptxdist] [PATCH 2/2] rootfs: correctly escape /etc/issue figlets
  2017-11-30 23:31 [ptxdist] [PATCH 0/2] improve type design in the login banner Roland Hieber
  2017-11-30 23:31 ` [ptxdist] [PATCH 1/2] install_replace_figlet: allow escaping the figlet output Roland Hieber
@ 2017-11-30 23:31 ` Roland Hieber
  1 sibling, 0 replies; 3+ messages in thread
From: Roland Hieber @ 2017-11-30 23:31 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

Use install_replace_figlet's newly introduced 'getty' escape mode to
escape '\' with '\\' and prevent any possible variable interpolation
when /etc/issue is displayed by getty.

Signed-off-by: Roland Hieber <rohieb@rohieb.name>
---
 rules/rootfs.make | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/rules/rootfs.make b/rules/rootfs.make
index 81d4cd93a..ef5bba7df 100644
--- a/rules/rootfs.make
+++ b/rules/rootfs.make
@@ -194,10 +194,12 @@ ifdef PTXCONF_ROOTFS_ISSUE
 		$(call remove_quotes,$(PTXCONF_ROOTFS_ETC_HOSTNAME)))
 	@$(call install_replace_figlet, rootfs, /etc/issue, \
 		@FIGLET:VENDOR@, \
-		`sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_PROJECT_VENDOR)`)
+		`sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_PROJECT_VENDOR)`, \
+		etcissue)
 	@$(call install_replace_figlet, rootfs, /etc/issue, \
 		@FIGLET:HOSTNAME@, \
-		`sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_ROOTFS_ETC_HOSTNAME)`)
+		`sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_ROOTFS_ETC_HOSTNAME)`, \
+		etcissue)
 endif
 
 ifdef PTXCONF_ROOTFS_HOSTS
-- 
2.15.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-30 23:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-30 23:31 [ptxdist] [PATCH 0/2] improve type design in the login banner Roland Hieber
2017-11-30 23:31 ` [ptxdist] [PATCH 1/2] install_replace_figlet: allow escaping the figlet output Roland Hieber
2017-11-30 23:31 ` [ptxdist] [PATCH 2/2] rootfs: correctly escape /etc/issue figlets Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox