Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/miscutils/crontab.c

    r3232 r3621  
    5454    BB_EXECLP(ptr, ptr, file, NULL);
    5555    bb_perror_msg_and_die("can't execute '%s'", ptr);
    56 }
    57 
    58 static int open_as_user(const struct passwd *pas, const char *file)
    59 {
    60     pid_t pid;
    61     char c;
    62 
    63     pid = xvfork();
    64     if (pid) { /* PARENT */
    65         if (wait4pid(pid) == 0) {
    66             /* exitcode 0: child says it can read */
    67             return open(file, O_RDONLY);
    68         }
    69         return -1;
    70     }
    71 
    72     /* CHILD */
    73     /* initgroups, setgid, setuid */
    74     change_identity(pas);
    75     /* We just try to read one byte. If it works, file is readable
    76      * under this user. We signal that by exiting with 0. */
    77     _exit(safe_read(xopen(file, O_RDONLY), &c, 1) < 0);
    7856}
    7957
     
    138116            bb_show_usage();
    139117        if (NOT_LONE_DASH(argv[0])) {
    140             src_fd = open_as_user(pas, argv[0]);
    141             if (src_fd < 0)
    142                 bb_error_msg_and_die("user %s cannot read %s",
    143                         pas->pw_name, argv[0]);
     118            src_fd = xopen_as_uid_gid(argv[0], O_RDONLY, pas->pw_uid, pas->pw_gid);
    144119        }
    145120    }
     
    196171        /*free(tmp_fname);*/
    197172        /*free(new_fname);*/
    198 
    199173    } /* switch */
    200174
Note: See TracChangeset for help on using the changeset viewer.