1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
--- libfwupdplugin/fu-common-freebsd.c.orig 2025-09-12 09:55:19 UTC
+++ libfwupdplugin/fu-common-freebsd.c
@@ -14,6 +14,7 @@
#include "fu-common-private.h"
#include "fu-kenv.h"
+#include "fu-path.h"
/* bsdisks doesn't provide Manager object */
#define UDISKS_DBUS_PATH "/org/freedesktop/UDisks2"
@@ -122,9 +123,45 @@ fu_common_get_olson_timezone_id_impl(GError **error)
gchar *
fu_common_get_olson_timezone_id_impl(GError **error)
{
+ g_autofree gchar *fn_localtime = fu_path_from_kind(FU_PATH_KIND_LOCALTIME);
+ g_autoptr(GFile) file_localtime = g_file_new_for_path(fn_localtime);
+
+ /* use the last two sections of the symlink target */
+ g_debug("looking for timezone file %s", fn_localtime);
+ if (g_file_query_file_type(file_localtime, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL) ==
+ G_FILE_TYPE_SYMBOLIC_LINK) {
+ const gchar *target;
+ g_autoptr(GFileInfo) info = NULL;
+
+ info = g_file_query_info(file_localtime,
+ G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL,
+ error);
+ if (info == NULL)
+ return NULL;
+ target = g_file_info_get_symlink_target(info);
+ if (target != NULL) {
+ g_auto(GStrv) sections = g_strsplit(target, "/", -1);
+ guint sections_len = g_strv_length(sections);
+ if (sections_len < 2) {
+ g_set_error(error,
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOT_SUPPORTED,
+ "invalid symlink target: %s",
+ target);
+ return NULL;
+ }
+ return g_strdup_printf("%s/%s",
+ sections[sections_len - 2],
+ sections[sections_len - 1]);
+ }
+ }
+
+ /* failed */
g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
- "getting the Olson timezone ID is not supported on FreeBSD");
+ "no timezone or localtime is available");
return NULL;
}
|