From: Michael Tremer Date: Sun, 17 Jul 2022 18:56:46 +0000 (+0000) Subject: Use sane directory/file permissions throughout X-Git-Tag: 0.9.28~688 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=520ce66cbb2ececd7a40e908ef9dbd0547ea18b7;p=pakfire.git Use sane directory/file permissions throughout Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 230d2c0dd..480a7faa6 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -838,7 +838,7 @@ static int pakfire_build_enable_repos(struct pakfire* pakfire) { const char* path = pakfire_repo_get_path(repo); // Make sure the source directory exists - r = pakfire_mkdir(path, 0); + r = pakfire_mkdir(path, 0700); if (r && errno != EEXIST) { ERROR(pakfire, "Could not create repository directory %s: %m\n", path); goto ERROR; diff --git a/src/libpakfire/key.c b/src/libpakfire/key.c index 07b6dbaf5..cb81057b6 100644 --- a/src/libpakfire/key.c +++ b/src/libpakfire/key.c @@ -381,7 +381,7 @@ static int pakfire_key_write_to_keystore(struct pakfire_key* key) { return r; // Create parent directory - r = pakfire_mkparentdir(path, 0); + r = pakfire_mkparentdir(path, 0700); if (r) return r; diff --git a/src/libpakfire/mount.c b/src/libpakfire/mount.c index 2e2d31c61..6627eab6e 100644 --- a/src/libpakfire/mount.c +++ b/src/libpakfire/mount.c @@ -350,7 +350,7 @@ static int pakfire_mount_interpreter(struct pakfire* pakfire) { return r; // Create directory - r = pakfire_mkparentdir(target, 0); + r = pakfire_mkparentdir(target, 0755); if (r) return r; @@ -381,7 +381,7 @@ int pakfire_mount_all(struct pakfire* pakfire) { return r; // Create target - pakfire_mkdir(target, 0); + pakfire_mkdir(target, 0755); RETRY: // Perform mount() @@ -389,7 +389,7 @@ RETRY: if (r) { // If the target directory does not exist, we will create it if (errno == ENOENT) { - r = pakfire_mkdir(target, S_IRUSR|S_IWUSR|S_IXUSR); + r = pakfire_mkdir(target, 0755); if (r) { ERROR(pakfire, "Could not create %s\n", target); return r; @@ -455,7 +455,7 @@ PAKFIRE_EXPORT int pakfire_bind(struct pakfire* pakfire, const char* src, const // Make sure the mountpoint exists switch (st.st_mode & S_IFMT) { case S_IFDIR: - r = pakfire_mkdir(mountpoint, 0); + r = pakfire_mkdir(mountpoint, st.st_mode); if (r && errno != EEXIST) return r; break; @@ -463,7 +463,7 @@ PAKFIRE_EXPORT int pakfire_bind(struct pakfire* pakfire, const char* src, const case S_IFREG: case S_IFLNK: // Make parent directory - r = pakfire_mkparentdir(mountpoint, 0); + r = pakfire_mkparentdir(mountpoint, 0755); if (r) return r; diff --git a/src/libpakfire/packager.c b/src/libpakfire/packager.c index cf7e0168b..02434f59e 100644 --- a/src/libpakfire/packager.c +++ b/src/libpakfire/packager.c @@ -782,7 +782,7 @@ int pakfire_packager_finish_to_directory(struct pakfire_packager* packager, goto ERROR; // Create the parent directory - r = pakfire_mkparentdir(path, 0); + r = pakfire_mkparentdir(path, 0755); if (r) goto ERROR; diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index da24e4fd0..f1a94c359 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -739,7 +739,7 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path, } // Make sure that our private directory exists - r = pakfire_mkdir(private_dir, 0); + r = pakfire_mkdir(private_dir, 0755); if (r && errno != EEXIST) { ERROR(p, "Could not create private directory %s: %m\n", private_dir); goto ERROR; @@ -819,7 +819,7 @@ int pakfire_acquire_lock(struct pakfire* pakfire) { DEBUG(pakfire, "Acquire lock...\n"); // Ensure the parent directory exists - pakfire_mkparentdir(pakfire->lock_path, 0); + pakfire_mkparentdir(pakfire->lock_path, 0755); // Open the lock file pakfire->lock = fopen(pakfire->lock_path, "w"); @@ -1893,7 +1893,7 @@ int pakfire_build_setup(struct pakfire* pakfire) { return r; // Ensure path exists - r = pakfire_mkdir(path, 0); + r = pakfire_mkdir(path, 0755); if (r && errno != EEXIST) { ERROR(pakfire, "Could not create ccache directory %s: %m\n", path); return r; diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index 8df135d1a..7bcc0d3e5 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -961,7 +961,7 @@ int pakfire_mkdir(const char* path, mode_t mode) { } FILE* pakfire_mktemp(char* path) { - int r = pakfire_mkparentdir(path, 0); + int r = pakfire_mkparentdir(path, 755); if (r) return NULL; @@ -975,7 +975,7 @@ FILE* pakfire_mktemp(char* path) { } char* pakfire_mkdtemp(char* path) { - int r = pakfire_mkparentdir(path, 0); + int r = pakfire_mkparentdir(path, 755); if (r) return NULL;