From 4226f910d45455856ee5b9855d1d9ce39b513aad Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Sun, 23 Dec 2012 22:44:05 +0100 Subject: [PATCH] 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 Signed-off-by: Karel Zak --- login-utils/sulogin-consoles.c | 8 ++++++-- login-utils/sulogin-consoles.h | 7 +++++++ login-utils/sulogin.c | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c index 3729be4485..e1d36711c0 100644 --- a/login-utils/sulogin-consoles.c +++ b/login-utils/sulogin-consoles.c @@ -98,7 +98,6 @@ static uint32_t emergency_flags; # define MNT_PROCFS 0x0001 # define MNT_DEVTMPFS 0x0002 -static __attribute__((__destructor__)) void emergency_do_umounts(void) { if (emergency_flags & MNT_DEVTMPFS) @@ -107,7 +106,6 @@ void emergency_do_umounts(void) umount2("/proc", MNT_DETACH); } -static __attribute__((__constructor__)) void emergency_do_mounts(void) { struct stat rt, xt; @@ -143,6 +141,12 @@ void emergency_do_mounts(void) } } } + +#else /* !USE_SULOGIN_EMERGENCY_MOUNT */ + +void emergency_do_umounts(void) { } +void emergency_do_mounts(void) { } + #endif /* USE_SULOGIN_EMERGENCY_MOUNT */ /* diff --git a/login-utils/sulogin-consoles.h b/login-utils/sulogin-consoles.h index c713bad1d9..c2f95eac79 100644 --- a/login-utils/sulogin-consoles.h +++ b/login-utils/sulogin-consoles.h @@ -21,6 +21,8 @@ * * Author: Werner Fink */ +#ifndef UTIL_LINUX_SULOGIN_CONSOLES_H +#define UTIL_LINUX_SULOGIN_CONSOLES_H #include #include @@ -45,3 +47,8 @@ struct console { extern int detect_consoles(const char *device, int fallback, struct list_head *consoles); + +extern void emergency_do_umounts(void); +extern void emergency_do_mounts(void); + +#endif /* UTIL_LINUX_SULOGIN_CONSOLES_H */ diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c index 1a47e740f8..02fa8db57c 100644 --- a/login-utils/sulogin.c +++ b/login-utils/sulogin.c @@ -834,6 +834,10 @@ int main(int argc, char **argv) mask_signal(SIGINT, SIG_IGN, &saved_sigint); mask_signal(SIGHUP, SIG_IGN, &saved_sighup); + + emergency_do_mounts(); + atexit( emergency_do_umounts ); + /* * See if we need to open an other tty device. */ -- 2.47.2