From 01373d74ef13014262d599cd9c26c1ec724a2204 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 13 Oct 2009 14:22:33 +0200 Subject: [PATCH] swapon: more robust progname probing Currently, the 'swapoff' is the default behavior. It means that if you have a libtool wrapper script in your build directory the executed binary name is 'lt-swapon' and then "swapon -a" is interpreted as "swapoff -a". Any random argv[0] should not be interpreted as "swapoff". Signed-off-by: Karel Zak --- mount/swapon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mount/swapon.c b/mount/swapon.c index d89c6a96..a66d59d6 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -791,6 +791,9 @@ main(int argc, char *argv[]) { if (streq(progname, "swapon")) return main_swapon(argc, argv); - else + else if (streq(progname, "swapoff")) return main_swapoff(argc, argv); + + errx(EXIT_FAILURE, _("'%s' is unsupported program name " + "(must be 'swapon' or 'swapoff')."), progname); } -- 2.39.5