]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (chfn) ensure that invalid input is detected correctly master
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 15 Jan 2026 05:06:41 +0000 (00:06 -0500)
committerKarel Zak <kzak@redhat.com>
Thu, 29 Jan 2026 11:21:44 +0000 (12:21 +0100)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests/expected/chfn/input-illegal-passwd-chars [new file with mode: 0644]
tests/expected/chfn/input-too-long [new file with mode: 0644]
tests/ts/chfn/input [new file with mode: 0755]

diff --git a/tests/expected/chfn/input-illegal-passwd-chars b/tests/expected/chfn/input-illegal-passwd-chars
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok
diff --git a/tests/expected/chfn/input-too-long b/tests/expected/chfn/input-too-long
new file mode 100644 (file)
index 0000000..9766475
--- /dev/null
@@ -0,0 +1 @@
+ok
diff --git a/tests/ts/chfn/input b/tests/ts/chfn/input
new file mode 100755 (executable)
index 0000000..a39b680
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Copyright (C) 2025 Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
+#
+# This file is part of util-linux.
+#
+# This file 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 file 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.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="input"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_CHFN"
+
+# invalid passwd characters are [,:="\n]
+ts_init_subtest "illegal-passwd-chars"
+if ! "$TS_CMD_CHFN" --full-name "foo=bar:," &>/dev/null; then
+  echo "ok" > "$TS_OUTPUT"
+fi
+ts_finalize_subtest
+
+# currently we limit a valid GECOS field to 256 characters
+ts_init_subtest "too-long"
+if ! "$TS_CMD_CHFN" --full-name "$(head -c 257 /dev/zero | tr '\0' 'a')" &>/dev/null; then
+  echo "ok" > "$TS_OUTPUT"
+fi
+ts_finalize_subtest
+
+ts_finalize