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 <kzak@redhat.com>
This commit is contained in:
Karel Zak 2009-10-13 14:22:33 +02:00
parent d08cd85fad
commit 01373d74ef
1 changed files with 4 additions and 1 deletions

View File

@ -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);
}