From a4b7aa61ed1e89cae05d079a44e520658323e927 Mon Sep 17 00:00:00 2001 From: Darshaka Pathirana Date: Fri, 7 May 2021 17:40:57 +0200 Subject: [PATCH 01/16] grepedit/notifyd.py: Convert to Python 3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Run the following commands: % 2to3-2.7 -w usr_bin/grepedit % isort usr_bin/grepedit % black usr_bin/grepedit In grepedit the following print statement has been split manually: + print( + "%s:%s has changed since the grep command ran- " + "not modifying this line" % key + ) And: % 2to3-2.7 -w usr_bin/notifyd.py % black usr_bin/notifyd.py % isort usr_bin/notifyd.py In notifyd.py added some ignore statements/comments (for the examples which were actually comments). The following errors/warnings were fixed manually: ❯ flake8 --max-line-length 88 usr_bin/notifyd.py usr_bin/notifyd.py:201:1: E741 ambiguous variable name 'l' usr_bin/notifyd.py:214:5: E722 do not use bare 'except' Variable 'l' has been renamed to 'listen' and the bare 'except' has been changed to catch 'OSError' as described in the socket documentation: https://docs.python.org/3/library/socket.html grepedit + notifyd.py + osd_server.py has not been functionally tested. Please test. (But this is not the scope of this change, as it had to be dropped anyway as it is missing Python 3 support. If an errors occurs, please file a bug report.) black defaults to line length 88 and flake to 79. Decided to go set --max-line-length 88 for flake8. Note that osd_server.py is just a symlink to notifyd.py. --- Makefile | 4 +- usr_bin/grepedit | 100 ++++++++++++++++++++---------------- usr_bin/notifyd.py | 145 +++++++++++++++++++++++++++++++++-------------------- 3 files changed, 150 insertions(+), 99 deletions(-) diff --git a/Makefile b/Makefile index c122c0f..bcbfe07 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ pythoncheck: ## Run pythoncheck (flakecheck, isortcheck + blackcheck) @RETURN=0 @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do @ if head -1 "$${pythonfile}" | grep -q "python"; then - @ flake8 "$${pythonfile}" || RETURN=1 + @ flake8 --max-line-length 88 "$${pythonfile}" || RETURN=1 @ isort --check "$${pythonfile}" || RETURN=1 @ black --check "$${pythonfile}" || RETURN=1 @ fi @@ -34,7 +34,7 @@ flakecheck: ## Run flake8 only @RETURN=0 @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do @ if head -1 "$${pythonfile}" | grep -q "python"; then - @ flake8 "$${pythonfile}" || RETURN=1 + @ flake8 --max-line-length 88 "$${pythonfile}" || RETURN=1 @ fi @done @exit $${RETURN} diff --git a/usr_bin/grepedit b/usr_bin/grepedit index 2d5730b..9908ff2 100755 --- a/usr_bin/grepedit +++ b/usr_bin/grepedit @@ -1,20 +1,20 @@ #!/usr/bin/python -## Copyright 2005 Drew Perttula - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. - -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. - -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Copyright 2005 Drew Perttula + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """sometimes we grep for something in a bunch of files, and then we want to make edits to the lines that were returned from the grep. It's @@ -49,9 +49,14 @@ ez_setup.py-179- for name in filenames: """ -import tempfile, sys, os, re +import os +import re +import sys +import tempfile + from sets import Set + def grep_parse(filename): """parse grep output lines in given file into a dict of (filename, lineno) : text""" @@ -59,41 +64,50 @@ def grep_parse(filename): for line in open(filename): if line == "--\n": continue - m = re.match(r"(?P.*?)(?P[-:])(?P\d+)(?P=sep)(?P.*\n)$", line) + m = re.match( + r"(?P.*?)(?P[-:])(?P\d+)(?P=sep)(?P.*\n)$", + line, + ) if m is None: - print "couldn't parse grep result line %r" % line + print("couldn't parse grep result line %r" % line) continue - filename, lineno, text = (m.group('filename'), int(m.group('lineno')), - m.group('line')) - if (filename,lineno) in parse: - raise ValueError("multiple results found for %s:%s" % - (filename, lineno)) + filename, lineno, text = ( + m.group("filename"), + int(m.group("lineno")), + m.group("line"), + ) + if (filename, lineno) in parse: + raise ValueError("multiple results found for %s:%s" % (filename, lineno)) parse[(filename, lineno)] = text return parse + options = {} passthru_args = [] for arg in sys.argv[1:]: if arg == "--sort-text": - options['sort-text'] = True + options["sort-text"] = True continue passthru_args.append(arg) tf = tempfile.NamedTemporaryFile(prefix="grepedit_") tf.close() -cmd = ("grep --with-filename --line-number --binary-files=without-match %s > %s" % - (" ".join(['"%s"' % s.replace("\\","\\\\").replace('"','\\"') - for s in passthru_args]),tf.name)) +cmd = "grep --with-filename --line-number --binary-files=without-match %s > %s" % ( + " ".join( + ['"%s"' % s.replace("\\", "\\\\").replace('"', '\\"') for s in passthru_args] + ), + tf.name, +) os.system(cmd) originals = grep_parse(tf.name) -if options.get('sort-text', False): - orig = [(v,k) for k,v in originals.items()] +if options.get("sort-text", False): + orig = [(v, k) for k, v in list(originals.items())] orig.sort() f = open(tf.name, "w") - for text, (filename,lineno) in orig: + for text, (filename, lineno) in orig: f.write("%s:%s:%s" % (filename, lineno, text)) f.close() @@ -101,25 +115,29 @@ os.system("%s %s" % (os.getenv("EDITOR"), tf.name)) corrections = grep_parse(tf.name) -files = Set([filename for filename,lineno in corrections.keys()]) +files = Set([filename for filename, lineno in list(corrections.keys())]) for orig_filename in files: (copy_fd, copy_filename) = tempfile.mkstemp( dir=os.path.dirname(orig_filename), - prefix="_%s_tmp_grepedit" % os.path.basename(orig_filename)) + prefix="_%s_tmp_grepedit" % os.path.basename(orig_filename), + ) any_changes = False - for lineno,line in enumerate(open(orig_filename)): - lineno = lineno + 1 # grep is 1-based - key = orig_filename,lineno + for lineno, line in enumerate(open(orig_filename)): + lineno = lineno + 1 # grep is 1-based + key = orig_filename, lineno if key in corrections: if line != originals[key]: - print "%s:%s has changed since the grep command ran- not modifying this line" % key - print repr(line) - print repr(originals[key]) + print( + "%s:%s has changed since the grep command ran- " + "not modifying this line" % key + ) + print(repr(line)) + print(repr(originals[key])) elif corrections[key] == line: pass else: - print "%s:%s substituting new line" % key + print("%s:%s substituting new line" % key) line = corrections[key] any_changes = True os.write(copy_fd, line) @@ -128,7 +146,5 @@ for orig_filename in files: if any_changes: os.rename(copy_filename, orig_filename) else: - print "no changes made in file %s" % orig_filename + print("no changes made in file %s" % orig_filename) os.unlink(copy_filename) - - diff --git a/usr_bin/notifyd.py b/usr_bin/notifyd.py index 312c9b0..ec50fce 100755 --- a/usr_bin/notifyd.py +++ b/usr_bin/notifyd.py @@ -29,7 +29,7 @@ host = "127.0.0.1" port = 8901 logfile = os.path.expanduser("~/.event.log") osdparams = "-p bottom --color=red --delay=4 --age=4 " \ - "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \ + "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \ # noqa: W605,E501 "--offset=100 --shadow=0 --lines=5 --align=right --indent=100" actions = ( (".*", [log], True), @@ -40,78 +40,101 @@ actions = ( """ +import getopt +import logging import os -import sys import re -import string import socket -import logging -import getopt +import string import subprocess +import sys -default_hostname = 'localhost' +default_hostname = "localhost" default_port = 1234 -default_osd_params = osdparams = "-p bottom --color=red --delay=4 --age=4 " \ - "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \ - "--offset=100 --shadow=0 --lines=5 --align=right --indent=100" +default_osd_params = osdparams = ( + "-p bottom --color=red --delay=4 --age=4 " + "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " # noqa: W605,E501 + "--offset=100 --shadow=0 --lines=5 --align=right --indent=100" +) default_logfile = None def play(sound_file): def play_wrapper(msg): - with open(os.devnull, 'w') as devnull: - subprocess.Popen(['/usr/bin/aplay', sound_file], stderr=devnull) + with open(os.devnull, "w") as devnull: + subprocess.Popen(["/usr/bin/aplay", sound_file], stderr=devnull) + return play_wrapper + def execute(command): def command_wrapper(msg): - subprocess.call(command % dict(msg = msg)) + subprocess.call(command % dict(msg=msg)) + return command_wrapper + def osd(msg): osdcmd = "/usr/bin/osd_cat" - osdpipe = os.popen("%s %s" % (osdcmd, osdparams), 'w') + osdpipe = os.popen("%s %s" % (osdcmd, osdparams), "w") osdpipe.write(msg) osdpipe.close() + def libnotify(msg): try: import dbus except ImportError: - sys.stderr.write('Please install python-dbus\n') + sys.stderr.write("Please install python-dbus\n") raise SystemExit(1) bus = dbus.SessionBus() - notifyService = bus.get_object("org.freedesktop.Notifications", '/org/freedesktop/Notifications') - interface = dbus.Interface(notifyService, 'org.freedesktop.Notifications') + notifyService = bus.get_object( + "org.freedesktop.Notifications", "/org/freedesktop/Notifications" + ) + interface = dbus.Interface(notifyService, "org.freedesktop.Notifications") - message, title = (':' + msg).split(':')[::-1][0:2] + message, title = (":" + msg).split(":")[::-1][0:2] if not title: title, message = message, title - interface.Notify('notify-server', 0, 'notification-message-im', title, message, [], {'x-canonical-append':'allowed'}, -1) + interface.Notify( + "notify-server", + 0, + "notification-message-im", + title, + message, + [], + {"x-canonical-append": "allowed"}, + -1, + ) + def log(msg): if logger: logger.info(msg) + def syntax(): - print "osd_server.py [options]" - print " options:" - print " -h --help print this message" - print " -H --host host of the osd server (def: " + default_hostname + ")" - print " -P --port port of the osd server (def: " + str(default_port) + ")" - print " -l --log log file ('-' logs to stdout)" - - -env = { 'play' : play, - 'execute' : execute, - 'osd' : osd, - 'libnotify' : libnotify, - 'log' : log, - 'host' : default_hostname, - 'port' : default_port, - 'logfile' : default_logfile, - } + print("osd_server.py [options]") + print(" options:") + print(" -h --help print this message") + print(" -H --host host of the osd server (def: " + default_hostname + ")") + print( + " -P --port port of the osd server (def: " + str(default_port) + ")" + ) + print(" -l --log log file ('-' logs to stdout)") + + +env = { + "play": play, + "execute": execute, + "osd": osd, + "libnotify": libnotify, + "log": log, + "host": default_hostname, + "port": default_port, + "logfile": default_logfile, +} default_actions = ( (".*", [log], True), @@ -122,12 +145,22 @@ default_actions = ( default_bind = (default_hostname, default_port) try: - execfile(os.path.expanduser('~/.notifyd.conf'), {}, env) + exec( + compile( + open(os.path.expanduser("~/.notifyd.conf"), "rb").read(), + os.path.expanduser("~/.notifyd.conf"), + "exec", + ), + {}, + env, + ) except IOError: pass try: - opts, args = getopt.getopt(sys.argv[1:], "hH:P:l:", ["help", "host=", "port=", "log="]) + opts, args = getopt.getopt( + sys.argv[1:], "hH:P:l:", ["help", "host=", "port=", "log="] + ) except getopt.GetoptError: syntax() sys.exit(2) @@ -137,23 +170,23 @@ for opt, arg in opts: syntax() sys.exit(3) elif opt in ("-H", "--host"): - env['host'] = arg + env["host"] = arg elif opt in ("-P", "--port"): - env['port'] = int(arg) + env["port"] = int(arg) elif opt in ("-l", "--log"): - env['logfile'] = arg + env["logfile"] = arg -actions = env.get('actions', default_actions) -logfile_name = env.get('logfile') -logfile_format = env.get('logformat', '%(asctime)s %(message)s') -bind_address = (env['host'], env['port']) -osd_params = env.get('osdparams', default_osd_params) +actions = env.get("actions", default_actions) +logfile_name = env.get("logfile") +logfile_format = env.get("logformat", "%(asctime)s %(message)s") +bind_address = (env["host"], env["port"]) +osd_params = env.get("osdparams", default_osd_params) if logfile_name: - logger = logging.getLogger('notify_server') + logger = logging.getLogger("notify_server") lformatter = logging.Formatter(logfile_format) - if logfile_name not in ('', '-'): + if logfile_name not in ("", "-"): lfh = logging.FileHandler(logfile_name) lfh.setFormatter(lformatter) logger.addHandler(lfh) @@ -165,23 +198,25 @@ if logfile_name: else: logger = None -l = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -l.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) -l.bind(bind_address) -l.listen(5) +listen = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +listen.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +listen.bind(bind_address) +listen.listen(5) + def filter_char(c): - return c in string.printable + "äöüßÄÖÜ" and c or '_' + return c in string.printable + "äöüßÄÖÜ" and c or "_" + while 1: try: - (con, addr) = l.accept() - except: + (con, addr) = listen.accept() + except OSError: continue data = con.recv(50).strip() con.close() - log = ''.join(filter_char(c) for c in data) + log = "".join(filter_char(c) for c in data) for pattern, handlers, cont in actions: if re.match(pattern, log): -- 2.1.4 From 520c6203b7aaa7079c1e36f8cdd0718ec073eacd Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 6 May 2022 14:08:16 +0200 Subject: [PATCH 02/16] Release new version 2.11.0 --- debian/changelog | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/debian/changelog b/debian/changelog index b5f0647..00e3d13 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +grml-scripts (2.11.0) unstable; urgency=medium + + [ Darshaka Pathirana ] + * [cb8ed97] Add Code testing workflow + * [e41ddb1] Makefile: Do not shellcheck iimage + * [584376f] Makefile: Do not shellcheck make_chroot_jail + * [02a237b] Makefile: return error if a check fails + * [95f1a38] grml-swapon.8: Fix spelling (via spellintian) + * [a4b7aa6] grepedit/notifyd.py: Convert to Python 3 + * Many shellcheck related changes + + -- Michael Prokop Fri, 06 May 2022 14:06:47 +0200 + grml-scripts (2.10.0) unstable; urgency=medium * [7bbfe54] grml-chroot: support efivarfs in EFI environments -- 2.1.4 From 35bb41fcb746ad7d1e4b817f8e7f35f489a36f9a Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 19 May 2022 11:25:23 +0200 Subject: [PATCH 03/16] github actions: ensure our apt cache is up2date Otherwise we might end up with outdated mirror information: | Err:77 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 lintian all 2.62.0ubuntu2 | 404 Not Found [IP: 40.119.46.219 80] | Fetched 4172 kB in 4s (951 kB/s) | E: Failed to fetch http://azure.archive.ubuntu.com/ubuntu/pool/main/l/lintian/lintian_2.62.0ubuntu2_all.deb 404 Not Found [IP: 40.119.46.219 80] | E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? Gbp-Dch: Ignore --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b06617b..c988196 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,6 +15,9 @@ jobs: - name: Checkout source uses: actions/checkout@v2 + - name: Update APT cache + run: sudo apt-get update + - name: Install lintian run: sudo apt-get -y install lintian -- 2.1.4 From 40ec66c5320ebed6a99ffd92456d1ccde5d06345 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 3 Jun 2022 16:48:50 +0200 Subject: [PATCH 04/16] Drop debian/compat and switch to debhelper-compat approach --- debian/compat | 1 - debian/control | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 debian/compat diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/debian/control b/debian/control index 5fcd241..a944854 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: utils Priority: optional Maintainer: Michael Prokop Build-Depends: asciidoc, - debhelper (>= 10~), + debhelper-compat (= 12), dietlibc-dev, docbook-xsl, xsltproc -- 2.1.4 From 3b7f948896440f41092f14347b17ce114072c569 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Tue, 7 Jun 2022 15:58:34 +0200 Subject: [PATCH 05/16] grml_chroot: fix broken mount argument handling Commit b4a4893b0b6 broke behavior of the grml-chroot script, as it then passed all mount options as single argument, which then fails: | + all_options_='-t proc none' | + mount '-t proc none' /mnt/proc | mount: /mnt/proc: can't find in /etc/fstab. | + mountit sysfs sys | [...] Convert mount options into an array, to properly work also with quotes. --- usr_sbin/grml-chroot | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr_sbin/grml-chroot b/usr_sbin/grml-chroot index 8fcdabf..b13b57e 100755 --- a/usr_sbin/grml-chroot +++ b/usr_sbin/grml-chroot @@ -43,14 +43,14 @@ function mountit local dest_="$2" local options_="$3" - local all_options_="" + local all_options_=() if [[ $options_ == "--bind" ]]; then - all_options_="--bind $type_" + all_options_+=(--bind "$type_") else - all_options_="-t $type_ none" + all_options_+=(-t "$type_" none) fi - mount "$all_options_" "${DEST_}/$dest_" && storeMounts "$dest_" + mount "${all_options_[@]}" "${DEST_}/$dest_" && storeMounts "$dest_" } function umount_all -- 2.1.4 From 988a63311fe3f1c7516395a53656dde1d2cc122e Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Tue, 7 Jun 2022 15:59:41 +0200 Subject: [PATCH 06/16] Release new version 2.11.1 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 00e3d13..8018981 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml-scripts (2.11.1) unstable; urgency=medium + + * [40ec66c] Drop debian/compat and switch to debhelper-compat approach + * [3b7f948] grml_chroot: fix broken mount argument handling + + -- Michael Prokop Tue, 07 Jun 2022 15:59:26 +0200 + grml-scripts (2.11.0) unstable; urgency=medium [ Darshaka Pathirana ] -- 2.1.4 From 454a3e508881316131b82651fd11a3aaf4648c52 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 7 Sep 2022 13:56:57 +0200 Subject: [PATCH 07/16] iimage: replace egrep usage with grep -E grep 3.8 deprecated support for egrep + fgrep, and now prints a warning on stderr: | egrep: warning: egrep is obsolescent; using grep -E | fgrep: warning: fgrep is obsolescent; using grep -F --- usr_bin/iimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr_bin/iimage b/usr_bin/iimage index 9b210d0..b2f81f7 100755 --- a/usr_bin/iimage +++ b/usr_bin/iimage @@ -1004,7 +1004,7 @@ function update_description_names() { find_all_images for i in $ALL_IMAGES ; do - if ! egrep "$i=" ./description >/dev/null ; then + if ! grep -E "$i=" ./description >/dev/null ; then echo "$i=`description $i`" >> ./description fi -- 2.1.4 From c1231da0db59f3cb545d9ef8e446a287b7618a3c Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 11 Nov 2022 17:01:51 +0100 Subject: [PATCH 08/16] Release new version 2.11.2 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 8018981..3938a61 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +grml-scripts (2.11.2) unstable; urgency=medium + + * [454a3e5] iimage: replace egrep usage with grep -E + + -- Michael Prokop Fri, 11 Nov 2022 17:01:40 +0100 + grml-scripts (2.11.1) unstable; urgency=medium * [40ec66c] Drop debian/compat and switch to debhelper-compat approach -- 2.1.4 From 570d9599584feb8ff7ccc8a9abe346c356f62c45 Mon Sep 17 00:00:00 2001 From: Darshaka Pathirana Date: Sat, 12 Nov 2022 17:18:35 +0100 Subject: [PATCH 09/16] Set SHELL variable in run-welcome + run-screen By default login(1) is called by agetty(8) and sets the SHELL variable "according to the appropriate fields in the password entry". Our tty1 calls run-welcome, tty2 - tty4 call run-screen and tty5 - tty7 call agetty (with autologin grml). So, our tty1 - tty4 bypass agetty(8) + login(1) and (should) end in a the zsh shell (via the welcome-screen or GNU/screen) without the SHELL variable set. run-welcome is designed to be started (only) on tty(1) and starts zsh anyway. But as we bypass login(1) the SHELL variable is not set. The same is true for run-screen, but instead of starting the zsh as login-shell, `screen` is called and runs the shell defined by the SHELL variable or /bin/sh if not defined. So, we ended up using the systemd "Environment"-option to set the SHELL variable (grml/grml-live@6871972 + grml/grml-live@7422d31). Although this is a working solution, setting the SHELL variable in run-welcome + run-screen makes it more transparent, that the script is actually responsible to set the SHELL variable. While debugging this problem, also noticed that screen should start the shell as login-shell (like all other ttys). To do so the given shell command needs to be prefixed with the '-' character. grml/grml-live@6871972 + grml/grml-live@7422d31 can/should be reverted after this change has been applied. Issues: grml/grml#135 + grml/grml#14 --- usr_share/run-screen | 7 ++++--- usr_share/run-welcome | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/usr_share/run-screen b/usr_share/run-screen index 4832feb..d04543f 100755 --- a/usr_share/run-screen +++ b/usr_share/run-screen @@ -6,6 +6,7 @@ # License: This file is licensed under the GPL v2. ################################################################################ +export SHELL=/bin/zsh # try to mitigate raceconditions from screen SCREENDIR_="/var/run/screen" mkdir -m 700 "${SCREENDIR_}/S-$USER" >/dev/null 2>&1 @@ -13,11 +14,11 @@ mkdir -m 700 "${SCREENDIR_}/S-$USER" >/dev/null 2>&1 # now run screen with config if [ "$(id -u)" = 0 ] ; then - exec screen -U -c /etc/grml/screenrc + exec screen -U -c /etc/grml/screenrc -s "-$SHELL" elif [ -r "$HOME/.screenrc" ] ; then - exec screen -U -c "$HOME/.screenrc" + exec screen -U -c "$HOME/.screenrc" -s "-$SHELL" else - exec screen -U -c /etc/grml/screenrc_generic + exec screen -U -c /etc/grml/screenrc_generic -s "-$SHELL" fi ## END OF FILE ################################################################# diff --git a/usr_share/run-welcome b/usr_share/run-welcome index 265301e..d8d694a 100755 --- a/usr_share/run-welcome +++ b/usr_share/run-welcome @@ -9,6 +9,8 @@ # shellcheck disable=SC1091 . /etc/grml/sh-lib +export SHELL=/bin/zsh + [ -r /etc/grml_version ] && GRMLVERSION=$(cat /etc/grml_version) || GRMLVERSION='(no version information available)' PATH=$HOME/bin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/games:/home/grml/bin CMDLINE=$(cat /proc/cmdline) @@ -82,6 +84,6 @@ Happy hacking! http://grml.org/ " fi -exec /bin/zsh -l +exec "$SHELL" -l ## END OF FILE ################################################################# -- 2.1.4 From 168953e791d6fe6dd0203fe1fda085fba33a033d Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 25 Nov 2022 09:51:01 +0100 Subject: [PATCH 10/16] Release new version 2.12.0 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 3938a61..e369b61 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml-scripts (2.12.0) unstable; urgency=medium + + [ Darshaka Pathirana ] + * [570d959] Set SHELL variable in run-welcome + run-screen + + -- Michael Prokop Fri, 25 Nov 2022 09:50:44 +0100 + grml-scripts (2.11.2) unstable; urgency=medium * [454a3e5] iimage: replace egrep usage with grep -E -- 2.1.4 From b3825665c6b20c495e6964bc1fa1a23aa0b30ed9 Mon Sep 17 00:00:00 2001 From: Darshaka Pathirana Date: Sun, 27 Nov 2022 13:29:51 +0100 Subject: [PATCH 11/16] grml-resolution: Quick 'n dirty xrandr output parser fix The xrandr output parser of grml-resolution seems to be broken since at least Grml 2014.11: grml-resolution does not list possible resolutions but its corresponding refresh rates. It seems like once upon a time xrandr had a 'size-index' in front of each resolution. This is not the case anymore and there does not seem to be an option to add that behaviour back to xrandr. So, CURRENT_NUM did not receive the 'size-index' of the current resolution, therefor I dropped that variable which was used to detect if the user had chosen the current resolution (nothing bad happens if xrandr sets the current resolution). We now list the possible resolutions and refresh rates, separated by an underscore because `dialog` does not like spaces. xrandr -s works fine with the chosen 'index' from dialog. Closes: grml/grml-scripts#14 --- usr_bin/grml-resolution | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/usr_bin/grml-resolution b/usr_bin/grml-resolution index 5b334d7..08d075a 100755 --- a/usr_bin/grml-resolution +++ b/usr_bin/grml-resolution @@ -23,11 +23,10 @@ COUNTER=0 STRING="" # current mode -CURRENT_NUM=$(xrandr | awk '/\*/ {print $1}' | tr -d '*') -CURRENT_RESOLUTION=$(xrandr | awk '/\*/ {print $2 $3 $4}') +CURRENT_RESOLUTION=$(xrandr | awk '/\*/ {print $1"_"$2}') # menu -for i in $(xrandr | awk '{print $2$3$4}' | grep "^[0-9]") ; do +for i in $(xrandr | awk '{print $1"_"$2}' | grep "^[0-9]") ; do STRING="$STRING $COUNTER $i" ((COUNTER++)) done @@ -43,9 +42,7 @@ esac CHOSE=$(cat "$RESOLUTION") -if [ "$CHOSE" = "$CURRENT_NUM" ] ; then - dialog --title "$PN" --msgbox "Chosen resolution corresponds to current resolution. No changes needed." 0 0 -elif [ -n "$CHOSE" ] ; then +if [ -n "$CHOSE" ] ; then # shellcheck disable=SC2015 xrandr -s "$CHOSE" 2>"$ERROR" && \ dialog --title "$PN" --msgbox "Running xrandr with resolution was succesful." 0 0 || \ -- 2.1.4 From 0ac4551b01b478003597737ae214a763144a3b98 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 28 Nov 2022 08:35:28 +0100 Subject: [PATCH 12/16] Release new version 2.12.1 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index e369b61..c43e09c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml-scripts (2.12.1) unstable; urgency=medium + + [ Darshaka Pathirana ] + * [b382566] grml-resolution: Quick 'n dirty xrandr output parser fix + + -- Michael Prokop Mon, 28 Nov 2022 08:35:17 +0100 + grml-scripts (2.12.0) unstable; urgency=medium [ Darshaka Pathirana ] -- 2.1.4 From 099f921c3368735a4162d07d6c4d8e324b524b72 Mon Sep 17 00:00:00 2001 From: Michael Schierl Date: Sat, 14 Jan 2023 21:56:38 +0100 Subject: [PATCH 13/16] Fix `grml2ram` when booted via `loopback.cfg` When booted from a multiboot USB stick via loopback.cfg (or when using `findiso=` kernel option manually), `/dev/loop0` is used for the ISO file and `/dev/loop1` for the squashfs image. Therefore, changing backing file descriptor of `/dev/loop0` will fail. Call `losetup` to find the name of the loop device associaed to the squashfs image instead. --- usr_sbin/grml2ram | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr_sbin/grml2ram b/usr_sbin/grml2ram index a4e119e..0806383 100755 --- a/usr_sbin/grml2ram +++ b/usr_sbin/grml2ram @@ -65,6 +65,7 @@ fi GRMLSIZE="$(du $IMAGE | awk '{print $1}')" RAM=$(/usr/bin/gawk '/MemFree/{print $2}' /proc/meminfo) +LOOPDEV=$(/sbin/losetup -j "${IMAGE}" -n -O NAME) case "$*" in -f|--force) ewarn "Forcing copy process for grml-image (${GRMLSIZE}kB) as requested via force option." ; eend 0 @@ -80,7 +81,7 @@ esac einfo "Copying $IMAGE to RAM, this might take a while." rsync -a --progress $IMAGE /tmp/GRML LANGUAGE=C LANG=C LC_ALL=C perl << EOF -open LOOP, ' Date: Fri, 3 Feb 2023 17:26:33 +0100 Subject: [PATCH 14/16] Release new version 2.12.2 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index c43e09c..1eda2a6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml-scripts (2.12.2) unstable; urgency=medium + + [ Michael Schierl ] + * [099f921] Fix `grml2ram` when booted via `loopback.cfg` + + -- Michael Prokop Fri, 03 Feb 2023 17:26:26 +0100 + grml-scripts (2.12.1) unstable; urgency=medium [ Darshaka Pathirana ] -- 2.1.4 From 0c1cd5d0cbee79178dba78483b4d082b9e60a263 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 1 Sep 2023 13:20:55 +0200 Subject: [PATCH 15/16] Drop broken and deprecated vmware-detect MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It was reported that this tool no longer works as expected, though virt-what and systemd-detect-virt exist nowadays. Thanks: András Korn --- compile/.gitignore | 1 - compile/Makefile | 5 +- compile/vmware-detect.c | 143 ------------------------------------------------ debian/overrides | 1 - debian/rules | 3 +- 5 files changed, 2 insertions(+), 151 deletions(-) delete mode 100644 compile/vmware-detect.c diff --git a/compile/.gitignore b/compile/.gitignore index 5f8d282..c6f80a9 100644 --- a/compile/.gitignore +++ b/compile/.gitignore @@ -1,4 +1,3 @@ align dpkg_not_running -vmware-detect grml-runtty diff --git a/compile/Makefile b/compile/Makefile index a5d42c3..964ae3c 100644 --- a/compile/Makefile +++ b/compile/Makefile @@ -1,4 +1,4 @@ -PROGS = vmware-detect dpkg_not_running grml-runtty +PROGS = dpkg_not_running grml-runtty #ifndef CFLAGS CFLAGS = -O2 -Wall -s @@ -14,9 +14,6 @@ CC = gcc all: $(PROGS) -vmware-detect: vmware-detect.c - diet $(CC) $(CFLAGS) -o $@ $^ - dpkg_not_running: dpkg_not_running.c diet $(CC) $(CFLAGS) -o $@ $^ diff --git a/compile/vmware-detect.c b/compile/vmware-detect.c deleted file mode 100644 index c99e36f..0000000 --- a/compile/vmware-detect.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Filename: vmware-detect.c -* Purpose: Detect if running inside vmware -* Authors: grml-team (grml.org), (c) Michael Gebetsroither -* Bug-Reports: see http://grml.org/bugs/ -* License: This file is licensed under the GPL v2. -*******************************************************************************/ -// return 0 if running inside vmware, 1 otherwise - -#include "string.h" -#include "unistd.h" -#include "stdio.h" -#include "stdlib.h" -#include "signal.h" - -#define WRITE(x) write(1, x, strlen(x)) -#define DWRITE(x) do{ \ - if(debug) { \ - WRITE(x); \ - } \ -} while(0); -#define FALSE 0 -#define TRUE !FALSE - -/* doc: - * vmware IO backdoor: http://chitchat.at.infoseek.co.jp/vmware/backdoor.html - * http://www.honeynet.org/papers/bots/botnet-code.html - * http://www.codegurus.be/codegurus/Programming/virtualpc&vmware_en.htm - */ - -// from libowfat {{{ -static inline char tohex(char c) { - return c>=10?c-10+'a':c+'0'; -} - -unsigned int fmt_xlong(char *dest,unsigned long i) { - register unsigned long len,tmp; - /* first count the number of bytes needed */ - for (len=1, tmp=i; tmp>15; ++len) tmp>>=4; - if (dest) - for (tmp=i, dest+=len; ; ) { - *--dest = tohex(tmp&15); - if (!(tmp>>=4)) break; - } - return len; -} -// }}} - -void printIdtr(const unsigned char* idtr, unsigned size) -{ - unsigned i; - for(i=0; i Date: Wed, 6 Sep 2023 17:26:11 +0200 Subject: [PATCH 16/16] Release new version 2.13.0 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 1eda2a6..7f7a132 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml-scripts (2.13.0) unstable; urgency=medium + + * [0c1cd5d] Drop broken and deprecated vmware-detect. + Thanks to András Korn + + -- Michael Prokop Wed, 06 Sep 2023 17:24:49 +0200 + grml-scripts (2.12.2) unstable; urgency=medium [ Michael Schierl ] -- 2.1.4