mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-20 04:40:04 +01:00
merge: branch 'bg/dns-no-stub'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2298
This commit is contained in:
commit
0e121f5658
11 changed files with 41 additions and 11 deletions
|
|
@ -684,7 +684,7 @@ iwd_config_write(GKeyFile *config,
|
|||
* in the last few filename characters -- it cannot end in .open, .psk
|
||||
* or .8021x.
|
||||
*/
|
||||
return nm_utils_file_set_contents(filepath, data, length, 0600, times, NULL, error);
|
||||
return nm_utils_file_set_contents(filepath, data, length, 0600, times, NULL, NULL, error);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "libnm-glib-aux/nm-str-buf.h"
|
||||
#include "libnm-glib-aux/nm-io-utils.h"
|
||||
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "devices/nm-device.h"
|
||||
|
|
@ -1006,7 +1007,8 @@ _read_link_cached(const char *path, gboolean *is_cached, char **cached)
|
|||
#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF ".tmp"
|
||||
#define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager"
|
||||
|
||||
#define NO_STUB_RESOLV_CONF NMRUNDIR "/no-stub-resolv.conf"
|
||||
#define NO_STUB_RESOLV_CONF NMRUNDIR "/no-stub-resolv.conf"
|
||||
#define NO_STUB_RESOLV_CONF_TMP NMRUNDIR "/no-stub-resolv.conf.tmp"
|
||||
|
||||
static void
|
||||
update_resolv_conf_no_stub(NMDnsManager *self,
|
||||
|
|
@ -1019,7 +1021,14 @@ update_resolv_conf_no_stub(NMDnsManager *self,
|
|||
|
||||
content = create_resolv_conf(searches, nameservers, options);
|
||||
|
||||
if (!g_file_set_contents(NO_STUB_RESOLV_CONF, content, -1, &local)) {
|
||||
if (!nm_utils_file_set_contents(NO_STUB_RESOLV_CONF,
|
||||
content,
|
||||
-1,
|
||||
0644,
|
||||
NULL,
|
||||
NO_STUB_RESOLV_CONF_TMP,
|
||||
NULL,
|
||||
&local)) {
|
||||
_LOGD("update-resolv-no-stub: failure to write file: %s", local->message);
|
||||
g_error_free(local);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ nm_main_utils_write_pidfile(const char *pidfile)
|
|||
char pid[16];
|
||||
|
||||
nm_sprintf_buf(pid, "%lld", (long long) getpid());
|
||||
if (!nm_utils_file_set_contents(pidfile, pid, -1, 00644, NULL, NULL, &error)) {
|
||||
if (!nm_utils_file_set_contents(pidfile, pid, -1, 00644, NULL, NULL, NULL, &error)) {
|
||||
fprintf(stderr, _("Writing to %s failed: %s\n"), pidfile, error->message);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2865,6 +2865,7 @@ _host_id_read(guint8 **out_host_id, gsize *out_host_id_len)
|
|||
0600,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&error)) {
|
||||
nm_log_warn(
|
||||
LOGD_CORE,
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ ip_again:
|
|||
00644,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
nm_log_dbg(LOGD_PLATFORM, "dump to file complete");
|
||||
|
|
|
|||
|
|
@ -320,6 +320,7 @@ write_blobs(GHashTable *blobs, GError **error)
|
|||
0600,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&write_error)) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ nms_keyfile_nmmeta_write(const char *dirname,
|
|||
length,
|
||||
0600,
|
||||
NULL,
|
||||
NULL,
|
||||
&errsv,
|
||||
NULL)) {
|
||||
NM_SET_OUT(out_full_filename, g_steal_pointer(&full_filename_tmp));
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ cert_writer(NMConnection *connection,
|
|||
0600,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&local);
|
||||
if (success) {
|
||||
/* Write the path value to the keyfile.
|
||||
|
|
@ -384,7 +385,14 @@ _internal_write_connection(NMConnection *connection,
|
|||
}
|
||||
}
|
||||
|
||||
nm_utils_file_set_contents(path, kf_content_buf, kf_content_len, 0600, NULL, NULL, &local_err);
|
||||
nm_utils_file_set_contents(path,
|
||||
kf_content_buf,
|
||||
kf_content_len,
|
||||
0600,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
g_set_error(error,
|
||||
NM_SETTINGS_ERROR,
|
||||
|
|
|
|||
|
|
@ -415,8 +415,10 @@ nm_utils_file_get_contents(int dirfd,
|
|||
|
||||
/*
|
||||
* Copied from GLib's g_file_set_contents() et al., but allows
|
||||
* specifying a mode for the new file and optionally the last access
|
||||
* and last modification times.
|
||||
* specifying:
|
||||
* - the file mode (@mode)
|
||||
* - optionally, the last access and modification times (@times)
|
||||
* - optionally, a fixed name for the temporary file (@tmp_name)
|
||||
*/
|
||||
gboolean
|
||||
nm_utils_file_set_contents(const char *filename,
|
||||
|
|
@ -424,10 +426,11 @@ nm_utils_file_set_contents(const char *filename,
|
|||
gssize length,
|
||||
mode_t mode,
|
||||
const struct timespec *times,
|
||||
const char *tmp_name,
|
||||
int *out_errsv,
|
||||
GError **error)
|
||||
{
|
||||
gs_free char *tmp_name = NULL;
|
||||
gs_free char *tmp_name_free = NULL;
|
||||
struct stat statbuf;
|
||||
int errsv;
|
||||
gssize s;
|
||||
|
|
@ -442,8 +445,13 @@ nm_utils_file_set_contents(const char *filename,
|
|||
if (length == -1)
|
||||
length = strlen(contents);
|
||||
|
||||
tmp_name = g_strdup_printf("%s.XXXXXX", filename);
|
||||
fd = g_mkstemp_full(tmp_name, O_RDWR | O_CLOEXEC, mode);
|
||||
if (tmp_name) {
|
||||
fd = open(tmp_name, O_CREAT | O_RDWR | O_TRUNC | O_CLOEXEC, mode);
|
||||
} else {
|
||||
tmp_name_free = g_strdup_printf("%s.XXXXXX", filename);
|
||||
tmp_name = tmp_name_free;
|
||||
fd = g_mkstemp_full(tmp_name_free, O_RDWR | O_CLOEXEC, mode);
|
||||
}
|
||||
if (fd < 0) {
|
||||
return _get_contents_error_errno(error, out_errsv, "failed to create file %s", tmp_name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ gboolean nm_utils_file_set_contents(const char *filename,
|
|||
gssize length,
|
||||
mode_t mode,
|
||||
const struct timespec *times,
|
||||
const char *tmp_name,
|
||||
int *out_errsv,
|
||||
GError **error);
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ output_conn(gpointer key, gpointer value, gpointer user_data)
|
|||
filename = nm_keyfile_utils_create_filename(basename, TRUE);
|
||||
full_filename = g_build_filename(connections_dir, filename, NULL);
|
||||
|
||||
if (!nm_utils_file_set_contents(full_filename, data, len, 0600, NULL, NULL, &error))
|
||||
if (!nm_utils_file_set_contents(full_filename, data, len, 0600, NULL, NULL, NULL, &error))
|
||||
goto err_out;
|
||||
} else
|
||||
g_print("\n*** Connection '%s' ***\n\n%s", basename, data);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue