diff options
author | Karel Zak | 2019-04-16 15:14:13 +0200 |
---|---|---|
committer | Karel Zak | 2019-04-16 15:14:13 +0200 |
commit | 2c308875a7fa1aaa44892c368f6b37bcfcb8879a (patch) | |
tree | 157ea7afca59059676dbcc25133dd196d1e45fb8 /login-utils | |
parent | include/c: add print_version() macro (diff) | |
download | kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.tar.gz kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.tar.xz kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.zip |
misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils')
-rw-r--r-- | login-utils/chfn.c | 6 | ||||
-rw-r--r-- | login-utils/chsh.c | 5 | ||||
-rw-r--r-- | login-utils/islocal.c | 2 | ||||
-rw-r--r-- | login-utils/last.c | 5 | ||||
-rw-r--r-- | login-utils/login.c | 3 | ||||
-rw-r--r-- | login-utils/logindefs.c | 2 | ||||
-rw-r--r-- | login-utils/lslogins.c | 5 | ||||
-rw-r--r-- | login-utils/newgrp.c | 5 | ||||
-rw-r--r-- | login-utils/nologin.c | 4 | ||||
-rw-r--r-- | login-utils/su-common.c | 6 | ||||
-rw-r--r-- | login-utils/sulogin.c | 8 | ||||
-rw-r--r-- | login-utils/utmpdump.c | 6 | ||||
-rw-r--r-- | login-utils/vipw.c | 5 |
13 files changed, 25 insertions, 37 deletions
diff --git a/login-utils/chfn.c b/login-utils/chfn.c index c5312fa0c..a2e6e099e 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -176,8 +176,7 @@ static void parse_argv(struct chfn_control *ctl, int argc, char **argv) status += check_gecos_string(_("Home Phone"), optarg); break; case 'v': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case 'u': usage(); default: @@ -412,7 +411,8 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); /* both for messages and for iscntrl() below */ bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); + uid = getuid(); /* check /etc/login.defs CHFN_RESTRICT */ diff --git a/login-utils/chsh.c b/login-utils/chsh.c index c267c7272..9b2761157 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -166,8 +166,7 @@ static void parse_argv(int argc, char **argv, struct sinfo *pinfo) while ((c = getopt_long(argc, argv, "s:lhuv", long_options, NULL)) != -1) { switch (c) { case 'v': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case 'u': /* deprecated */ case 'h': usage(); @@ -264,7 +263,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); parse_argv(argc, argv, &info); if (!info.username) { diff --git a/login-utils/islocal.c b/login-utils/islocal.c index 7c4e775c1..469bc5629 100644 --- a/login-utils/islocal.c +++ b/login-utils/islocal.c @@ -91,7 +91,7 @@ int is_local(const char *user) #ifdef TEST_PROGRAM int main(int argc, char *argv[]) { - atexit(close_stdout); + close_stdout_atexit(); if (argc <= 2) { fprintf(stderr, _("Usage: %s <passwordfile> <username>...\n"), argv[0]); diff --git a/login-utils/last.c b/login-utils/last.c index 303adeacd..2f7d9d48f 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -939,7 +939,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); /* * Which file do we want to read? */ @@ -954,8 +954,7 @@ int main(int argc, char **argv) usage(&ctl); break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'R': ctl.showhost = 0; break; diff --git a/login-utils/login.c b/login-utils/login.c index ab819f16f..a2d2725a6 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -1196,8 +1196,7 @@ int main(int argc, char **argv) break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case HELP_OPTION: usage(); default: diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c index 07a977660..2b505d255 100644 --- a/login-utils/logindefs.c +++ b/login-utils/logindefs.c @@ -403,7 +403,7 @@ int get_hushlogin_status(struct passwd *pwd, int force_check) int main(int argc, char *argv[]) { char *name, *type; - atexit(close_stdout); + close_stdout_atexit(); if (argc <= 1) errx(EXIT_FAILURE, "usage: %s <filename> " diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index c913cf2d8..efb20a4f7 100644 --- a/login-utils/lslogins.c +++ b/login-utils/lslogins.c @@ -1425,7 +1425,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); ctl->time_mode = TIME_SHORT; @@ -1528,8 +1528,7 @@ int main(int argc, char *argv[]) ctl->time_mode = parse_time_mode(optarg); break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'Z': { #ifdef HAVE_LIBSELINUX diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 453883148..5e4b4caa0 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -196,13 +196,12 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (ch) { case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/login-utils/nologin.c b/login-utils/nologin.c index b0b6a721c..14a091715 100644 --- a/login-utils/nologin.c +++ b/login-utils/nologin.c @@ -54,10 +54,8 @@ int main(int argc, char *argv[]) switch (c) { case 'h': usage(); - break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_FAILURE; + print_version(EXIT_FAILURE); /* yes FAILURE! */ default: errtryhelp(EXIT_FAILURE); } diff --git a/login-utils/su-common.c b/login-utils/su-common.c index 94289898d..86beab99c 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -1321,7 +1321,7 @@ int su_main(int argc, char **argv, int mode) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); su_init_debug(); su->conv.appdata_ptr = (void *) su; @@ -1392,9 +1392,7 @@ int su_main(int argc, char **argv, int mode) usage(mode); case 'V': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); - + print_version(EXIT_SUCCESS); default: errtryhelp(EXIT_FAILURE); } diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c index 5f09bd48e..549870d22 100644 --- a/login-utils/sulogin.c +++ b/login-utils/sulogin.c @@ -815,6 +815,8 @@ static void usage(void) fputs(USAGE_SEPARATOR, out); printf(USAGE_HELP_OPTIONS(26)); printf(USAGE_MAN_TAIL("sulogin(8)")); + + exit(EXIT_SUCCESS); } int main(int argc, char **argv) @@ -853,7 +855,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); /* XXX */ + close_stdout_atexit(); /* * See if we have a timeout flag. @@ -870,11 +872,9 @@ int main(int argc, char **argv) opt_e = 1; break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); - return EXIT_SUCCESS; default: /* Do not exit! getopt prints a warning. */ break; diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index 5cc87834a..f1a3607dc 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -334,7 +334,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "fro:hV", longopts, NULL)) != -1) { switch (c) { @@ -355,10 +355,8 @@ int main(int argc, char **argv) case 'h': usage(); - break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); default: errtryhelp(EXIT_FAILURE); } diff --git a/login-utils/vipw.c b/login-utils/vipw.c index 2502fcb4e..2b35036e6 100644 --- a/login-utils/vipw.c +++ b/login-utils/vipw.c @@ -325,7 +325,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); if (!strcmp(program_invocation_short_name, "vigr")) { program = VIGR; @@ -338,8 +338,7 @@ int main(int argc, char *argv[]) while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (c) { case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: |