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:57 +0200
committerMichael Biebl <biebl@debian.org>2018-06-17 14:54:57 +0200
commit9d9b149b81f5ea5fe53ac383fda9cf3afb96b30f (patch)
treea47c80e4d962d3f2202dbab41e2744c921fb8567 /src/nm-core-utils.c
parent03218e6d85e6654bd942b7531ba48b9d9535d55f (diff)
parent069cb5c3a525ebcc19cc2927964258acaca87b13 (diff)
Update upstream source from tag 'upstream/1.11.90'
Update to upstream version '1.11.90'
with Debian dir 13153fad72263d24704dca73c994fe8f7bfd3a28
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 *