Commit Graph

23 Commits

Author SHA1 Message Date
Yuri Chornoivan 311e33afef Fix minor typos 2020-07-09 20:14:32 +03:00
Sami Kerola 71f207a5f5
sulogin: reduce vulnerability surface
Hopefully these changes are unreachable code, but better safe than sorry
when dealing with setuid root code that is installed everywhere.  Quite
obviously the introduced abort() calls protect from impossible inputs.

Secondly set all possible data to be read-only in attempt to make it more
difficult to alter anything at all.

Reference: https://www.securecoding.cert.org/confluence/display/c/DCL00-C.+Const-qualify+immutable+objects
Reviewed-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Karel Zak 5d74cf0092 lib/list: remove LIST_HEAD macro
* the variable definition with hidden type is always horrible, for
  example:

	  int func() {
	    LIST_HEAD(foo);
	    ...
	  }

  the more readable is:

          int func() {
            struct list_head foo;

            INIT_LIST_HEAD(&foo);
            ...
          }

* the name LIST_HEAD conflict with /usr/include/sys/queue.h

* we use it only on two places in sulogin

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-05 11:54:59 +01:00
Ruediger Meier 223939d95b misc: spelling, always use "cannot" instead of "can not"
Just to be consistent ...

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-11-30 14:56:50 +01:00
Sami Kerola b236e43ef0 sulogin: remove __nonnull__ function attribute
This change fixes compiler option -Werror=nonnull option warning:

login-utils/sulogin-consoles.c: In function 'append_console':
login-utils/sulogin-consoles.c:324:14: warning: nonnull argument 'consoles'
compared to NULL [-Wnonnull-compare]

The NULL check done with list_empty() looks valid, so  it is best to remove
the function attribute that allows compiler to optimize the check away.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-14 12:28:53 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02: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 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
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
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
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 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
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
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 8bd6450375 sulogin: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-09 14:32:05 +02:00
Sami Kerola 21c4058d92 sulogin: fix memory leak [clang-analyzer]
And make code a little bit more robust.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-09 14:25:13 +02:00
Karel Zak a303e047bb sulogin: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-17 17:23:26 +02:00
Karel Zak 5ad0923904 remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-20 14:40:19 +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 4226f910d4 sulogin: don't use {de,con}structor attributes
We're not Russian roulette players, so don't use such ugly things at all..

Reported-by:  Dave Reisner <d@falconindy.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23 22:44:05 +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