summary refs log tree commit diff
path: root/src/nm-core-utils.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-06-17 14:54:10 +0200
committerMichael Biebl <biebl@debian.org>2018-06-17 14:54:10 +0200
commit069cb5c3a525ebcc19cc2927964258acaca87b13 (patch)
tree66ac6b21a44d630c0fc281c0df327239d491226a /src/nm-core-utils.c
parent04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (diff)
New upstream version 1.11.90 upstream/1.11.90
Diffstat (limited to 'src/nm-core-utils.c')
-rw-r--r--src/nm-core-utils.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
index b1a4cc25..54ccdb83 100644
--- a/src/nm-core-utils.c
+++ b/src/nm-core-utils.c
@@ -2521,20 +2521,20 @@ nm_utils_machine_id_read (void)
 	 */
 	if (   !g_file_get_contents ("/etc/machine-id", &contents, NULL, NULL)
 	    && !g_file_get_contents (LOCALSTATEDIR "/lib/dbus/machine-id", &contents, NULL, NULL))
-		return FALSE;
+		return NULL;
 
 	contents = g_strstrip (contents);
 
 	for (i = 0; i < 32; i++) {
 		if (!g_ascii_isxdigit (contents[i]))
-			return FALSE;
+			return NULL;
 		if (contents[i] >= 'A' && contents[i] <= 'F') {
 			/* canonicalize to lower-case */
 			contents[i] = 'a' + (contents[i] - 'A');
 		}
 	}
 	if (contents[i] != '\0')
-		return FALSE;
+		return NULL;
 
 	return g_steal_pointer (&contents);
 }
@@ -2896,6 +2896,22 @@ nm_utils_secret_key_get (const guint8 **out_secret_key,
 	return secret_key->is_good;
 }
 
+gint64
+nm_utils_secret_key_get_timestamp (void)
+{
+	struct stat stat_buf;
+	const guint8 *key;
+	gsize key_len;
+
+	if (!nm_utils_secret_key_get (&key, &key_len))
+		return 0;
+
+	if (stat (NMSTATEDIR "/secret_key", &stat_buf) != 0)
+		return 0;
+
+	return stat_buf.st_mtim.tv_sec;
+}
+
 /*****************************************************************************/
 
 const char *