aboutsummaryrefslogtreecommitdiff
path: root/miscutils/crontab.c
diff options
context:
space:
mode:
authoraldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-04-13 12:45:04 +0000
committeraldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-04-13 12:45:04 +0000
commitf0bf1ade78b709229cab0801347032478b02ef96 (patch)
tree378b5a002da81f8622913cc6a9aeac873e307ec9 /miscutils/crontab.c
parenta39965951155a179f9e8afed70dd5f45ea70f280 (diff)
downloadbusybox-w32-f0bf1ade78b709229cab0801347032478b02ef96.tar.gz
busybox-w32-f0bf1ade78b709229cab0801347032478b02ef96.tar.bz2
busybox-w32-f0bf1ade78b709229cab0801347032478b02ef96.zip
- patch from Denis Vlasenko to add and use bb_xopen3()
git-svn-id: svn://busybox.net/trunk/busybox@14847 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'miscutils/crontab.c')
-rw-r--r--miscutils/crontab.c29
1 files changed, 11 insertions, 18 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) {