diff options
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/crontab.c | 29 | ||||
-rw-r--r-- | miscutils/mt.c | 3 | ||||
-rw-r--r-- | miscutils/rx.c | 10 |
3 files changed, 15 insertions, 27 deletions
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index 703d01ecc..1b2f46f3a 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
@@ -179,20 +179,16 @@ crontab_main(int ac, char **av) | |||
179 | char buf[1024]; | 179 | char buf[1024]; |
180 | 180 | ||
181 | snprintf(tmp, sizeof(tmp), TMPDIR "/crontab.%d", getpid()); | 181 | snprintf(tmp, sizeof(tmp), TMPDIR "/crontab.%d", getpid()); |
182 | if ((fd = open(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600)) >= 0) { | 182 | fd = bb_xopen3(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600); |
183 | chown(tmp, getuid(), getgid()); | 183 | chown(tmp, getuid(), getgid()); |
184 | if ((fi = fopen(pas->pw_name, "r"))) { | 184 | if ((fi = fopen(pas->pw_name, "r"))) { |
185 | while ((n = fread(buf, 1, sizeof(buf), fi)) > 0) | 185 | while ((n = fread(buf, 1, sizeof(buf), fi)) > 0) |
186 | write(fd, buf, n); | 186 | write(fd, buf, n); |
187 | } | ||
188 | EditFile(caller, tmp); | ||
189 | remove(tmp); | ||
190 | lseek(fd, 0L, 0); | ||
191 | repFd = fd; | ||
192 | } else { | ||
193 | bb_error_msg_and_die("unable to create %s", tmp); | ||
194 | } | 187 | } |
195 | 188 | EditFile(caller, tmp); | |
189 | remove(tmp); | ||
190 | lseek(fd, 0L, 0); | ||
191 | repFd = fd; | ||
196 | } | 192 | } |
197 | option = REPLACE; | 193 | option = REPLACE; |
198 | /* fall through */ | 194 | /* fall through */ |
@@ -289,11 +285,8 @@ GetReplaceStream(const char *user, const char *file) | |||
289 | if (ChangeUser(user, 0) < 0) | 285 | if (ChangeUser(user, 0) < 0) |
290 | exit(0); | 286 | exit(0); |
291 | 287 | ||
292 | fd = open(file, O_RDONLY); | 288 | bb_default_error_retval = 0; |
293 | if (fd < 0) { | 289 | fd = bb_xopen3(file, O_RDONLY, 0); |
294 | bb_error_msg("unable to open %s", file); | ||
295 | exit(0); | ||
296 | } | ||
297 | buf[0] = 0; | 290 | buf[0] = 0; |
298 | write(filedes[1], buf, 1); | 291 | write(filedes[1], buf, 1); |
299 | while ((n = read(fd, buf, sizeof(buf))) > 0) { | 292 | while ((n = read(fd, buf, sizeof(buf))) > 0) { |
diff --git a/miscutils/mt.c b/miscutils/mt.c index 44efedbe3..368fc66b9 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c | |||
@@ -101,8 +101,7 @@ int mt_main(int argc, char **argv) | |||
101 | break; | 101 | break; |
102 | } | 102 | } |
103 | 103 | ||
104 | if ((fd = open(file, mode, 0)) < 0) | 104 | fd = bb_xopen3(file, mode, 0); |
105 | bb_perror_msg_and_die("%s", file); | ||
106 | 105 | ||
107 | switch (code->value) { | 106 | switch (code->value) { |
108 | case MTTELL: | 107 | case MTTELL: |
diff --git a/miscutils/rx.c b/miscutils/rx.c index c7e82ead5..3df461349 100644 --- a/miscutils/rx.c +++ b/miscutils/rx.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /*------------------------------------------------------------------------- | 2 | /*------------------------------------------------------------------------- |
2 | * Filename: xmodem.c | 3 | * Filename: xmodem.c |
3 | * Version: $Id: rx.c,v 1.2 2004/03/15 08:28:46 andersen Exp $ | 4 | * Version: $Id: rx.c,v 1.2 2004/03/15 08:28:46 andersen Exp $ |
@@ -289,13 +290,8 @@ int rx_main(int argc, char **argv) | |||
289 | bb_show_usage(); | 290 | bb_show_usage(); |
290 | 291 | ||
291 | fn = argv[1]; | 292 | fn = argv[1]; |
292 | ttyfd = open("/dev/tty", O_RDWR); | 293 | ttyfd = bb_xopen3("/dev/tty", O_RDWR, 0); |
293 | if (ttyfd < 0) | 294 | filefd = bb_xopen3(fn, O_RDWR|O_CREAT|O_TRUNC, 0666); |
294 | bb_error_msg_and_die("%s: open on /dev/tty failed: %m\n", argv[0]); | ||
295 | |||
296 | filefd = open(fn, O_RDWR|O_CREAT|O_TRUNC, 0666); | ||
297 | if (filefd < 0) | ||
298 | bb_error_msg_and_die("%s: open on %s failed: %m\n", argv[0], fn); | ||
299 | 295 | ||
300 | if (tcgetattr(ttyfd, &tty) < 0) | 296 | if (tcgetattr(ttyfd, &tty) < 0) |
301 | bb_error_msg_and_die("%s: tcgetattr failed: %m\n", argv[0]); | 297 | bb_error_msg_and_die("%s: tcgetattr failed: %m\n", argv[0]); |