[gnome-boxes] util: More error handling in get_timezone_from_linux()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] util: More error handling in get_timezone_from_linux()
- Date: Thu, 2 May 2013 19:04:28 +0000 (UTC)
commit dc700acc02959fc5590d3e2556523c2e78ffd80e
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu May 2 18:04:25 2013 +0300
util: More error handling in get_timezone_from_linux()
https://bugzilla.gnome.org/show_bug.cgi?id=699281
src/util-app.vala | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/util-app.vala b/src/util-app.vala
index 91f6849..94a5c86 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -503,11 +503,18 @@ namespace Boxes {
return timedate.timezone;
}
+ private const string TZ_FILE = "/etc/localtime";
+
public string get_timezone_from_linux () throws GLib.Error {
- var file = File.new_for_path ("/etc/localtime");
+ var file = File.new_for_path (TZ_FILE);
+ if (!file.query_exists ())
+ throw new Boxes.Error.INVALID ("Timezone file not found in expected location '%s'", TZ_FILE);
var info = file.query_info (FileAttribute.STANDARD_SYMLINK_TARGET,
FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
var target = info.get_symlink_target ();
+ if (target == null)
+ throw new Boxes.Error.INVALID ("Timezone file '%s' is expected to be a symlink", TZ_FILE);
+
var tokens = target.split ("zoneinfo/");
if (tokens == null || tokens.length < 2)
throw new Boxes.Error.INVALID ("Timezone file in unexpected location '%s'", target);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]