Merge pull request #108 from datenwolf/master
set umask for pkgdb creation/access
This commit is contained in:
commit
47c05047ea
@ -28,6 +28,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ static int pkgdb_fd;
|
|||||||
int
|
int
|
||||||
xbps_pkgdb_lock(struct xbps_handle *xhp)
|
xbps_pkgdb_lock(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
|
mode_t prev_umask;
|
||||||
int rv;
|
int rv;
|
||||||
/*
|
/*
|
||||||
* Use a mandatory file lock to only allow one writer to pkgdb,
|
* Use a mandatory file lock to only allow one writer to pkgdb,
|
||||||
@ -89,13 +91,18 @@ xbps_pkgdb_lock(struct xbps_handle *xhp)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prev_umask = umask(022);
|
||||||
if ((pkgdb_fd = open(xhp->pkgdb_plist, O_CREAT|O_RDWR|O_CLOEXEC, 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));
|
||||||
free(xhp->pkgdb_plist);
|
free(xhp->pkgdb_plist);
|
||||||
|
umask(prev_umask);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
umask(prev_umask);
|
||||||
|
|
||||||
if (lockf(pkgdb_fd, F_TLOCK, 0) == -1) {
|
if (lockf(pkgdb_fd, F_TLOCK, 0) == -1) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_dbg_printf(xhp, "[pkgdb] cannot lock pkgdb: %s\n", strerror(rv));
|
xbps_dbg_printf(xhp, "[pkgdb] cannot lock pkgdb: %s\n", strerror(rv));
|
||||||
|
Loading…
Reference in New Issue
Block a user