diff mbox series

[v2,12/18] storage: Remove mode argument

Message ID 20240202225405.993792-12-denkenz@gmail.com (mailing list archive)
State Accepted
Commit e4fdf579649f919d31c63aedd8f5f693589e4bc8
Headers show
Series [v2,01/18] umlrunner: Also mount /var/lib as tmpfs | expand

Commit Message

Denis Kenzior Feb. 2, 2024, 10:53 p.m. UTC
oFono should be making all sub-directories in STORAGEDIR (typically
/var/lib/ofono) as owner readable/writable.  No other permissions make
sense.  Remove the mode argument from the function signature to make
this explicit.
---
 src/storage.c | 7 ++++---
 src/storage.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/storage.c b/src/storage.c
index 47429c22d1bc..1b761c4ce57a 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -47,12 +47,13 @@  const char *ofono_storage_dir(void)
 	return STORAGEDIR;
 }
 
-int create_dirs(const char *filename, const mode_t mode)
+int create_dirs(const char *filename)
 {
 	struct stat st;
 	char *dir;
 	const char *prev, *next;
 	int err;
+	static const mode_t mode = 0700;
 
 	if (filename[0] != '/')
 		return -1;
@@ -133,7 +134,7 @@  ssize_t write_file(const unsigned char *buffer, size_t len,
 	tmp_path = l_strdup_printf("%s.XXXXXX.tmp", path);
 
 	r = -1;
-	if (create_dirs(path, mode | S_IXUSR) != 0)
+	if (create_dirs(path) != 0)
 		goto error_create_dirs;
 
 	fd = L_TFR(g_mkstemp_full(tmp_path, O_WRONLY | O_CREAT | O_TRUNC, mode));
@@ -204,7 +205,7 @@  void storage_sync(const char *imsi, const char *store, GKeyFile *keyfile)
 	if (path == NULL)
 		return;
 
-	if (create_dirs(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
+	if (create_dirs(path) != 0) {
 		l_free(path);
 		return;
 	}
diff --git a/src/storage.h b/src/storage.h
index 76069949e747..46efd2d1a208 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -22,7 +22,7 @@ 
 #include <fcntl.h>
 #include <sys/types.h>
 
-int create_dirs(const char *filename, const mode_t mode);
+int create_dirs(const char *filename);
 
 ssize_t read_file(unsigned char *buffer, size_t len,
 			const char *path_fmt, ...)