diff options
author | Sami Kerola | 2012-04-04 19:49:40 +0200 |
---|---|---|
committer | Sami Kerola | 2012-04-04 19:49:40 +0200 |
commit | efb8854f4cfa335f3ad72d79a84589110c2a8e87 (patch) | |
tree | 83d1c6e33bb7afacb40bc81772d390d009fd70ac /sys-utils | |
parent | term-utils: verify writing to streams was successful (diff) | |
download | kernel-qcow2-util-linux-efb8854f4cfa335f3ad72d79a84589110c2a8e87.tar.gz kernel-qcow2-util-linux-efb8854f4cfa335f3ad72d79a84589110c2a8e87.tar.xz kernel-qcow2-util-linux-efb8854f4cfa335f3ad72d79a84589110c2a8e87.zip |
sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/arch.c | 2 | ||||
-rw-r--r-- | sys-utils/chcpu.c | 2 | ||||
-rw-r--r-- | sys-utils/ctrlaltdel.c | 2 | ||||
-rw-r--r-- | sys-utils/cytune.c | 2 | ||||
-rw-r--r-- | sys-utils/dmesg.c | 2 | ||||
-rw-r--r-- | sys-utils/fallocate.c | 3 | ||||
-rw-r--r-- | sys-utils/flock.c | 2 | ||||
-rw-r--r-- | sys-utils/fsfreeze.c | 2 | ||||
-rw-r--r-- | sys-utils/fstrim.c | 2 | ||||
-rw-r--r-- | sys-utils/ipcmk.c | 2 | ||||
-rw-r--r-- | sys-utils/ipcrm.c | 2 | ||||
-rw-r--r-- | sys-utils/ipcs.c | 2 | ||||
-rw-r--r-- | sys-utils/ldattach.c | 2 | ||||
-rw-r--r-- | sys-utils/losetup.c | 2 | ||||
-rw-r--r-- | sys-utils/lscpu.c | 2 | ||||
-rw-r--r-- | sys-utils/mount.c | 2 | ||||
-rw-r--r-- | sys-utils/mountpoint.c | 2 | ||||
-rw-r--r-- | sys-utils/pivot_root.c | 2 | ||||
-rw-r--r-- | sys-utils/prlimit.c | 2 | ||||
-rw-r--r-- | sys-utils/readprofile.c | 2 | ||||
-rw-r--r-- | sys-utils/renice.c | 2 | ||||
-rw-r--r-- | sys-utils/rtcwake.c | 5 | ||||
-rw-r--r-- | sys-utils/setarch.c | 2 | ||||
-rw-r--r-- | sys-utils/setsid.c | 2 | ||||
-rw-r--r-- | sys-utils/swapon.c | 2 | ||||
-rw-r--r-- | sys-utils/switch_root.c | 2 | ||||
-rw-r--r-- | sys-utils/tunelp.c | 2 | ||||
-rw-r--r-- | sys-utils/umount.c | 2 | ||||
-rw-r--r-- | sys-utils/unshare.c | 2 |
29 files changed, 60 insertions, 2 deletions
diff --git a/sys-utils/arch.c b/sys-utils/arch.c index 470b12b9a..a7305895a 100644 --- a/sys-utils/arch.c +++ b/sys-utils/arch.c @@ -34,6 +34,7 @@ #include <sys/utsname.h> #include "c.h" +#include "closestream.h" #include "nls.h" static void __attribute__ ((__noreturn__)) usage(FILE * out) @@ -61,6 +62,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (ch) { diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c index 58e40f90d..18655927b 100644 --- a/sys-utils/chcpu.c +++ b/sys-utils/chcpu.c @@ -40,6 +40,7 @@ #include "strutils.h" #include "bitops.h" #include "path.h" +#include "closestream.h" #define _PATH_SYS_CPU "/sys/devices/system/cpu" #define _PATH_SYS_CPU_ONLINE _PATH_SYS_CPU "/online" @@ -246,6 +247,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); maxcpus = get_max_number_of_cpus(); if (maxcpus < 1) diff --git a/sys-utils/ctrlaltdel.c b/sys-utils/ctrlaltdel.c index ef963226e..2ad56a1bb 100644 --- a/sys-utils/ctrlaltdel.c +++ b/sys-utils/ctrlaltdel.c @@ -13,6 +13,7 @@ #include "linux_reboot.h" #include "nls.h" #include "c.h" +#include "closestream.h" static void __attribute__ ((__noreturn__)) usage(FILE * out) { @@ -37,6 +38,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (ch) { diff --git a/sys-utils/cytune.c b/sys-utils/cytune.c index 96d2d6404..ecacff2a1 100644 --- a/sys-utils/cytune.c +++ b/sys-utils/cytune.c @@ -52,6 +52,7 @@ #include "c.h" #include "cyclades.h" +#include "closestream.h" #include "strutils.h" #if 0 @@ -311,6 +312,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((i = getopt_long(argc, argv, "qs:S:t:T:gGi:Vh", longopts, diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 9cbe51658..de4b3abc6 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -29,6 +29,7 @@ #include "widechar.h" #include "writeall.h" #include "bitops.h" +#include "closestream.h" /* Close the log. Currently a NOP. */ #define SYSLOG_ACTION_CLOSE 0 @@ -688,6 +689,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "CcDdEF:f:hkl:n:rs:TtuVx", longopts, NULL)) != -1) { diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 5fc13fe62..adfaa70f7 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -51,7 +51,7 @@ #include "nls.h" #include "strutils.h" #include "c.h" - +#include "closestream.h" static void __attribute__((__noreturn__)) usage(FILE *out) { @@ -104,6 +104,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "hVnpl:o:", longopts, NULL)) != -1) { switch(c) { diff --git a/sys-utils/flock.c b/sys-utils/flock.c index 50cea1392..1db28a294 100644 --- a/sys-utils/flock.c +++ b/sys-utils/flock.c @@ -42,6 +42,7 @@ #include "c.h" #include "nls.h" #include "strutils.h" +#include "closestream.h" static void __attribute__((__noreturn__)) usage(int ex) { @@ -161,6 +162,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); if (argc < 2) usage(EX_USAGE); diff --git a/sys-utils/fsfreeze.c b/sys-utils/fsfreeze.c index 3f03a5241..5d1702158 100644 --- a/sys-utils/fsfreeze.c +++ b/sys-utils/fsfreeze.c @@ -23,6 +23,7 @@ #include "blkdev.h" #include "nls.h" +#include "closestream.h" #include "c.h" static int freeze_f(int fd) @@ -68,6 +69,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "hfu", longopts, NULL)) != -1) { switch(c) { diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c index 4673e94ab..bb88bb804 100644 --- a/sys-utils/fstrim.c +++ b/sys-utils/fstrim.c @@ -40,6 +40,7 @@ #include "nls.h" #include "strutils.h" #include "c.h" +#include "closestream.h" #ifndef FITRIM struct fstrim_range { @@ -87,6 +88,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); memset(&range, 0, sizeof(range)); range.len = ULLONG_MAX; diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c index 3b3ebb9ba..6919d0dea 100644 --- a/sys-utils/ipcmk.c +++ b/sys-utils/ipcmk.c @@ -33,6 +33,7 @@ #include "c.h" #include "nls.h" #include "strutils.h" +#include "closestream.h" key_t create_key(void) { @@ -98,6 +99,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while((opt = getopt_long(argc, argv, "hM:QS:p:Vh", longopts, NULL)) != -1) { switch(opt) { diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c index c091de349..b452b51ec 100644 --- a/sys-utils/ipcrm.c +++ b/sys-utils/ipcrm.c @@ -22,6 +22,7 @@ #include "c.h" #include "nls.h" #include "strutils.h" +#include "closestream.h" #ifndef HAVE_UNION_SEMUN /* according to X/OPEN we have to define it ourselves */ @@ -316,6 +317,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); /* check to see if the command is being invoked in the old way if so * then remove argument list */ diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index 48a4dac4f..fc4164823 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -33,6 +33,7 @@ #include "c.h" #include "nls.h" +#include "closestream.h" /* * SHM_DEST and SHM_LOCKED are defined in kernel headers, but inside @@ -162,6 +163,7 @@ int main (int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((opt = getopt_long(argc, argv, options, longopts, NULL)) != -1) { switch (opt) { diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c index d331413fd..2917d4e83 100644 --- a/sys-utils/ldattach.c +++ b/sys-utils/ldattach.c @@ -27,6 +27,7 @@ #include "c.h" #include "nls.h" #include "strutils.h" +#include "closestream.h" #ifndef N_GIGASET_M101 # define N_GIGASET_M101 16 @@ -234,6 +235,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); /* parse options */ progname = program_invocation_short_name; diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c index b8f6762b1..7059d2f89 100644 --- a/sys-utils/losetup.c +++ b/sys-utils/losetup.c @@ -19,6 +19,7 @@ #include "strutils.h" #include "loopdev.h" #include "xgetpass.h" +#include "closestream.h" enum { A_CREATE = 1, /* setup a new device */ @@ -217,6 +218,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); loopcxt_init(&lc, 0); loopcxt_enable_debug(&lc, getenv("LOOPDEV_DEBUG") ? TRUE : FALSE); diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 6e17b2eb5..1c2d9b61a 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -41,6 +41,7 @@ #include "bitops.h" #include "tt.h" #include "path.h" +#include "closestream.h" #define CACHE_MAX 100 @@ -1255,6 +1256,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((c = getopt_long(argc, argv, "abce::hp::s:xV", longopts, NULL)) != -1) { diff --git a/sys-utils/mount.c b/sys-utils/mount.c index 664c9865a..0f6140690 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -39,6 +39,7 @@ #include "xgetpass.h" #include "exitcodes.h" #include "xalloc.h" +#include "closestream.h" /*** TODO: DOCS: * @@ -701,6 +702,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); mnt_init_debug(0); cxt = mnt_new_context(); diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c index 63a54469f..6ab813d72 100644 --- a/sys-utils/mountpoint.c +++ b/sys-utils/mountpoint.c @@ -37,6 +37,7 @@ #include "nls.h" #include "xalloc.h" #include "c.h" +#include "closestream.h" static int quiet; @@ -147,6 +148,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); mnt_init_debug(0); diff --git a/sys-utils/pivot_root.c b/sys-utils/pivot_root.c index 044aab226..31ceabb78 100644 --- a/sys-utils/pivot_root.c +++ b/sys-utils/pivot_root.c @@ -23,6 +23,7 @@ #include "c.h" #include "nls.h" +#include "closestream.h" #define pivot_root(new_root,put_old) syscall(SYS_pivot_root,new_root,put_old) @@ -50,6 +51,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (ch) { diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index c45b85efb..12271a079 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -33,6 +33,7 @@ #include "xalloc.h" #include "strutils.h" #include "list.h" +#include "closestream.h" #ifndef RLIMIT_RTTIME # define RLIMIT_RTTIME 15 @@ -513,6 +514,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); INIT_LIST_HEAD(&lims); diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c index 52e64e8e5..04d9c7375 100644 --- a/sys-utils/readprofile.c +++ b/sys-utils/readprofile.c @@ -53,6 +53,7 @@ #include "nls.h" #include "xalloc.h" +#include "closestream.h" #define S_LEN 128 @@ -166,6 +167,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); proFile = defaultpro; mapFile = defaultmap; diff --git a/sys-utils/renice.c b/sys-utils/renice.c index cd4cafab3..f5d51b66a 100644 --- a/sys-utils/renice.c +++ b/sys-utils/renice.c @@ -46,6 +46,7 @@ #include <errno.h> #include "nls.h" #include "c.h" +#include "closestream.h" static int donice(int,int,int); @@ -86,6 +87,7 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); argc--; argv++; diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index c18e5e2fc..4ae2cef29 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -41,6 +41,7 @@ #include "usleep.h" #include "strutils.h" #include "c.h" +#include "closestream.h" /* constants from legacy PC/AT hardware */ #define RTC_PF 0x40 @@ -285,7 +286,8 @@ static void suspend_system(const char *suspend) } /* this executes after wake from suspend */ - fclose(f); + if (close_stream(f)) + errx(EXIT_FAILURE, _("write error")); } @@ -394,6 +396,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((t = getopt_long(argc, argv, "ahd:lm:ns:t:uVv", long_options, NULL)) != EOF) { diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c index a61fe391e..97269f45a 100644 --- a/sys-utils/setarch.c +++ b/sys-utils/setarch.c @@ -35,6 +35,7 @@ #include <sys/utsname.h> #include "nls.h" #include "c.h" +#include "closestream.h" #define set_pers(pers) ((long)syscall(SYS_personality, pers)) @@ -251,6 +252,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); if (argc < 1) show_usage(_("Not enough arguments")); diff --git a/sys-utils/setsid.c b/sys-utils/setsid.c index 132f4a2ab..6d1eeda42 100644 --- a/sys-utils/setsid.c +++ b/sys-utils/setsid.c @@ -19,6 +19,7 @@ #include "c.h" #include "nls.h" +#include "closestream.h" static void __attribute__ ((__noreturn__)) usage(FILE * out) { @@ -53,6 +54,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while ((ch = getopt_long(argc, argv, "+Vhc", longopts, NULL)) != -1) switch (ch) { diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 25915b32a..e1e8455a7 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -26,6 +26,7 @@ #include "canonicalize.h" #include "xalloc.h" #include "c.h" +#include "closestream.h" #define PATH_MKSWAP "/sbin/mkswap" @@ -890,6 +891,7 @@ main(int argc, char *argv[]) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); progname = program_invocation_short_name; if (!progname) { diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index 0da784295..4ff3bff8f 100644 --- a/sys-utils/switch_root.c +++ b/sys-utils/switch_root.c @@ -35,6 +35,7 @@ #include "c.h" #include "nls.h" +#include "closestream.h" #ifndef MS_MOVE #define MS_MOVE 8192 @@ -194,6 +195,7 @@ static void __attribute__((__noreturn__)) usage(FILE *output) int main(int argc, char *argv[]) { char *newroot, *init, **initargs; + atexit(close_stdout); if (argv[1] && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))) usage(stdout); diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c index 98b00f6ef..4d9038aec 100644 --- a/sys-utils/tunelp.c +++ b/sys-utils/tunelp.c @@ -63,6 +63,7 @@ #include "lp.h" #include "nls.h" #include "xalloc.h" +#include "closestream.h" #define EXIT_BAD_VALUE 3 #define EXIT_LP_IO_ERR 4 @@ -142,6 +143,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); if (argc < 2) print_usage(stderr); diff --git a/sys-utils/umount.c b/sys-utils/umount.c index cce4b5375..97b2f443b 100644 --- a/sys-utils/umount.c +++ b/sys-utils/umount.c @@ -34,6 +34,7 @@ #include "env.h" #include "optutils.h" #include "exitcodes.h" +#include "closestream.h" static int table_parser_errcb(struct libmnt_table *tb __attribute__((__unused__)), const char *filename, int line) @@ -309,6 +310,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); mnt_init_debug(0); cxt = mnt_new_context(); diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c index 728b86037..9de997bdc 100644 --- a/sys-utils/unshare.c +++ b/sys-utils/unshare.c @@ -27,6 +27,7 @@ #include "nls.h" #include "c.h" +#include "closestream.h" #ifndef CLONE_NEWSNS # define CLONE_NEWNS 0x00020000 @@ -91,6 +92,7 @@ int main(int argc, char *argv[]) setlocale(LC_MESSAGES, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + atexit(close_stdout); while((c = getopt_long(argc, argv, "hVmuin", longopts, NULL)) != -1) { switch(c) { |