summaryrefslogtreecommitdiff
path: root/miscutils/crontab.c
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils/crontab.c')
-rw-r--r--miscutils/crontab.c27
1 files changed, 1 insertions, 26 deletions
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index 4731d8d..aad242f 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -55,28 +55,6 @@ static void edit_file(const struct passwd *pas, const char *file)
bb_perror_msg_and_die("can't execute '%s'", ptr);
}
-static int open_as_user(const struct passwd *pas, const char *file)
-{
- pid_t pid;
- char c;
-
- pid = xvfork();
- if (pid) { /* PARENT */
- if (wait4pid(pid) == 0) {
- /* exitcode 0: child says it can read */
- return open(file, O_RDONLY);
- }
- return -1;
- }
-
- /* CHILD */
- /* initgroups, setgid, setuid */
- change_identity(pas);
- /* We just try to read one byte. If it works, file is readable
- * under this user. We signal that by exiting with 0. */
- _exit(safe_read(xopen(file, O_RDONLY), &c, 1) < 0);
-}
-
int crontab_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int crontab_main(int argc UNUSED_PARAM, char **argv)
{
@@ -137,10 +115,7 @@ int crontab_main(int argc UNUSED_PARAM, char **argv)
if (!argv[0])
bb_show_usage();
if (NOT_LONE_DASH(argv[0])) {
- src_fd = open_as_user(pas, argv[0]);
- if (src_fd < 0)
- bb_error_msg_and_die("user %s cannot read %s",
- pas->pw_name, argv[0]);
+ src_fd = xopen_as_uid_gid(argv[0], O_RDONLY, pas->pw_uid, pas->pw_gid);
}
}