]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sulogin: don't use {de,con}structor attributes
authorKarel Zak <kzak@redhat.com>
Sun, 23 Dec 2012 21:44:05 +0000 (22:44 +0100)
committerKarel Zak <kzak@redhat.com>
Sun, 23 Dec 2012 21:44:05 +0000 (22:44 +0100)
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>
login-utils/sulogin-consoles.c
login-utils/sulogin-consoles.h
login-utils/sulogin.c

index 3729be44851ce7f3404a831938d3058bca62b90a..e1d36711c00c11f4aa230fd1489122893946e6b3 100644 (file)
@@ -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 */
 
 /*
index c713bad1d96ecf80dcf3f9baba15a5b5f62bb483..c2f95eac7984138607ac5cb4c8676642e85610a7 100644 (file)
@@ -21,6 +21,8 @@
  *
  * Author: Werner Fink <werner@suse.de>
  */
+#ifndef UTIL_LINUX_SULOGIN_CONSOLES_H
+#define UTIL_LINUX_SULOGIN_CONSOLES_H
 
 #include <sys/types.h>
 #include <stdint.h>
@@ -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 */
index 1a47e740f8fda2405050a81b43e6e214a5869c2b..02fa8db57cb52e9fbf1e8716cace399b41c09cbe 100644 (file)
@@ -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.
         */