aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/crontab.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-08-04 10:16:59 -0500
committerRob Landley <rob@landley.net>2016-08-04 10:16:59 -0500
commit027a73a903af306449710ce12bc09e0e3550c6c9 (patch)
treea415cb11fa6f2b34e63b8259fc52342aaa8fec75 /toys/pending/crontab.c
parent145b7024b5fbb74f16d5e403fb004ff8209bc4a0 (diff)
downloadtoybox-027a73a903af306449710ce12bc09e0e3550c6c9.tar.gz
Make xopen() skip stdin/stdout/stderr, add xopen_stdio() if you want stdout,
add xopenro() that takes one argument and understands "-" means stdin, and switch over lots of users.
Diffstat (limited to 'toys/pending/crontab.c')
-rw-r--r--toys/pending/crontab.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/toys/pending/crontab.c b/toys/pending/crontab.c
index 80a881d7..0b1c47db 100644
--- a/toys/pending/crontab.c
+++ b/toys/pending/crontab.c
@@ -114,7 +114,7 @@ static int validate_component(int min, int max, char *src)
static int parse_crontab(char *fname)
{
char *line;
- int lno, fd = xopen(fname, O_RDONLY);
+ int lno, fd = xopenro(fname);
long plen = 0;
for (lno = 1; (line = get_rawline(fd, &plen, '\n')); lno++,free(line)) {
@@ -214,8 +214,7 @@ static void do_list(char *name)
int fdin;
snprintf(toybuf, sizeof(toybuf), "%s%s", TT.cdir, name);
- if ((fdin = open(toybuf, O_RDONLY)) == -1)
- error_exit("No crontab for '%s'", name);
+ fdin = xopenro(toybuf);
xsendfile(fdin, 1);
xclose(fdin);
}
@@ -233,7 +232,7 @@ static void update_crontab(char *src, char *dest)
snprintf(toybuf, sizeof(toybuf), "%s%s", TT.cdir, dest);
fdout = xcreate(toybuf, O_WRONLY|O_CREAT|O_TRUNC, 0600);
- fdin = xopen(src, O_RDONLY);
+ fdin = xopenro(src);
xsendfile(fdin, fdout);
xclose(fdin);
@@ -277,7 +276,7 @@ static void do_edit(struct passwd *pwd)
if (!stat(toybuf, &sb)) { // file exists and have some content.
if (sb.st_size) {
- srcfd = xopen(toybuf, O_RDONLY);
+ srcfd = xopenro(toybuf);
xsendfile(srcfd, destfd);
xclose(srcfd);
}