Changeset 3219 in kBuild
- Timestamp:
- Mar 30, 2018 10:30:15 PM (7 years ago)
- Location:
- trunk/src/kmk/kmkbuiltin
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/cat.c
r3218 r3219 222 222 } else { 223 223 pThis->filename = path; 224 fd = open(path, O_RDONLY );224 fd = open(path, O_RDONLY | KMK_OPEN_NO_INHERIT); 225 225 #ifndef NO_UDOM_SUPPORT 226 226 if (fd < 0 && errno == EOPNOTSUPP) -
trunk/src/kmk/kmkbuiltin/cmp_util.c
r3192 r3219 481 481 } 482 482 else 483 fd2 = open(file2, O_RDONLY | O_BINARY , 0);483 fd2 = open(file2, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0); 484 484 if (fd2 >= 0) 485 485 { … … 534 534 } 535 535 else 536 fd1 = open(file1, O_RDONLY | O_BINARY , 0);536 fd1 = open(file1, O_RDONLY | O_BINARY | KMK_OPEN_NO_INHERIT, 0); 537 537 if (fd1 >= 0) 538 538 { -
trunk/src/kmk/kmkbuiltin/cp_utils.c
r3192 r3219 102 102 *pcopied = 0; 103 103 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) { 105 105 warn(pCtx, "open: %s", entp->fts_path); 106 106 return (1); … … 128 128 if (lseek(from_fd, 0, SEEK_SET) != 0) { 129 129 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) { 131 131 warn(pCtx, "open: %s", entp->fts_path); 132 132 return (1); … … 157 157 * create a new file */ 158 158 (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, 160 160 fs->st_mode & ~(S_ISUID | S_ISGID)); 161 161 } else 162 162 /* 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); 164 164 } 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, 166 166 fs->st_mode & ~(S_ISUID | S_ISGID)); 167 167 -
trunk/src/kmk/kmkbuiltin/fts.c
r3145 r3219 275 275 if (!ISSET(FTS_NOCHDIR)) { 276 276 #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) 278 278 SET(FTS_NOCHDIR); 279 279 else if (fcntl(sp->fts_rfd, F_SETFD, FD_CLOEXEC) == -1) { … … 454 454 if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { 455 455 #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) { 457 457 p->fts_errno = errno; 458 458 p->fts_info = FTS_ERR; … … 556 556 #ifdef HAVE_FCHDIR 557 557 if ((p->fts_symfd = 558 open(".", O_RDONLY , 0)) == -1) {558 open(".", O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) == -1) { 559 559 p->fts_errno = errno; 560 560 p->fts_info = FTS_ERR; … … 722 722 723 723 #ifdef HAVE_FCHDIR 724 if ((fd = open(".", O_RDONLY , 0)) == -1)724 if ((fd = open(".", O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) == -1) 725 725 #else 726 726 if ((pszRoot = getcwd(NULL, 0)) == NULL) … … 1427 1427 if (!path) /* shuts up gcc nonull checks*/ 1428 1428 return -1; 1429 fd = open(path, O_RDONLY );1429 fd = open(path, O_RDONLY | KMK_OPEN_NO_INHERIT); 1430 1430 if (fd == -1) 1431 1431 return -1; -
trunk/src/kmk/kmkbuiltin/install.c
r3215 r3219 551 551 } 552 552 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) 554 554 return err(pThis->pCtx, EX_OSERR, "%s", from_name); 555 555 556 556 /* If we don't strip, we can compare first. */ 557 557 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) { 559 559 rc = err(pThis->pCtx, EX_OSERR, "%s", to_name); 560 560 goto l_done; … … 613 613 close(to_fd); 614 614 #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); 616 616 if (to_fd < 0) { 617 617 rc = err(pThis->pCtx, EX_OSERR, "stripping %s", to_name); … … 627 627 628 628 /* 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) { 630 630 rc = err(pThis->pCtx, EX_OSERR, "%s", to_name); 631 631 goto l_done; … … 707 707 /* Re-open to_fd so we aren't hosed by the rename(2). */ 708 708 (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) { 710 710 rc = err(pThis->pCtx, EX_OSERR, "%s", to_name); 711 711 goto l_done; … … 913 913 } 914 914 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); 916 916 if (newfd < 0 && saved_errno != 0) 917 917 errno = saved_errno; -
trunk/src/kmk/kmkbuiltin/kDepObj.c
r3192 r3219 1069 1069 pOutput = stdout; 1070 1070 else 1071 pOutput = fopen(pszOutput, "w" );1071 pOutput = fopen(pszOutput, "w" KMK_FOPEN_NO_INHERIT_MODE); 1072 1072 if (!pOutput) 1073 1073 return err(pCtx, 1, "Failed to create output file '%s'", pszOutput); … … 1145 1145 else 1146 1146 { 1147 pInput = fopen(argv[i], "rb" );1147 pInput = fopen(argv[i], "rb" KMK_FOPEN_NO_INHERIT_MODE); 1148 1148 if (!pInput) 1149 1149 return err(pCtx, 1, "Failed to open input file '%s'", argv[i]); -
trunk/src/kmk/kmkbuiltin/md5sum.c
r3192 r3219 168 168 169 169 /* figure out the appropriate flags. */ 170 fFlags = O_RDONLY ;170 fFlags = O_RDONLY | KMK_OPEN_NO_INHERIT; 171 171 #ifdef O_SEQUENTIAL 172 172 fFlags |= _O_SEQUENTIAL; -
trunk/src/kmk/kmkbuiltin/mscfakes.c
r3192 r3219 366 366 if (doname(pszX, pszEnd)) 367 367 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); 369 369 if (fd >= 0) 370 370 return fd; -
trunk/src/kmk/kmkbuiltin/mv.c
r3215 r3219 374 374 acl_t acl; 375 375 376 if ((from_fd = open(from, O_RDONLY , 0)) < 0) {376 if ((from_fd = open(from, O_RDONLY | KMK_OPEN_NO_INHERIT, 0)) < 0) { 377 377 warn("%s", from); 378 378 return (1); … … 389 389 } 390 390 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) { 392 392 if (errno == EEXIST && unlink(to) == 0) 393 393 continue;
Note:
See TracChangeset
for help on using the changeset viewer.