From: Karel Zak Date: Tue, 13 Oct 2009 12:22:33 +0000 (+0200) Subject: swapon: more robust progname probing X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01373d74ef13014262d599cd9c26c1ec724a2204;p=util-linux 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 --- 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); }