Commit Graph

75 Commits

Author SHA1 Message Date
Sami Kerola cfa7fe890b last, utmpdump, agetty, wall, write: avoid compatibility hacks
In include/bits/utmp.h the ut_user and ut_time macros are marked with
comment they are backwards compatibility hacks.  It is probably best to
avoid use of these macros where ever possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:10 +01:00
Karel Zak 6f96420666 agetty: -L accepts optional argument
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-06 15:39:11 +02:00
Sami Kerola 3797cf255b agetty: fix memory leak [clang-analyzer]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-09 14:25:15 +02:00
kernc a056cfe290 Fixes "getty: unrecognized option '--loginpause'"
Usage incorrectly stated --loginpause is a valid option, where instead --login-pause is.

Also --no-hostname --> --nohostname.
2013-07-04 17:02:57 +02:00
Karel Zak 714cff30fd agetty: use O_NONBLOCK only for serial lines with CLOCAL
* regression introduced by ef264c830e

 * also increase sleep when O_NONBLOCK used (grr.. this is so stupid
   thing, do we really need O_NONBLOCK for the stupid serial lines?)

References: https://bugzilla.redhat.com/show_bug.cgi?id=972457
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-13 11:30:02 +02:00
Karel Zak 4cfda3dce0 agetty: update man page and usage()
- baud_rate is optional
 - agetty has been rewritten 2 years ago, so don't blame original
   authors in the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-03 10:04:43 +02:00
Karel Zak ef264c830e agetty: allow full control on CLOCAL flag
Now the -L option allows to explicitly enable CLOCAL flag.

Unfortunately sometimes it's necessary to clear the flag. This patch
add optional argument =<mode> to specify 'auto', 'always' and 'never'
to control CLOCAL flag.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=816342
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-23 09:47:58 +02:00
Sami Kerola 1aba8336c0 agetty: check writing to a file was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:06 +02:00
Sami Kerola 86ad1432e8 agetty: the command does not have -h and -V options
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 13:55:54 +02:00
Karel Zak 4b856ee4b9 agetty: add --chroot to usage() and man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-05 12:55:20 +02:00
Karel Zak 1505a0b266 agetty: add -E, --remote to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-05 12:47:42 +02:00
Karel Zak 8362545b4a lib/xalloc: fix mamory leak in xgethostname() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:08:47 +01:00
Karel Zak 915c1d99f6 agetty: make \{4,6} issue file code more robust [coverity scan]
... and more readable for static analyzers

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 14:33:17 +01:00
Karel Zak 5ad0923904 remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-20 14:40:19 +01:00
Sami Kerola f8bd089b1d a pointer should not be compared to zero [coccinelle]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 11:51:15 +01:00
Benno Schulenberg 9e53140075 agetty: properly pluralize the reporting of the number of users
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-30 15:23:42 +01:00
Sami Kerola 7d36855604 agetty: make usage() translator friendly
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 16:40:05 +01:00
Benno Schulenberg 8c219bf463 textual: gettextize several overlooked messages
Also improve the clarity of some of them.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:29 +01:00
Werner Fink f5664477cb include/ttyutils: add default chardata
this one moves the init_chardata to include/ttyutils.h as well as to
lib/include/ttyutils.c.  Also the macros CTL/CTRL are fixed in
agetty.c and sulogin.c to use the XOR variant CTL.

[kzak@redhat.com: use macro rather than global variable for default
                  chardata]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:42:12 +01:00
Karel Zak 91984e938e agetty: replace perms 660 to 620
... the default is root:tty 620

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-02 08:27:32 +01:00
Karel Zak a73f59fa03 sulogin: remove consoles.c from libcommon
- move struct chardata to include/ttyutils.h
- move console.{h,c} to login-utils/sulogin-* (it's sulogin specific)
- fix sulogin and agetty includes

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23 22:14:21 +01:00
Karel Zak 5676f36563 agetty: remove @ and # as default kill and erase chars
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 11:23:53 +01:00
Karel Zak cb872ac99d agetty: add --{erase,kill}-chars options
We need way to disable the default kill and erase agetty chars to make
the getty usable for Active Directory users with '@' in username.

It seems that the most extendible solution is to add options that
allow to complete control additional erase/kill chars. If you specify
empty strings then the chars are disabled at all.

Note that this patch is backwardly compatible.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=870854
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 11:17:51 +01:00
Karel Zak 933956cb49 agetty: make --autologin useful with --skip-login (prompt)
The --autologin prints

	hostname login: username (automatic login)

message. This commit allows to suppress the message at all if
--skip-login (aka skip prompt) is specified.

It means that

	agetty --skip-login --noissue --autologin foouser

does completely silent autologin.

Addresses: https://github.com/karelzak/util-linux/issues/21
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-19 10:54:58 +01:00
Michal Schmidt c13d60b291 agetty: fix autodetection for TERM
open_tty() autodetects whether to set TERM to "linux" or "vt102", but it
can apply the result only if op->term is still NULL.
2012-11-02 12:38:25 +01:00
Sami Kerola 74b3df85f7 agetty: replace gethostbyname() with getaddrinfo()
The gethostbyname() is legacy function which may be withdrawn in a
future.

Reference: http://pubs.opengroup.org/onlinepubs/009695399/functions/gethostbyname.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-22 10:14:36 +02:00
Karel Zak 2448f33637 agetty: stop using MAXHOSTNAMELEN
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 16:27:46 +02:00
Karel Zak 2b945eda3d agetty: add \4 and \6 issue file sequences to print IP addresses
Based on Andrea Bonomi <a.bonomi@endian.com> ideas.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-13 12:59:46 +02:00
Mantas Mikulėnas 9002d6504a agetty: remove unnecessary sleep(10)
I'm quite sure this is not supposed to be here (apparently added as part
of commit 783b08fc1c).

Signed-off-by: Mantas Mikulėnas <grawity@gmail.com>
2012-07-25 16:13:11 +02:00
Karel Zak 783b08fc1c agetty: close tty before vhangup()
Let's close all tty file descriptors if called with --hangup option.

References: https://lkml.org/lkml/2012/6/5/145
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-12 16:34:56 +02:00
Karel Zak 4459448fbd agetty: make tcsetpgrp() optional
The session setup TIOCSCTTY is optional, so tcsetpgrp() that depends
on controlling terminal should be optional too.

Reported-by: Hilko Bengen <bengen@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-11 18:15:21 +02:00
Sami Kerola 01c5b78794 agetty: use configured run state directory
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-10 13:00:20 +02:00
Karel Zak efcf26f44f agetty: more robust debug() macro, check ioctl result [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 12:13:08 +02:00
Sami Kerola 0e9b73d3fb build: fix redundant redeclaration warnings
env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]

fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls]

kill.h:1:13: note: previous declaration of 'get_pids' was here
kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls]

kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]

agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls]
agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]

libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here
libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here
mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls]
mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Karel Zak 3a9c3f3fb7 include/c: move fallback for MAXHOSTNAMELEN to c.h
Reported-by: Thomas Schwinge <thomas@codesourcery.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-29 10:08:25 +02:00
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Karel Zak 879a7ab470 agetty: move vc initialization to ttyutils.h
... to make the code usable for sulogin.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-12 14:39:32 +01:00
Karel Zak d9201203cf agetty: check localtime() result
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-06 16:02:28 +01:00
Francesco Cosoleto 1a204cd216 agetty: add static and const qualifiers
Remove also a static qualifier in main() function.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-12-16 12:49:13 +01:00
Karel Zak 1593b134eb agetty: don't use log_err() for non-fatal errors
The TIOCSCTTY ioctl requires that caller is session leader -- so it
depends on initd (or we have to add setsid() to aggety). It seems that the
traditional way is to setup tty in agetty and session in login(1).

It means that all session related things (TIOCSCTTY, vhangup, ...) in the
command agetty should be optional. (Note that vhangup() is called when
--hangup is explicitly specified on command line, so log_err() makes
sense there.)

Reported-by: Andrew Walrond <andrew@walrond.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-08 12:54:49 +01:00
Dennis Jensen 9c62a2326e agetty: map NL to CR-NL on output in initial termiossettings
From: Jacoby Hickerson <hickersonjl@gmail.com>
Signed-off-by: Dennis Jensen <dennis.h.jensen@siemens.com>
2011-11-28 10:34:39 +01:00
Karel Zak 01095ae33c agetty: pass hostname to login(1)
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-26 23:17:15 +02:00
Karel Zak b926112726 agetty: test ECHO on c_lflag
Reported-by: xinglp <xinglp@gmail.com>
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=739522
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-26 12:34:10 +02:00
Karel Zak 36601b2343 agetty: add --nohints
Reported-by: "Gabor Z. Papp" <gzp@papp.hu>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 14:24:27 +02:00
Karel Zak 89aed1c950 agetty: double equals sign typo in opentty()
Reported-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-07 07:37:03 +02:00
Karel Zak c0d38ecdce agetty: clean up usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 11:58:50 +02:00
Karel Zak 9aeb66dc6b agetty: improve login(1) argv[]
* fix regression: missing username should not be reported (EPERM) if
  -n/--skip-login is given and username is NULL.

* don't compose login options *string* if we can use argv *array* (the
  string is necessary only for --login-options).

* don't overwrite --login-options by --autologin

  The old code silently ignores login-options and "login -f <username>"
  is always used.

  The new code uses:
    a)	"login -f <username>"    by default
    b)	"login <login-options>"  for --login-options + --autologin

  where for b) the username from "--autologin <username>" is used to
  replace \u magic string in <login-options>.

* the \u could be used more than once in one login argv string, for
  example: agetty --login-options "-o user=\\u,name=\\u --foo"

* the space in --login-options is correctly ignored, for example
  agetty --login-options " hello world ".

Reviewed-by: Voelker, Bernhard <bernhard.voelker@siemens-enterprise.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-08 12:07:07 +02:00
Samuel Thibault b0198a1163 agetty: C.UTF-8 locale instead of en_US.UTF-8
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2011-08-08 11:50:21 +02:00
Samuel Thibault 7478fce029 agetty: only enable F_UTF8 if kernel has already set IUTF8.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2011-08-08 11:49:58 +02:00
Werner Fink 8408647d89 agetty: Fix IUTF8 flag
Preserve IUTF8 as set up by the kernel, which knows which consoles are
in utf8 mode.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Werner Fink <werner@suse.de>
2011-08-02 14:20:31 +02:00