libxbps: open fds with O_CLOEXEC to avoid warnings of leaked fds.
This commit is contained in:
parent
bc97851fdb
commit
ea364affc8
@ -89,7 +89,7 @@ xbps_pkgdb_lock(struct xbps_handle *xhp)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((pkgdb_fd = open(xhp->pkgdb_plist, O_CREAT|O_RDWR, 0664)) == -1) {
|
if ((pkgdb_fd = open(xhp->pkgdb_plist, O_CREAT|O_RDWR|O_CLOEXEC, 0664)) == -1) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_dbg_printf(xhp, "[pkgdb] cannot open pkgdb for locking "
|
xbps_dbg_printf(xhp, "[pkgdb] cannot open pkgdb for locking "
|
||||||
"%s: %s\n", xhp->pkgdb_plist, strerror(rv));
|
"%s: %s\n", xhp->pkgdb_plist, strerror(rv));
|
||||||
|
@ -91,7 +91,7 @@ xbps_repo_lock(struct xbps_handle *xhp, const char *repodir,
|
|||||||
free(repofile);
|
free(repofile);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL, 0660);
|
fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0660);
|
||||||
rv = errno;
|
rv = errno;
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
break;
|
break;
|
||||||
@ -265,7 +265,7 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url)
|
|||||||
/*
|
/*
|
||||||
* Open the repository archive.
|
* Open the repository archive.
|
||||||
*/
|
*/
|
||||||
repo->fd = open(repofile, O_RDONLY);
|
repo->fd = open(repofile, O_RDONLY|O_CLOEXEC);
|
||||||
if (repo->fd == -1) {
|
if (repo->fd == -1) {
|
||||||
int rv = errno;
|
int rv = errno;
|
||||||
xbps_dbg_printf(xhp, "[repo] `%s' open repodata %s\n",
|
xbps_dbg_printf(xhp, "[repo] `%s' open repodata %s\n",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2008-2014 Juan Romero Pardines.
|
* Copyright (c) 2008-2015 Juan Romero Pardines.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -69,7 +69,7 @@ xbps_mmap_file(const char *file, void **mmf, size_t *mmflen, size_t *filelen)
|
|||||||
|
|
||||||
assert(file);
|
assert(file);
|
||||||
|
|
||||||
if ((fd = open(file, O_RDONLY)) == -1)
|
if ((fd = open(file, O_RDONLY|O_CLOEXEC)) == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (fstat(fd, &st) == -1) {
|
if (fstat(fd, &st) == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user