Commit Graph

1052 Commits

Author SHA1 Message Date
Karel Zak cb5b52882e lslogins: use strtime_short()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-24 13:22:23 +02:00
Karel Zak 88134ee208 lslogins: use strtm_iso()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-24 11:08:10 +02:00
Karel Zak c7eb14d325 last: cleanup time formatting code
- describe difference between login and logout time formats in struct last_timefmt
- use strtime_iso()
- rename LAST_TIMEFTM_SHORT_CTIME to LAST_TIMEFTM_SHORT
- rename LAST_TIMEFTM_FULL_CTIME to LAST_TIMEFTM_CTIME
- add LAST_TIMEFTM_HHMM for internal purpose (logout format for "--time-format short")

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-24 11:07:08 +02:00
Werner Fink fe3f7e17aa sulogin: agetty: use the plymouth local protocol instead the plymouth binary
for stopping plymouthd.  That do not depend on the existence of
the plymouth binary if it e.g. becomes uninstalled or an other
service is providing plymouthd facilities.

[kzak@redhat.com: - fix compiler warnings [-Wpointer-sign]
                  - use sizeof() for write_all()
                  - cast to char* for read_all]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-20 11:21:10 +02:00
Sami Kerola 31af559e30
setpwnam: fix memory leak
Found with scan-build.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-19 21:27:54 +01:00
Sami Kerola 400423824a
sulogin: make fopen O_CLOEXEC specifier usage portable
The close at exit specifier "e" is glibc extension, so use it only if when
the extension is available.

Proposed-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Karel Zak 76839e9794 vipw: make tmp_file usage more robust [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-29 13:23:32 +02:00
Werner Fink 6988998b66 sulogin: Always make echo work after performing getpasswd even if root account is locked
If the root account is locked and no password was provided then the terminal
line is not set back to do echo of the input. This correct a small overlook
in commit 7ff1162e67

Signed-off-by: Werner Fink <werner@suse.de>
2016-03-22 10:50:39 +01:00
Ruediger Meier 36f1200851 sulogin: ignore missing WEXITED, add warning
This happens on Debian kFreeBSD and probably on Hurd too since
cde7699c. One should review this issue to fix it properly.

CC: Werner Fink <werner@suse.de>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-21 21:03:41 +01:00
Sami Kerola 4cd4b68795 vipw: print only one new line when asking about shadow file
Commit 11b86e1733 changed printf() to puts() in favour of more simple
function, but forgot that puts() adds a new line to end of string.  That new
line is neither needed, or expected, so use fputs() that is both a simple
printing function and comes without new line side effect.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-03-15 14:12:31 +01:00
Karel Zak 11b86e1733 vipw: use puts() when formatting unnecessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-14 16:02:17 +01:00
Karel Zak 785539baa3 Merge branch 'travis-osx' of https://github.com/rudimeier/util-linux
* 'travis-osx' of https://github.com/rudimeier/util-linux:
  travis: add OSX build
  travis: switch to Ubuntu 14.04 Trusty
  build-sys: improve uuidd and script build conditions
  build-sys: use AC_PROG_MKDIR_P and remove a few gnuisms
  build-sys: add missing "not found" strings
  build-sys: fix again UL_SCANF_TYPE_MODIFIER
  tests: don't use system's mount commands
  tests: improve skipping of old btrfs-tools
  tests: remove invalid argument in libmount/debug
  tests: skip old socat silently
  misc: fix icc/clang compiler warnings
  misc: fix printf i386 compiler warnings
2016-03-14 15:59:10 +01:00
Karel Zak 3d0cf042b0 sulogin: fix sigset_t initialization
Reported-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-14 13:21:27 +01:00
Ruediger Meier 58c87bd045 misc: fix icc/clang compiler warnings
clang warning:
libmount/src/tab.c:1833:6: warning: variable 'rc' is used uninitialized whenever
      'if' condition is true [-Wsometimes-uninitialized]
        if (!mpc)
            ^~~~

icc printf warnings:
    libmount/src/monitor.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
            DBG(MONITOR, ul_debugobj(mn, status == 1 ? " success" : " nothing"));
            ^
    login-utils/vipw.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
                           : _("You are using shadow passwords on this system.\n"));
                                                                                  ^

icc enum warnings:
    disk-utils/fdisk-menu.c(150): warning #188: enumerated type mixed with another type
            .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD,
                       ^
    libsmartcols/src/table_print.c(750): warning #188: enumerated type mixed with another type
                            &width, align,
                                    ^

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:47:27 +01:00
Karel Zak 075d2c0754 include: move sys/sysmacros.h to c.h
The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary),
but needed on many places. It seems better to keep it in c.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-08 14:29:45 +01:00
Karel Zak 3fe3f560b7 Revert "include sysmacros.h where used"
This reverts commit 46a40c0184.
2016-03-08 14:26:33 +01:00
Mike Frysinger 46a40c0184 include sysmacros.h where used
BSD/Linux systems stick major/minor/makedev in sysmacros.h.  Newer Linux
libraries have been moving away from including sysmacros.h implicitly via
sys/types.h, so include it directly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-03-08 14:21:55 +01:00
Ruediger Meier 9d76c6fb9f libmount: don't include libio.h
This include was added just one month ago in 5a971329 but I don't see
what it was good for. It's missing in musl libc.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:29:55 +01:00
Ruediger Meier fea1cbf748 misc: never cast void* from malloc(3) and friends
Such cast could hide serious compiler warnings in case we are
missing includes (e.g. <stdlib.h> or "xalloc.h").

See
http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:29:27 +01:00
Yuriy M. Kaminskiy 06fa581748 misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-07 15:11:06 +01:00
Ruediger Meier a365953a24 login-utils: minor utmp cleanup
- consistently use ut->ut_user instead of ut->ut_name
- don't include obsolete lastlog.h BSD header

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:06 +01:00
Ruediger Meier bbbf2aa853 newgrp: rename memset_s()
It's already defined in OSX standard c library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:59 +01:00
Ruediger Meier b0b54cc582 build-sys: always add AM_CFLAGS
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:17:29 +01:00
Ruediger Meier b201f1d86c build-sys: always use global LDADD
This was a major showstopper when building on a system where
LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test
programs which wouldn't need LDADD ... never mind.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:16:58 +01:00
Romain Naour 092bc0edaa vipw: Remove pre-ANSI compiler support
__P() is used for compatibility with old K&R C compilers. With
ANSI C this macro has no effect.

This fixes a compilation error with musl libc because of undeclared
__P.

Ref:
https://lists.samba.org/archive/samba-technical/2015-June/108042.html

Signed-off-by: Romain Naour <romain.naour@gmail.com>
2016-02-22 09:50:22 +01:00
Ruediger Meier 66daee0765 include: check for sys/sysmacros.h
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 16:54:17 +01:00
Karel Zak c619d3d167 su: clean up groups initialization
This patch does not change any su/runuser behaviour, code changes:

* don't use huge groups[NGROUPS_MAX]; the array has 256k, but we need
  it only occasionally when -G/-g specified.

* the current code uses groups[0] for -g and the rest for -G, this patch adds
  'gid' to remember -g argument to avoid memmove()

* add function add_supp_group() to simplify su_main()

* add note about -G and -g relation to the man pages (undocumented now)

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-15 14:07:25 +01:00
Karel Zak d0fe12aeb4 sulogin: keep initialization more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-12 11:21:50 +01:00
Werner Fink cde7699c27 sulogin: avoid shared memory area usemask but use waitid() for childs
This small patch improves the console detection code and also avoids not
existing device nodes due strdup() which is used in canonicalize_path().
Beside this now the code for emergeny mount does work if enabled at
configure time.

Signed-off-by: Werner Fink <werner@suse.de>
2016-02-12 11:19:21 +01:00
Ruediger Meier 3fd1f7711e docs: fix typos found by codespell
Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03 15:10:08 +01:00
Filipe Brandenburger 94757eceb1 scriptreplay/newgrp: use signed int to store return of getopt_long
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2016-01-07 12:47:41 +01:00
Karel Zak 8b7ef91689 lslogins: fix getgrouplist() usage for 64BE
on ppc64:
 $ lslogins kzak
 $ lslogins: cannot allocate 85899345920 bytes: Cannot allocate memory

because

  (int *) len

where len is pointer to size_t is bad idea...

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-21 15:50:58 +01:00
Karel Zak f7ac9e71b1 login, mount: fix __SC_GETPW_R_SIZE_MAX usage
sysconf(_SC_GETPW_R_SIZE_MAX) returns initial suggested size for pwd
buffer (see getpwnam_r man page or POSIX). This is not large enough in
some cases.

Yes, this sysconf option is misnamed (should be _SC_GETPW_R_SIZE_MIN).

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-15 12:33:34 +01:00
Benno Schulenberg 1e6a9c1814 chfn: improve formatting and wording of the manpage
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-11-09 10:03:58 +01:00
Sami Kerola a64e268224 login: fix stat(2) race
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-09 09:56:14 +01:00
Sami Kerola bd299782ca
nologin: require /etc/nologin.txt to be file
This makes silly practical jokes impossible, like for example symlinking
/dev/null or dev/random to /etc/nologin.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:38 +01:00
Sami Kerola f06abd22be
last: display input file in usage() according to command name
Default depends on whether the executable is called 'lastb' or something
else.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:34 +01:00
James Clarke 99eadc9e3f sulogin: Use fallback method on the Hurd for detecting consoles
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
2015-10-16 09:52:16 +02:00
Chen Qi 1b76608ef8 login: replace siginterrupt with sigaction
[kzak@redhat.com: - POSIX.1-2008 marks siginterrupt() as obsolete]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
2015-08-31 11:34:36 +02:00
Karel Zak 3e16df1558 chfn: document CHFN_RESTRICT /etc/login.defs
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-24 10:46:48 +02:00
Karel Zak bde91c85bd chsh, chfn, vipw: fix filenames collision
The utils when compiled WITHOUT libuser then mkostemp()ing
"/etc/%s.XXXXXX" where the filename prefix is argv[0] basename.

An attacker could repeatedly execute the util with modified argv[0]
and after many many attempts mkostemp() may generate suffix which
makes sense. The result maybe temporary file with name like rc.status
ld.so.preload or krb5.keytab, etc.

Note that distros usually use libuser based ch{sh,fn} or stuff from
shadow-utils.

It's probably very minor security bug.

Addresses: CVE-2015-5224
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-24 10:05:55 +02:00
Karel Zak f686b9980a lslogins: remove duplicate [make checkincludes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 12:57:22 +02:00
Karel Zak a6bf40ee77 lslogins: merge read_utmp() code
The code is used only in lslogins, so it does not make sense to
maintain it in libcommon.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-16 11:26:14 +02:00
Karel Zak 2b8a9bda07 lslogins: fix --user-accs and --system-accs docs
Reported-by: Mantas Mikulėnas <grawity@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-15 16:14:32 +02:00
Karel Zak f2f731deb8 Merge branch 'sulogin' 2015-06-30 11:21:12 +02:00
Sami Kerola 0688911ad4 last-deprecated: remove from source tree
The last/lastb(1) from sysvinit has been around for about two years,
and the better implementation is already part of releases 2.24 to 2.26.
It should be safe to remove the unused last code from the source tree.

Reference: ce60272039
Signed-off-by: Sami Kerola <sami.kerola@lastminute.com>
2015-06-29 12:05:39 +02:00
Karel Zak 7ff1162e67 sulogin: improve support for locked root account
Some installations and distributions don't use a root account password
for security reasons and use sudo instead. In that case, asking for the
password makes no sense, and it is not even considered as valid as it's just
"*" or "!".

In these cases --force is required to just start a root shell and no
ask for password.

I don't think it's a good idea to automatically start root shell when
locked account is detected. It's possible that the machine is on
public place and for example Ubuntu uses root account disabled by
default (and also Fedora when installed by yum/dnf without anaconda).

The --force option forces admins to think about it...

The distro maintainers can also use --force in their initscripts or
systemd emergency.service if they believe that promiscuous setting is
the right thing for the distro.

Addresses: https://bugs.debian.org/326678
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-25 14:17:05 +02:00
Guillem Jover 1c8beb3dfb sulogin: Use read instead of allocated size from getline()
The getline function distinguishes between the allocated and read
lenghts, and we should not mix them up, as we might end up processing
junk.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2015-06-08 12:10:05 +02:00
Karel Zak d681e0956c sulogin: don't use strcpy(), enlarge pwd line buffer
* according to "man getpwnam" 16384 bytes is enough to store one
  passwd entry (let's use 2*BUFSIZE to avoid magic numbers in code)

* don't use strcpy() to set empty password

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-25 15:24:13 +02:00
Ruediger Meier 2e81d99870 last, fix race when comparing time stamps
It is just luck if two time() calls happen within the same
second. Introduced in 31d28e09.

Actually I don't like adding another global variable but this
way we avoid bigger refactoring. IMO it's questionable why
lastdate, lastdown, etc. are initialized with current time() at
all. It looks unsafe to print "still running" always when
logout_time = now.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-03-25 10:36:52 +01:00
Ruediger Meier 568f460ca3 last: fix first (current) runlevel line
Since 744c7fec lastrch was not set to current time anymore, but we need it.

 # broken:
 $ ./last -x | grep -m 2 runlevel
 runlevel (to lvl 5)   3.11.10-25-deskt Wed Feb 18 13:11 - 01:00 (-16484+-12:-11)
 runlevel (to lvl 5)   3.11.10-25-deskt Thu Jan 22 16:50 - 13:11 (26+20:21)

 # fixed:
 $ ./last -x | grep -m 2 runlevel
 runlevel (to lvl 5)   3.11.10-25-deskt Wed Feb 18 13:11   still running
 runlevel (to lvl 5)   3.11.10-25-deskt Thu Jan 22 16:50 - 13:11 (26+20:21)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-03-25 10:36:49 +01:00
Karel Zak 744c7fecd3 last: keep array of files in main()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-13 11:47:00 +01:00
Karel Zak da1a8ed0b0 last: fix utmplist usage
last(1) uses a global list of entries, this is unnecessary and it's
also mistake because the pointer to the list is not set to NULL when
last(1) opens another utmp file. For example:

 last -f /var/log/wtmp -f /var/log/wtmp-20150220

ends with unexpected free() call or sometimes with never ending loop.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1201033
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-13 11:30:16 +01:00
Karel Zak 254743e4a6 build-sys: cleanup realtime lib usage
* check for timer_create()
* define dependence on timer_create() for flock
* rename CLOCKGETTIME_LIBS to REALTIME_LIBS

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-06 14:20:19 +01:00
Bill Pemberton a55f60a107 docs: fix some spelling errors and typos in man pages
runuser.1: fix spelling implemenation -> implementation
scriptreplay.1: fix spelling overide -> override
unshare.1: fix spelling permamently -> permanently
last.1: fix spelling preferrable -> preferable
lslogins.1: fix spelling priviliges -> privileges
hwclock.8.in: fix spelling transfered -> transferred
prlimit.1: fix typo umlimited -> unlimited
agetty.8: fix typo unnsupported -> unsupported

Signed-off-by: Bill Pemberton <wfp5p@worldbroken.com>
2015-02-27 14:48:56 +01:00
Sami Kerola cd2a6f1cfd rpmatch: use symbolic value when evaluation return codes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-02-24 12:42:06 +01:00
Sami Kerola 559a5b6cf2 sulogin, hwclock: use xusleep() instead of usleep()
As said in include/c.h the usleep() is marked as obsolete, so do the same
that most of the other util-linux calls do with this interface.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-02-10 13:21:24 +01:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Karel Zak 912a7077b2 utmpdump: don't pass parameter of type "struct utmp" by value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:40:47 +01:00
Karel Zak 863d371c83 sulogin: make sure that fallback FD is valid [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:32:42 +01:00
Karel Zak 101c5838ac su: fix mem leak in modify_environ() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:26:09 +01:00
Karel Zak 86cf1ff42a login: fix mem leak in init_environ() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:25:07 +01:00
J William Piggott b06c1ca6f8 docs: restore minus symbols in long opts
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-20 18:15:30 -05:00
J William Piggott 973252578d docs: fix-up man-pages flaged by checkmans.sh
disk-utils/sfdisk.8	Fix font escape
login-utils/vipw.8	Delete bogus macro
misc-utils/look.1	Delete bogus macro
sys-utils/prlimit.1	Delete bogus macro

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-13 11:43:46 -05:00
Benno Schulenberg 3a60b1c26b docs: remove obsolete and unneeded comments from man-page files
Transform some of them into copyright lines.
Also fix three header lines and snip some trailing whitespace.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:03:26 +01:00
Sami Kerola 7ee26cbf02 maint: fix shadow declaration
This change fixes all shadow declarations.  The worth while to mention
fix is with libfdisk sun geometry.  It comes from bitops.h cpu_to_be16
macro that further expands from include/bits/byteswap.h that has the
shadowing.

libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow]
libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow]

That could have caused earlier some unexpected results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 10:08:21 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Karel Zak 4a98629b29 chsh: keep struct options in .rodata
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-06 11:00:51 +01:00
Karel Zak 84705c8b89 chsh: simplify get_shell_list()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-06 10:57:09 +01:00
Sami Kerola 1fd15f04b3 newgrp: set function arguments read-only when possible
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 51c52acfb1 newgrp: move shell determination closer where it is used
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 477135dfec newgrp: simplify if else clauses
The 'if' clauses that have termination as either of the control flow
results will never need 'else'.  Making the termination to happen true
flow is enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:53:01 +00:00
Sami Kerola 9a5cbe5223 chsh: fail get_shell_list() check when /etc/shells cannot be opened
And get rid of stdbool.h true/false usage.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 1df0219f2c chsh: simplify check_shell()
Shell null check is redundant.  The shell can be null only after
ask_new_shell returned such, and that is checked earlier in program
logic.

Secondly the check_shell does not need to return values, in such cases
the program can simply exit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola e323df25f5 chsh: rewrite function interacting with user to get path to new shell
Rename prompt() to ask_new_shell().  Remove fixed size buffer and
allocate path to new shell, that should make Hurd people happy.  Use
strutils.h for white space trimming.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 68b24d53e1 chsh: clean up parse_argv()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola f64979233f chsh: allow user to set shell to /bin/sh if none is set
Earlier setting a /bin/sh was impossible for users that had nothing set
as shell, as that was seen as no change.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 561c48582c chsh: set few variables read-only and rename one of them
This change also improves couple variable initializations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:51 +00:00
Sami Kerola 1cb122d591 chsh: use getline() to support arbitrarily long lines
Use of fgets() can make a single long line to be understood as two
entries, and someone could play tricks with the remainder part of the
buffer.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:50 +00:00
Sami Kerola 144ae70ef3 chfn, chsh: share illegal_passwd_chars() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:50 +00:00
Sami Kerola 5eef61296f chsh: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-05 22:52:50 +00:00
Karel Zak bf6c15ed4a chfn: fix compilation without libuser
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-19 15:05:04 +01:00
Sami Kerola e88f005949 chfn: make command to obey login.defs CHFN_RESTRICT instructions
Reference: http://man7.org/linux/man-pages/man5/login.defs.5.html
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=138519
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola f723cbf544 chfn: remove set_changed_data() and add add_missing()
The add_missing() and find_field() functions are needed when input data
is incomplete, such as in case when chfn is instructed to change only
selected fields with command line options.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola d9e1ac99e4 chfn: rename prompt() to ask_new_field()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola 5fe1c32f61 chfn: move new and old finger structs to chfn control struct
This change is a little bit messy, and requires a comment the struct
finfo should not have 'struct passwd *pw' as it's member.  The earlier
struct design would have been burden to maintain, and confusing to use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola e4efecc4db chfn: clean up parse_argv()
Use switch() case ?: for all option parsing, as in most of the other
source files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola d5fdba0346 chfn: add minimalistic struct chfn_control
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:04 +00:00
Sami Kerola 58985f6712 chfn: simplify parse_passwd() by using strsep()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 496083bad6 chfn: fix usage() regression
Commit db433bf737 changed -u for --help to
-h, that is not true.  The -h is short hand for --home-phone.  And the
--version is accompanied with -v not -V.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 1b7a19ebbb chfn: use xasprintf() rather than bunch of strlen() and malloc() calls
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 5a57c00af0 chfn: rewrite prompt() to use strutils
The left and right white space trimming can be done with strutils.h
[lr]trim_whitespace() functions.

As a minor fix when user input exceeds maxium allowed gecos field length
the remaining characters in stdin are purged so that re-prompting works
correctly.

Additionally the prompt() is made to add message to check_gecos_string(),
so that there are less similar strings for translation project to deal.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 2401633559 chfn: remove function prototypes
Requires resuffling functions order they work without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 4ecc6dbb53 lslogins: use hardcoded paths from pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 77006d95db lslogins: add space to systemd journal header and message
This commit changes journal messages in individual user printout the
following way.

Dec 13 16:02:05 systemd[324]:Time has been changed	(old)
Dec 13 16:02:05 systemd[324]: Time has been changed	(new)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola cdf3896a05 lslogins: reject unknown time format arguments
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola dfd4359bb0 lslogins: fix short options
Usage is promising -e is an option alias of --export, so make it work.
And get rid of -x that was accepted, but not in use.

Long only enum member OPT_VER was probably a development time idea, that
never got to be used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola 1025d21efe lslogins: tell why command failed
Printing usage() without hint what is wrong does not help an user.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola f838efeb67 lslogins: make journald last logs time stamps to honor --time-format
This makes by default the last logs to have year in output when necessary.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Sami Kerola aa45b344d3 lslogins: allow changing password changed and expiration time formats
The password change and expiry has are marked with resolution of a day,
so add a new short iso-8601 format.  With this system admins can easily
find users has not updated their password lately

$ lslogins --time-format=iso --user --output=pwd-change,user | sort -n

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:02 +00:00
Benno Schulenberg f49ccec212 docs: don't use bold or italics for "[option]" in synopsis of man pages
As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-12-19 09:57:23 +01:00
Will Johansson ecc5632f09 login: Fix unused variables in login.c if _HAVE_UT_TV isn't defined
Wrap around the variable declaration for `tv' with ifdef so the compilers
don't warn about unused variables if we're compiling without UT_TV. This
happens with the musl libc, since it doesn't define _HAVE_UT_TV, even
though it _does_ have the ut_tv field in the utmp struct.

Signed-off-by: Will Johansson <will.johansson@gmail.com>
2014-12-18 11:02:08 +01:00
Will Johansson fe2c9909cd login-utils: Enable building util-linux against OpenPAM
OpenPAM is compatible with util-linux, with a few changes, namely
using OpenPAM's conversation function, openpam_ttyconv.

We check for Linux-PAM by querying for security/pam_misc.h, and OpenPAM
by querying for security/openpam.h.

Signed-off-by: Will Johansson <will.johansson@gmail.com>
2014-12-15 10:16:03 +01:00
Karel Zak 0d75c73d4f lslogins: fix -l -g logic
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-12 15:17:19 +01:00
Sami Kerola 228bb39a5e lslogins: align usage() and manual with struct option longopts
Short option -G goes together with long option --supp-groups, while
neither of -m or --groups-info has worked in a release so remove them
from usage() and manual.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:41 +01:00
Sami Kerola 123f0f5bf0 lslogins: fix assertion failure for none existing logins
This cange makes the following to retun none-zero value instead of a core
dump.

$ lslogins qwertyuiopasdfghjklzxcvbnm1234567
lslogins: libsmartcols/src/line.c:362: scols_line_get_cell: Assertion `ln' failed.
Aborted (core dumped)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:39 +01:00
Sami Kerola 58fbb9b2d5 login-utils: use libc error printing facility
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:20 +01:00
Karel Zak 6f7eba20af login: ignore SIGXFSZ when write to lastlog
the lastlog file is huge and on systems with large UIDs, it's so huge that
it generates SIGXFSZ when the FSIZE limit is too small.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1165702
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 15:45:42 +01:00
Karel Zak cd2876d252 build-sys: move all around clock_gettime() to monotonic.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 11:54:47 +01:00
Karel Zak 8fc4a88630 build-sys: properly check for -lrt
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 11:05:14 +01:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola 7d2600e2d0 docs: update deprecation banners
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:11 +02:00
pcpa 1d966345df su: print proper core dump message when killed
An example is, in one terminal "sudo su -; echo $$", and in
another terminal, "kill -9  $PID" (the pid of the su -). It
should not print "(core dumped)", unless the kill signal
specified so, e.g. kill -7 or kill -11.

Signed-off-by: pcpa <paulo.cesar.pereira.de.andrade@gmail.com>
2014-10-01 10:23:48 +02:00
Benno Schulenberg ee7ea5c85e textual: use a somewhat clearer and more standard failure message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-01 09:37:04 +02:00
Karel Zak 30ea015b87 lslogins: cleanup after error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-26 11:23:32 +02:00
Sami Kerola 453fc7165d textual: share crypt() error message in sulogin and newgrp
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:03 +01:00
Sami Kerola 8f663a674d newgrp: avoid use of obsolete getpass() function
Read a password from user with termios, and once the password data is no
longer needed ensure it gets overwrote before unallocating memory.

Reference: http://man7.org/linux/man-pages/man3/getpass.3.html
Reference: https://www.securecoding.cert.org/confluence/display/seccode/MSC06-C.+Beware+of+compiler+optimizations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:03 +01:00
Sami Kerola c829aebc39 newgrp: use libc function to read gshadow if it is available
The glib versionf of getsgnam() is using /etc/nsswitch.conf, allowing the
group passwords to come from external database.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:02 +01:00
Sami Kerola d4ce90d47c last: improve code readability by renaming variable names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Sami Kerola 8813da1ea2 last: make is_phantom() when kernel config does not include audit support
When kernel CONFIG_AUDIT is not set the /proc/<pid>/loginuid information
is not present resulting live sessions to be marked 'gone - no logout' in
last(1) print out.  To go-around this change makes last(1) to look
/dev/<tty> device ownership as a substitute of loginuid.

The go-around seems to work fairly well, but it has it short comings.
For example after closing a X window session the /dev/ttyN file seems to
be owned by root, not the user who had it before entering to the X
session.  While that is suboptimal it is still better than an attmempt to
determine uid_t by looking owner of the /proc/<struct utmp ut_pid>, that
is a login(1) process running as root.

The issue was found using Archlinux installation.

$ pacman -Qi linux
Name           : linux
Version        : 3.16-2
[...]
Build Date     : Mon Aug 4 18:06:51 2014

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Benno Schulenberg b45413a860 docs: bring the runuser and su man pages closer to standard formatting
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-29 12:14:58 +02:00
Benno Schulenberg 75ca43bbb2 docs: give the man page of utmpdump the proper User Commands header
Also bring the formatting closer to standard.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-29 12:14:58 +02:00
Benno Schulenberg bf967a6cab docs: improve the formatting of the chfn and chsh man pages
Also fix a pasting mistake where the chfn man page suggested
to use ypchsh or lchsh for non-local entries.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-29 12:14:57 +02:00
Benno Schulenberg 09af3db48e textual: fix some typos and inconsistencies in various messages
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-23 08:56:00 +02:00
Karel Zak ccef45168b Merge branch 'master' of https://github.com/yurchor/util-linux
* 'master' of https://github.com/yurchor/util-linux:
  Fix typos in user visible messages
2014-07-22 12:01:50 +02:00
Karel Zak 3df45c7cdc Merge branch 'ioclt' of https://github.com/lanurmi/util-linux 2014-07-22 11:58:21 +02:00
Karel Zak 87a144a502 lslogins: more robust usage of columns[]
For more details see commit dcc8dbdc8137cb3da5100158639b565565b89875.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:51:01 +02:00
Karel Zak fa936c9f9b sulogin: don't use uninitialized struct sigaction [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 14:47:20 +02:00
Karel Zak c210324c67 sulogin: check result of the open() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 14:42:00 +02:00
Karel Zak 2e118e709b last: fix is_phantom() logic [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 14:39:11 +02:00
Benno Schulenberg 1000a59543 docs: improve the formatting and wording of two man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-17 14:00:50 +02:00
Karel Zak bdba3fd9b5 lslogins: make --notruncate more robust
- keep coldescs[] read-only
 - don't expect that only COL_GECOS uses truncate flag

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-16 11:25:03 +02:00
Karel Zak 4b6ae07123 lslogins: add --noheadings
That's fatal mistake that this option which is required for script
is missing.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-16 11:19:20 +02:00
Karel Zak 37019cbc27 lslogins: use bit-array, cleanup SELinux code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-16 11:09:42 +02:00
Sami Kerola 0e65dcde88 textual: fix some typos
Found with misspell-check version 2.0d.

Reference: https://github.com/lyda/misspell-check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:21:02 +01:00
Lauri Nurmi a5c523a0e7 Fix typo "ioclt" in various files. 2014-07-11 22:52:09 +03:00
Yuri Chornoivan b5af3ee835 Fix typos in user visible messages 2014-07-03 09:33:15 +03:00
Benno Schulenberg b8ec0ab712 lslogins: improve the columns information
Some fixes for typos, whitespace and wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-06-30 10:21:43 +02:00
Benno Schulenberg ce969b16f0 lslogins: improve wording and formatting of the man page
Some typos, spacing, line breaks, and missing optional arguments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-06-30 10:21:27 +02:00
Samuel Thibault 88e0f3df66 build-sys: fixes for non-Linux systems
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-19 10:35:23 +02:00
Ruediger Meier 18df1cc77c utmpdump: fix localtime() error handling
If current TZ has no representation of a given time_t then localtime()
would return NULL and break the next strftime().

In practice this happens very likely on systems with 64bit time_t when
parsing broken binary data. Seen on aarch64 (and probably s390) using
our (incompatible) test wtmp data.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-06-11 23:06:32 +02:00
Karel Zak 710ed55dcd libsmartcols: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 13:47:06 +02:00
Karel Zak 27e6e446b9 lslogins: fix pretty-print columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 15:08:26 +02:00
Karel Zak b3f4f05632 lslogins: cleanup some command line options
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 15:05:10 +02:00
Karel Zak 8b13a4d89d lslogins: cleanup default outputs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 14:48:45 +02:00
Karel Zak ed374569ae lslogins: cleanup -a output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 14:17:41 +02:00
Karel Zak d4aa0ff138 lslogins: improve COL_PWD_WARN and COL_NPROCS desc
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 13:37:58 +02:00
Karel Zak 74fddd8623 lslogins: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 13:32:03 +02:00
Karel Zak f7aea533f4 lslogins: fix nologins check
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 13:24:35 +02:00
Karel Zak ea24eacc6b lslogins: cleanup time formats
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 13:21:57 +02:00
Karel Zak f47c6d3a59 lslogins: clean up password hash check
* rename to PWD-* column names
 * add PWD-DENY for accounts where is no possible to login by password
 * PWD-LOCK (was LOCKED) checks for valid but locked pawwords
 * LOGIN renamed to USER

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 12:48:40 +02:00
Karel Zak d8b2ddb7bb lslogins: remove --sort-by-name
If we really need a sort functionality hardcoded into lslogins(1) then we need
a generic sort options (like for lsblk,--sort <column>).

Note that it seems that "lslogins | sort --key <col>" is good enough for now as
lslogins(1) does not convert any data to human readable non-precise format (like
for example lsblk SIZE column etc.).

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 11:46:56 +02:00
Karel Zak 1624245ffe lslogins: improve nologins and shadow usage
* fix coding style
 * don't require shadow entries
 * check for /var/run/nologin

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-29 11:30:26 +02:00
Karel Zak f37b357b47 lslogins: print systemd journal logs
Co-Author: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-27 17:34:15 +02:00
Ondrej Oprala d3a93df80d lslogins: count per-user processes
[kzak@redhat.com: - rename column, align to right]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-27 17:01:05 +02:00
Karel Zak 56c8f8af4c lslogins: add FAILED-LOGIN to pretty output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-16 14:14:02 +02:00
Karel Zak 512abd5694 lslogins: sync man page and usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-16 14:04:54 +02:00
Karel Zak 10c74524e5 lslogins: improve pretty output
* use Yes/No
 * print all available information (columns)
 * cleanup code

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-16 12:35:46 +02:00
Karel Zak 3e5cba73f1 lslogins: NLS for all messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-16 11:41:18 +02:00
Karel Zak 8b5e227978 lslogins: conding style changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-16 11:31:00 +02:00
Karel Zak 68657ea2e7 lslogins: improve supplementary groups code, add SUPP-GIDS
* don't build list, but directly create a string
 * don't mix IDs and group names on output
 * add SUPP-GIDS to print only IDs

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-16 11:14:32 +02:00
Karel Zak 07a4046f95 lslogins: align to right 0|1 columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-15 14:10:50 +02:00
Karel Zak a94baf36dc lslogins: cleanup status[] usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-15 14:01:51 +02:00
Karel Zak 5424d2a225 lslogins: cleanup fill_table()
* check xasprintf() return code is unnecessary
 * just check all scols_line_set_data() return codes on one place

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-15 13:56:00 +02:00
Ondrej Oprala 3a016a536b lslogins: mention --time-format in usage
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:56:00 +02:00
Ondrej Oprala 32badc3466 lslogins: fix option exclusivity
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:56:00 +02:00
Ondrej Oprala c20ffb8f69 lslogins: add option --time-format
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:56:00 +02:00
Ondrej Oprala 969ee9e3ff lslogins: comment-in an expensive realloc
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:56:00 +02:00
Ondrej Oprala 4ea7848b50 lslogins: add option --iso
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:56:00 +02:00
Ondrej Oprala 384965928a lslogins: add support for multiple time formats
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Ondrej Oprala c77108b867 lslogins: pretty printing and extended -l,-g 2014-05-15 13:55:59 +02:00
Ondrej Oprala c6cf4d1c46 lslogins: make it work
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Ondrej Oprala 1ebfc60a0f lslogins: use thread-safe functions
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Ondrej Oprala dd7760a8c1 lslogins: store users in a tree
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Ondrej Oprala 29cc2a5568 lslogins: add functionality
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Ondrej Oprala 78dd745089 login: extract get_hushlogin_status
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Ondrej Oprala 914e20a00a lslogins: move to login-utils
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Werner Fink b9c7390948 agetty: beside virtual consoles support xvc and hvc device lines as well
For this approach do not use the ioctl TIOCMGET anymore as this
is for real serial lines only. But switch over to use the ioctl
KDGKBMODE as this is unique to the virtual console lines only.

Signed-off-by: Werner Fink <werner@suse.de>
2014-05-13 10:40:11 +02:00
Werner Fink f2bcda5183 agetty: better support of the special system consoles on S390
That is that there are several consoles, the /dev/ttyS0 which
is type of ibm3215 and a dumb terminal, then there is the device
/dev/3270/tty1 which can handle ANSI color escape sequences and is
a ibm327x terminal, and the /dev/ttyS1 which is a vt220 terminal.

The macro is_speed() in agetty.c allows to distinguish between the
terminal line (/dev)3270/tty1 and the speed options on the command
line used in

/run/systemd/generator/getty.target.wants/serial-getty@3270-tty1.service

which is a symbolic link to /usr/lib/systemd/system/serial-getty@.service

Signed-off-by: Werner Fink <werner@suse.de>
2014-05-13 10:39:40 +02:00
Werner Fink 624b204d7b sulogin: find a suitable console device
Enable sulogin to find a suitable console device even if the first line
in /proc/consoles does not have any major and minor number.

Signed-off-by: Werner Fink <werner@suse.de>
2014-05-13 10:38:06 +02:00
Werner Fink bb280f79f1 agetty: avoid that agetty nor sulogin are fooled by a running plymouth
The nowadays used plymouth locks the devices used for the system
console which causes that agetty as well as sulogin can not modify
the termios settings of e.g. the serial devices of the systenm console.

Signed-off-by: Werner Fink <werner@suse.de>
2014-05-13 10:36:49 +02:00
Ruediger Meier 6e69f1ee0f last: avoid leading "-" before "no logout"
This affects option --time-format=notime.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-10 15:17:42 +02:00
Ruediger Meier 4fcbfaa81d last: minor cleanup if statements
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-08 22:14:27 +02:00
Ruediger Meier f16d5044e1 last: --time-format=full should do the same like -F
For no reason "full" did something else than "iso" or -F as you
see here:
$ ./last  -f ../tests/ts/last/wtmp.LE  --time-format=full  | grep -A2 "no logout"
torvalds linux        hobby            Mon Aug 26 02:57:08 1991    gone                    - no logout
reboot   system boot  system-name      Wed Aug 28 20:00:00 2013   still                    running
reboot   system boot  system-name      Wed Aug 28 18:00:00 2013 - Wed Aug 28 19:00:00 2013  (01:00)
$ ./last  -f ../tests/ts/last/wtmp.LE  --time-format=iso  | grep -A2 "no logout"
torvalds linux        hobby            1991-08-26T02:57:08+0200   gone - no logout
reboot   system boot  system-name      2013-08-28T20:00:00+0200   still running
reboot   system boot  system-name      2013-08-28T18:00:00+0200 - 2013-08-28T19:00:00+0200  (01:00)
$ ./last  -f ../tests/ts/last/wtmp.LE  -F  | grep -A2 "no logout"
torvalds linux        hobby            Mon Aug 26 02:57:08 1991   gone - no logout
reboot   system boot  system-name      Wed Aug 28 20:00:00 2013   still running
reboot   system boot  system-name      Wed Aug 28 18:00:00 2013 - Wed Aug 28 19:00:00 2013  (01:00)

Also note the useless leading space before "gone"

The only thing which matters is fmt->out width when printing these
strings like "still running". Now ctl->fulltime flag is unsused and
removed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-08 22:14:06 +02:00
Ruediger Meier d3108db19e last: fix uninitialized length
length was unset when using "last --time-format=iso"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-07 14:42:36 +02:00
Karel Zak 08ca3e26a8 lib/timeutils: remove get_boot_time from libcommon
clock_gettime() needs -lrt, so let's keep this stuff
outside libcommon.la

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 13:16:05 +02:00
Bjarni Ingi Gislason 802cb7db71 chsh: Improve the typesetting of the manual
Protect a full stop (.), that begins or ends a string, with \&

  Change '-' to '\-', if it indicates an option

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2014-05-06 11:57:01 +02:00
Bjarni Ingi Gislason b5fff5211b chfn: Improve the typesetting of the manual
Change comma (,) to a period (.) as it is the control character

  Use macro RB instead of the reverse one (BR)

  Add missing [ in front of  an (optional) option

  Protect a full stop (.), that begins or ends a string, with \&

  Change '-' to '\-', if it indicates an option

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2014-05-06 11:56:49 +02:00
Sami Kerola 0e5218acd9 last: fix is_phantom() detection
The /proc/<pid>/loginuid is not always available, and when so a running
session should not be determined to be gone.  This is a regression from
commit mentioned in reference.

Sessions that have started before previous system boot, and did not log
out meanwhile, will be marked as gone.  It is fair to say that these
sessions are most likely result of a wtmp corruption.

Reference: 404fa3f93c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Ondrej Oprala 46e0dd136f vipw: minor man page improvements
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 13:46:01 +02:00
Ondrej Oprala fd2e45b78e nologin: minor man page improvements
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 13:45:59 +02:00
Ondrej Oprala 38e3e66f70 utmpdump: minor man page improvements
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 13:45:59 +02:00
Ondrej Oprala 20400eb4a6 sulogin: minor man page improvements
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 13:45:58 +02:00
Ondrej Oprala 2b5e13351f su: fix minor typos in the man page
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 13:45:57 +02:00
Ondrej Oprala 96b65fb3ce runuser: fix minor typos in the man page
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 13:45:55 +02:00
Ondrej Oprala 9fb4d0138a last: fix minor typos in the man page
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-14 13:45:54 +02:00
Ondrej Oprala 3aca66a54d login: fix minor typos in the man page
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-07 12:38:17 +02:00
Karel Zak 78a3b0af30 include/carefulputc: cleanup and add fputs_{quoted,nonblank}()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Karel Zak 270ab78a0c su: don't use kill(0, ...) when propagate signal
The current code uses kill(0, caught_signal) after regular
signal cleanup and before exit (all just to make shells happy).

Unfortunately, kill(0, ...) is a bad idea. It seems better to use
kill(getpid(), ...) otherwise we kill our parent process too.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1063887
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-17 13:22:30 +01:00
Sami Kerola 404fa3f93c last: make session gone determination more robust
Earlier determination that used kill with signal zero to pid was prone to
false positive reports, due reuse of pid space and unrelated processes.
New function is_phantom() tries do a little bit better job, but fails to
be perfect.  It seems linking to gether utmp session start time or
terminal id with /proc/<pid>/ information is not as simple as one might
hope.

Reported-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-02-10 18:25:31 +01:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:04:14 +01:00
Ville Skyttä d640dd9421 man: Syntax and spelling fixes.
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2014-01-06 08:55:09 +01:00
Karel Zak 3deb67f50d sulogin: use dirent->d_type when scans /dev
... it's more effective than call fstatat() for all device.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-12 12:26:13 +01:00
Karel Zak 9e480be7ac chsh, chfn: add info about non-local support to the man pages
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-11 09:18:18 +01:00
Karel Zak d0c10f7df9 su: add info about pam_lastlog to su.1
References: https://bugzilla.redhat.com/show_bug.cgi?id=1021108
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-21 14:27:30 +02:00
Benno Schulenberg b4362b6f84 docs: standardize the phrases for --help and --version in all man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-15 10:28:30 +02:00
Benno Schulenberg 60541961fc docs: improve grammar, wording and formatting of su man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-14 14:55:23 +02:00
Benno Schulenberg 06953a2e24 docs: sort options in last man page alphabetically
And use the option formatting with macros.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-14 14:55:23 +02:00
Benno Schulenberg 2a473f5f16 docs: tweak wording and formatting of last man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-14 14:55:22 +02:00
Benno Schulenberg 4fcac79b51 last: remove mistaken -F, --fullnames entry from the man page
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-14 14:54:50 +02:00
Benno Schulenberg 47481cbd01 textual: standardize some "cannot read" and "seek failed" error messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-09 11:37:38 +02:00
Benno Schulenberg 1ebc015ee5 su-common: pluralize one message
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:30 +02:00
Karel Zak 0e8edc9f9e su: fix caught_signal logic and initialize oldact [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-02 14:43:17 +02:00
Karel Zak 85dd024d84 utmpdump: make analyzers happy
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-01 17:11:25 +02:00
Karel Zak d879e0529c last: check fstat() return [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-01 16:59:43 +02:00
Karel Zak 88407b9321 nologin: add new command
Currently it's maintained as distro specific (or people use impolite
/bin/false way).

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-30 13:36:26 +02:00
Karel Zak bccc956df3 build-sys: fix lastb symlink
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-27 14:02:58 +02:00
Karel Zak f2bf736868 last: fix man page groff warning
tbl:<standard input>:166: column separation specified for last column

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-26 11:31:17 +02:00
Karel Zak 60f25deae7 lib: rename time-util.c to timeutils.c, fix headers
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-10 13:11:02 +02:00
Sami Kerola bce5163b68 last: fix memory leak
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-10 12:57:31 +02:00
Karel Zak 9b5dc4cb8d su: fix lastlog and btmp logging
The su(1) logging code mix ups "old" and "new" passwd structs. The
result is things like

	Sep  9 11:50:45 x2 su: (to kzak) kzak on none

in /var/log/messages. The right log entry is

	Sep  9 11:50:45 x2 su: (to root) kzak on pts/3

The bug has been introduced by commit c74a7af17c.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1005194
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-09 12:37:34 +02:00
Karel Zak 2ea747ebf1 last: --fulltime and --time-format are mutually exclusive
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-02 11:42:44 +02:00
Karel Zak c87e4fbbf4 last: consolidate time formatting to one struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-02 11:28:43 +02:00
Karel Zak ee24e58f86 last: use bit array
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-02 11:11:38 +02:00
Sami Kerola ee508c153f utmpdump: make IPv6 addresses work
(unless bug[s]) This change is backwards compatibile.  Earlier binary to
text dumps can be converted back to binary, or otherway around.

The only thing that will not work are IPv6 addresses that possible
earlier conversion had broke.  Such conversions resulted with random IPv4
in place of IPv6 address in text format, and original information is gone
forever.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:10 +01:00
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
Sami Kerola 31d28e0951 last: tell verbally system is still running
Use of uptime time stamp as previous boot login time makes the output not
constant, which is rather difficult to test.  Verbal message 'system is
still running' makes testing easy, and noticing which boot is still
running clear to a person.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:10 +01:00
Sami Kerola 97bbb5e41c last: trim trailing white spaces
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:10 +01:00
Sami Kerola 438269dca9 last: never restrict session time
When a session time will reach whopping 10000 days the last round bracket
is unnecessarily removed from output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:09 +01:00
Sami Kerola 4440390ef0 docs: add --time-format to last(1) manual page
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:09 +01:00
Sami Kerola 45f11b6bf7 last: add --time-format with iso-8601 format
The ISO-8601 format makes consuming time stamps easy with various
parsers.  The format includes time zone information which is crucial when
an investigator is trying to make sense outputs collected from systems
all a across planet.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:09 +01:00
Sami Kerola 83484375f2 last: use configuration struct
This allows reducing global variables and will minimize number of
arguments for functions making code a little bit easier to read, and
maintain.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:09 +01:00
Sami Kerola 4e01db8842 last: fix --present option logic error
Printing of sessions 'still logged in' was skipped because an error in
logic.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:09 +01:00
Sami Kerola 36f5c80a40 docs: add --since and time option formats to last(1) manual
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:08 +01:00
Sami Kerola dd50168b91 last: add --since time spec option
The --since and --until options are companions often needed together.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:08 +01:00
Sami Kerola 75ab9bf1eb lib/time-util: move YYYYMMDDHHMMSS to common parser
Even while the YYYYMMDDHHMMSS time format it not magnificent it is best
to make it to be part of the one, and only, time format parser.

Proposed-by: Karel Zak <kzak@redhat.com>
References: http://markmail.org/message/6baqt4ttkopu7ra6
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:08 +01:00
Sami Kerola 3a4ae395a4 last: parse easy to use time formats
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:08 +01:00
Sami Kerola 2af00c40a6 docs: add --present to last(1) manual page
I forgot to update manual after writing this functionality.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:07 +01:00
Sami Kerola 30faa20244 last: fix typo
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-29 18:14:06 +01:00
Karel Zak fb4edda749 su: suppress PAM info messages for -c or non-login sessions
The 'Last login:' messages from PAM lastlogin module is unexpected
for non-login sessions or when -c <command> executed.

For example:

  $ su - -c id
  Last login: Wed Jul 24 08:36:28 CEST 2013 from dhcp-25-161.brq.redhat.com on pts/18
  uid=0(root) gid=0(root) skupiny=0(root)

this makes 'su' useless in scripts.

This patch suppress all PAM_TEXT_INFO messages for -c and for
non-login session ('-' is not specified) after pam_authenticate() and
pam_acct_mgmt().

Note that the new PAM conversation function checks the first message
in the msg[] array only. It seems good enough as PAM internally uses
pam_info() function that does not use multiple messages for one conv
call.

References: https://bugzilla.redhat.com/show_bug.cgi?id=987787
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-27 11:49:13 +02:00
Karel Zak b86727542f last: mention optional arguments in usage
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-23 12:01:01 +02:00
Sami Kerola 37f534a667 last: add --present option
The --present option will allow user to easily determine who where logged
in at a given time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 11:45:42 +02:00
Sami Kerola 7ec7822965 last: allow --file to be defined multiple times
This is useful when an admin is trying to find something, and has to
process all available data.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 11:31:34 +02:00
Sami Kerola 751947b6fc last: global variables are initialize automatically to zero
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 10:59:03 +02:00
Sami Kerola 328734c048 last: use as narrow variable scoping as possible
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 10:59:02 +02:00
Sami Kerola f65833b930 last: remove broken code
Comment in the deletion tells everything necessary.

"This doesn't work on modern systems, where only a DNS lookup of the
result from hostname() will get you the domainname.  Remember that
domainname() is the NIS domainname, not DNS.  So basically this whole
piece of code is bullshit."

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 10:59:00 +02:00
Sami Kerola e843d04753 last: prefer enum rather than #definition list
Incremental number lists are more hard to get wrong with enum, and they
are nicer to debug as for example gdb is aware of these symbolic names.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 10:58:59 +02:00
Sami Kerola 5cae90f9d1 last: make switch cases complete, and inform if impossible occurs
Some of the ut_type numbers does not seem to be recognized by last(1) so
they are, at least for now, silently ignored.  See glibc documentation
for information what the ignored EMPTY, INIT_PROCESS, LOGIN_PROCESS, and
ACCOUNTING mean.

Reference: FIXME
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-23 10:58:57 +02:00