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>
* 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>
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>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
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>
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>
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>
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>
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>
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>
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>
- 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>