Commit ff163d9d authored by Thomas Haller's avatar Thomas Haller

shared: move file-get-contents and file-set-contents helper to shared/

These functions are not specific to "src/". Also, they will be needed
by outside of "src/" soon.
parent 6ee7453b
This diff is collapsed.
......@@ -26,4 +26,38 @@
/*****************************************************************************/
/**
* NMUtilsFileGetContentsFlags:
* @NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE: no flag
* @NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET: if present, ensure that no
* data is left in memory. Essentially, it means to call explicity_bzero()
* to not leave key material on the heap (when reading secrets).
*/
typedef enum {
NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE = 0,
NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET = (1 << 0),
} NMUtilsFileGetContentsFlags;
int nm_utils_fd_get_contents (int fd,
gboolean close_fd,
gsize max_length,
NMUtilsFileGetContentsFlags flags,
char **contents,
gsize *length,
GError **error);
int nm_utils_file_get_contents (int dirfd,
const char *filename,
gsize max_length,
NMUtilsFileGetContentsFlags flags,
char **contents,
gsize *length,
GError **error);
gboolean nm_utils_file_set_contents (const char *filename,
const char *contents,
gssize length,
mode_t mode,
GError **error);
#endif /* __NM_IO_UTILS_H__ */
This diff is collapsed.
......@@ -264,40 +264,6 @@ gboolean nm_utils_sysctl_ip_conf_is_path (int addr_family, const char *path, con
gboolean nm_utils_is_specific_hostname (const char *name);
/**
* NMUtilsFileGetContentsFlags:
* @NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE: no flag
* @NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET: if present, ensure that no
* data is left in memory. Essentially, it means to call explicity_bzero()
* to not leave key material on the heap (when reading secrets).
*/
typedef enum {
NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE = 0,
NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET = (1 << 0),
} NMUtilsFileGetContentsFlags;
int nm_utils_fd_get_contents (int fd,
gboolean close_fd,
gsize max_length,
NMUtilsFileGetContentsFlags flags,
char **contents,
gsize *length,
GError **error);
int nm_utils_file_get_contents (int dirfd,
const char *filename,
gsize max_length,
NMUtilsFileGetContentsFlags flags,
char **contents,
gsize *length,
GError **error);
gboolean nm_utils_file_set_contents (const char *filename,
const char *contents,
gssize length,
mode_t mode,
GError **error);
char *nm_utils_machine_id_read (void);
gboolean nm_utils_machine_id_parse (const char *id_str, /*uuid_t*/ guchar *out_uuid);
......
......@@ -54,6 +54,7 @@
#include "wifi/nm-wifi-utils-wext.h"
#include "wpan/nm-wpan-utils.h"
#include "nm-utils/unaligned.h"
#include "nm-utils/nm-io-utils.h"
#include "nm-utils/nm-udev-utils.h"
/*****************************************************************************/
......
......@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <linux/if_tun.h>
#include "nm-utils/nm-io-utils.h"
#include "platform/nmp-object.h"
#include "platform/nmp-netns.h"
#include "platform/nm-platform-utils.h"
......
......@@ -33,6 +33,7 @@
#include <stdio.h>
#include "nm-utils/nm-enum-utils.h"
#include "nm-utils/nm-io-utils.h"
#include "nm-manager.h"
#include "nm-setting-connection.h"
#include "nm-setting-wired.h"
......
......@@ -39,6 +39,7 @@
#include "nm-core-internal.h"
#include "nm-core-utils.h"
#include "nm-utils/nm-enum-utils.h"
#include "nm-utils/nm-io-utils.h"
#include "c-list/src/c-list.h"
/*****************************************************************************/
......
......@@ -34,6 +34,8 @@
#include "nms-keyfile-utils.h"
#include "nms-keyfile-reader.h"
#include "nm-utils/nm-io-utils.h"
/*****************************************************************************/
typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment