VirtualBox

Changeset 3219 in kBuild


Ignore:
Timestamp:
Mar 30, 2018 10:30:15 PM (7 years ago)
Author:
bird
Message:

kmkbuiltin: Added KMK_OPEN_NO_INHERIT to all open calls.

Location:
trunk/src/kmk/kmkbuiltin
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/cat.c

    r3218 r3219  
    222222                } else {
    223223                        pThis->filename = path;
    224                         fd = open(path, O_RDONLY);
     224                        fd = open(path, O_RDONLY | KMK_OPEN_NO_INHERIT);
    225225#ifndef NO_UDOM_SUPPORT
    226226                        if (fd < 0 && errno == EOPNOTSUPP)
  • trunk/src/kmk/kmkbuiltin/cmp_util.c

    r3192 r3219  
    481481    }
    482482    else
    483         fd2 = open(file2, O_RDONLY | O_BINARY, 0);
     483        fd2 = open(file2, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0);
    484484    if (fd2 >= 0)
    485485    {
     
    534534    }
    535535    else
    536         fd1 = open(file1, O_RDONLY | O_BINARY, 0);
     536        fd1 = open(file1, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0);
    537537    if (fd1 >= 0)
    538538    {
  • trunk/src/kmk/kmkbuiltin/cp_utils.c

    r3192 r3219  
    102102        *pcopied = 0;
    103103
    104         if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) {
     104        if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0)) == -1) {
    105105                warn(pCtx, "open: %s", entp->fts_path);
    106106                return (1);
     
    128128                        if (lseek(from_fd, 0, SEEK_SET) != 0) {
    129129                                close(from_fd);
    130                                 if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY, 0)) == -1) {
     130                                if ((from_fd = open(entp->fts_path, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0)) == -1) {
    131131                                        warn(pCtx, "open: %s", entp->fts_path);
    132132                                        return (1);
     
    157157                     * create a new file  */
    158158                    (void)unlink(to.p_path);
    159                     to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY,
     159                    to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY | KMK_OPEN_NO_INHERIT,
    160160                                 fs->st_mode & ~(S_ISUID | S_ISGID));
    161161                } else
    162162                    /* overwrite existing destination file name */
    163                     to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_BINARY, 0);
     163                    to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_BINARY | KMK_OPEN_NO_INHERIT, 0);
    164164        } else
    165                 to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY,
     165                to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY | KMK_OPEN_NO_INHERIT,
    166166                    fs->st_mode & ~(S_ISUID | S_ISGID));
    167167
  • trunk/src/kmk/kmkbuiltin/fts.c

    r3145 r3219  
    275275        if (!ISSET(FTS_NOCHDIR)) {
    276276#ifdef HAVE_FCHDIR
    277                 if ((sp->fts_rfd = open(".", O_RDONLY, 0)) == -1)
     277                if ((sp->fts_rfd = open(".", O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) == -1)
    278278                        SET(FTS_NOCHDIR);
    279279                else if (fcntl(sp->fts_rfd, F_SETFD, FD_CLOEXEC) == -1) {
     
    454454                if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
    455455#ifdef HAVE_FCHDIR
    456                         if ((p->fts_symfd = open(".", O_RDONLY, 0)) == -1) {
     456                        if ((p->fts_symfd = open(".", O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) == -1) {
    457457                                p->fts_errno = errno;
    458458                                p->fts_info = FTS_ERR;
     
    556556#ifdef HAVE_FCHDIR
    557557                                if ((p->fts_symfd =
    558                                     open(".", O_RDONLY, 0)) == -1) {
     558                                    open(".", O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) == -1) {
    559559                                        p->fts_errno = errno;
    560560                                        p->fts_info = FTS_ERR;
     
    722722
    723723#ifdef HAVE_FCHDIR
    724         if ((fd = open(".", O_RDONLY, 0)) == -1)
     724        if ((fd = open(".", O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) == -1)
    725725#else
    726726        if ((pszRoot = getcwd(NULL, 0)) == NULL)
     
    14271427                if (!path) /* shuts up gcc nonull checks*/
    14281428                        return -1;
    1429                 fd = open(path, O_RDONLY);
     1429                fd = open(path, O_RDONLY | KMK_OPEN_NO_INHERIT);
    14301430                if (fd == -1)
    14311431                        return -1;
  • trunk/src/kmk/kmkbuiltin/install.c

    r3215 r3219  
    551551        }
    552552
    553         if (!devnull && (from_fd = open(from_name, O_RDONLY | O_BINARY, 0)) < 0)
     553        if (!devnull && (from_fd = open(from_name, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0)) < 0)
    554554                return err(pThis->pCtx, EX_OSERR, "%s", from_name);
    555555
    556556        /* If we don't strip, we can compare first. */
    557557        if (pThis->docompare && !pThis->dostrip && target) {
    558                 if ((to_fd = open(to_name, O_RDONLY | O_BINARY, 0)) < 0) {
     558                if ((to_fd = open(to_name, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0)) < 0) {
    559559                        rc = err(pThis->pCtx, EX_OSERR, "%s", to_name);
    560560                        goto l_done;
     
    613613                close(to_fd);
    614614#endif
    615                 to_fd = open(tempcopy ? tempfile : to_name, O_RDONLY | O_BINARY, 0);
     615                to_fd = open(tempcopy ? tempfile : to_name, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0);
    616616                if (to_fd < 0) {
    617617                        rc = err(pThis->pCtx, EX_OSERR, "stripping %s", to_name);
     
    627627
    628628                /* Re-open to_fd using the real target name. */
    629                 if ((to_fd = open(to_name, O_RDONLY | O_BINARY, 0)) < 0) {
     629                if ((to_fd = open(to_name, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0)) < 0) {
    630630                        rc = err(pThis->pCtx, EX_OSERR, "%s", to_name);
    631631                        goto l_done;
     
    707707                /* Re-open to_fd so we aren't hosed by the rename(2). */
    708708                (void) close(to_fd);
    709                 if ((to_fd = open(to_name, O_RDONLY | O_BINARY, 0)) < 0) {
     709                if ((to_fd = open(to_name, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0)) < 0) {
    710710                        rc = err(pThis->pCtx, EX_OSERR, "%s", to_name);
    711711                        goto l_done;
     
    913913        }
    914914
    915         newfd = open(path, O_CREAT | O_RDWR | O_TRUNC | O_BINARY, S_IRUSR | S_IWUSR);
     915        newfd = open(path, O_CREAT | O_RDWR | O_TRUNC | O_BINARY | KMK_OPEN_NO_INHERIT, S_IRUSR | S_IWUSR);
    916916        if (newfd < 0 && saved_errno != 0)
    917917                errno = saved_errno;
  • trunk/src/kmk/kmkbuiltin/kDepObj.c

    r3192 r3219  
    10691069                        pOutput = stdout;
    10701070                    else
    1071                         pOutput = fopen(pszOutput, "w");
     1071                        pOutput = fopen(pszOutput, "w" KMK_FOPEN_NO_INHERIT_MODE);
    10721072                    if (!pOutput)
    10731073                        return err(pCtx, 1, "Failed to create output file '%s'", pszOutput);
     
    11451145        else
    11461146        {
    1147             pInput = fopen(argv[i], "rb");
     1147            pInput = fopen(argv[i], "rb" KMK_FOPEN_NO_INHERIT_MODE);
    11481148            if (!pInput)
    11491149                return err(pCtx, 1, "Failed to open input file '%s'", argv[i]);
  • trunk/src/kmk/kmkbuiltin/md5sum.c

    r3192 r3219  
    168168
    169169    /* figure out the appropriate flags. */
    170     fFlags = O_RDONLY;
     170    fFlags = O_RDONLY | KMK_OPEN_NO_INHERIT;
    171171#ifdef O_SEQUENTIAL
    172172    fFlags |= _O_SEQUENTIAL;
  • trunk/src/kmk/kmkbuiltin/mscfakes.c

    r3192 r3219  
    366366        if (doname(pszX, pszEnd))
    367367            return -1;
    368         fd = open(temp, _O_EXCL | _O_CREAT | _O_BINARY | _O_RDWR, 0777);
     368        fd = open(temp, _O_EXCL | _O_CREAT | _O_BINARY | _O_RDWR | KMK_OPEN_NO_INHERIT, 0777);
    369369        if (fd >= 0)
    370370            return fd;
  • trunk/src/kmk/kmkbuiltin/mv.c

    r3215 r3219  
    374374        acl_t acl;
    375375
    376         if ((from_fd = open(from, O_RDONLY, 0)) < 0) {
     376        if ((from_fd = open(from, O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) < 0) {
    377377                warn("%s", from);
    378378                return (1);
     
    389389        }
    390390        while ((to_fd =
    391             open(to, O_CREAT | O_EXCL | O_TRUNC | O_WRONLY, 0)) < 0) {
     391            open(to, O_CREAT | O_EXCL | O_TRUNC | O_WRONLY | KMK_OPEN_NO_INHERIT, 0)) < 0) {
    392392                if (errno == EEXIST && unlink(to) == 0)
    393393                        continue;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette