libxbps: xbps_mkpath: create intermediate dirs with 0755 permissions.
This commit is contained in:
parent
59dc65b907
commit
a426bad11d
7
lib/external/mkpath.c
vendored
7
lib/external/mkpath.c
vendored
@ -43,7 +43,7 @@ xbps_mkpath(const char *path, mode_t mode)
|
|||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
char *ppath, *slash;
|
char *ppath, *slash;
|
||||||
int done = 0, rv;
|
int done = 0;
|
||||||
mode_t dir_mode;
|
mode_t dir_mode;
|
||||||
|
|
||||||
if ((ppath = strdup(path)) == NULL)
|
if ((ppath = strdup(path)) == NULL)
|
||||||
@ -59,7 +59,7 @@ xbps_mkpath(const char *path, mode_t mode)
|
|||||||
if (mode == 0)
|
if (mode == 0)
|
||||||
mode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~umask(0);
|
mode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~umask(0);
|
||||||
|
|
||||||
dir_mode = mode | S_IWUSR | S_IXUSR;
|
dir_mode = mode | S_IRUSR | S_IXUSR | S_IROTH | S_IXOTH;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
slash += strspn(slash, "/");
|
slash += strspn(slash, "/");
|
||||||
@ -68,8 +68,7 @@ xbps_mkpath(const char *path, mode_t mode)
|
|||||||
done = (*slash == '\0');
|
done = (*slash == '\0');
|
||||||
*slash = '\0';
|
*slash = '\0';
|
||||||
|
|
||||||
rv = mkdir(ppath, done ? mode : dir_mode);
|
if (mkdir(ppath, done ? mode : dir_mode) == -1) {
|
||||||
if (rv < 0) {
|
|
||||||
/*
|
/*
|
||||||
* Can't create; path exists or no perms.
|
* Can't create; path exists or no perms.
|
||||||
* stat() path to determine what's there now.
|
* stat() path to determine what's there now.
|
||||||
|
Loading…
Reference in New Issue
Block a user