| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Copyright (C) 2012-2026 Free Software Foundation, Inc. |
| 4 |
# |
| 5 |
# This file is part of GNU Inetutils. |
| 6 |
# |
| 7 |
# GNU Inetutils is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation, either version 3 of the License, or (at |
| 10 |
# your option) any later version. |
| 11 |
# |
| 12 |
# GNU Inetutils is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
# General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program. If not, see `http://www.gnu.org/licenses/'. |
| 19 |
|
| 20 |
# Test to establish functionality of read_utmp() from Gnulib. |
| 21 |
# The functionality is needed by our services syslog and talkd. |
| 22 |
# |
| 23 |
|
| 24 |
. ./tools.sh |
| 25 |
|
| 26 |
READUTMP=${READUTMP:-./readutmp$EXEEXT} |
| 27 |
|
| 28 |
if test ! -x $READUTMP; then |
| 29 |
echo >&2 "No executable '$READUTMP' present. Skipping test." |
| 30 |
exit 77 |
| 31 |
fi |
| 32 |
|
| 33 |
if test -n "$VERBOSE"; then |
| 34 |
set -x |
| 35 |
fi |
| 36 |
|
| 37 |
errno=0 |
| 38 |
|
| 39 |
if who >/dev/null 2>&1; then |
| 40 |
# Check that readutmp agrees with who(1), |
| 41 |
# limiting ourselves to at most three users. |
| 42 |
for nn in `who | $SED 's/ .*//; 3q;'`; do |
| 43 |
$READUTMP $nn || errno=1 |
| 44 |
done |
| 45 |
else |
| 46 |
# Execute READUTMP once without argument, and once with |
| 47 |
# ourself as argument. Both should succeed, but are reported |
| 48 |
# as skipped test in case of failure. They are known to be |
| 49 |
# produce false positives in some circumstances. |
| 50 |
$READUTMP || errno=77 |
| 51 |
$READUTMP `func_id_user` || errno=77 |
| 52 |
fi |
| 53 |
|
| 54 |
if test $errno -eq 77; then |
| 55 |
cat >&2 <<-EOT |
| 56 |
NOTICE: read_utmp() from Gnulib just failed. This can be |
| 57 |
due to running this test in sudo mode, or using a role. |
| 58 |
Should this script fail while running it as a logged in |
| 59 |
user, then read_utmp() is indeed broken on this system. |
| 60 |
Then the present executables syslogd and talkd are not |
| 61 |
fully functional. |
| 62 |
EOT |
| 63 |
elif test $errno -eq 1; then |
| 64 |
cat >&2 <<-EOT |
| 65 |
User messaging is broken in syslogd and talkd. |
| 66 |
EOT |
| 67 |
fi |
| 68 |
|
| 69 |
exit $errno |