diff --git a/CHANGELOG.md b/CHANGELOG.md index 913510fa0..1c7165318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add dummy functions to allow restoring old dumps [#1251](https://github.com/greenbone/gvmd/pull/1251) - Fix delta sorting for unusual filter sort terms [#1249](https://github.com/greenbone/gvmd/pull/1249) - Fix SCP alert authentication and logging [#1264](https://github.com/greenbone/gvmd/pull/1264) +- Set file mode creation mask for feed lock handling [#1265](https://github.com/greenbone/gvmd/pull/1265) ### Removed diff --git a/src/gmp.c b/src/gmp.c index bfbc544ea..79adf4341 100644 --- a/src/gmp.c +++ b/src/gmp.c @@ -12360,6 +12360,7 @@ feed_type_name (int feed_type) static int get_feed_lock_status (const char *lockfile_name, gchar **timestamp) { + mode_t old_umask; int lockfile; int ret; @@ -12367,15 +12368,20 @@ get_feed_lock_status (const char *lockfile_name, gchar **timestamp) *timestamp = NULL; ret = 0; + old_umask = umask(0); lockfile = open (lockfile_name, O_RDWR | O_CREAT, /* "-rw-rw-r--" */ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); if (lockfile == -1) - g_warning ("%s: failed to open lock file '%s': %s", __func__, - lockfile_name, strerror (errno)); + { + g_warning ("%s: failed to open lock file '%s': %s", __func__, + lockfile_name, strerror (errno)); + umask (old_umask); + } else { + umask (old_umask); if (flock (lockfile, LOCK_EX | LOCK_NB)) /* Exclusive, Non blocking. */ { if (errno == EWOULDBLOCK) diff --git a/src/utils.c b/src/utils.c index 2a785b595..3b0a31dd5 100644 --- a/src/utils.c +++ b/src/utils.c @@ -541,6 +541,7 @@ static int lock_internal (lockfile_t *lockfile, const gchar *lockfile_name, int operation, gboolean name_is_full_path) { + mode_t old_umask; int fd; gchar *full_name; @@ -551,6 +552,7 @@ lock_internal (lockfile_t *lockfile, const gchar *lockfile_name, else full_name = g_build_filename (GVM_RUN_DIR, lockfile_name, NULL); + old_umask = umask (0); fd = open (full_name, O_RDWR | O_CREAT, /* "-rw-rw-r--" */ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); @@ -558,10 +560,12 @@ lock_internal (lockfile_t *lockfile, const gchar *lockfile_name, { g_warning ("Failed to open lock file '%s': %s", full_name, strerror (errno)); + umask (old_umask); lockfile->name = NULL; g_free (full_name); return -1; } + umask (old_umask); /* Lock the lockfile. */