FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 06-17-2008, 03:43 PM
Radek Vykydal
 
Default check values of kickstart option timezone

Hi,

this patch should solve unhandled exception caused by invalid value
of kickstart option timezone (bug #404321).

Why this way:

The timezone value read from ks can be checked
(by checking the presence of respective timezone file in usr/share/zoneinfo):

1) when reading ks
2) in setuptime step (where it actually is checked now)
3) in writeconfig step (where it raises IOError which is subj of this bug)
4) in firstboot date module

I think the cleanest way is to check it in 1), because then, in case of
invalid value, you can ask the user for a valid one in timezone step. This is
what the patch of kickstart.py does.

Other possibility is to defer the check to 3) with an advantage of wider
choice of installed timezone files (/mnt/sysimage/usr/share/zoneinfo).
Then, in case of invalid value, there would be 2 options:
- some default ('America/New_York') value would be set in /etc/sysconfig/clock
and /etc/localtime (otherwise the exception would be raised by system-config-date
during firstboot date configuration)
- or the invalid value from ks would be saved into /etc/sysconfig/clock,
/etc/localtime would not be copied, and firstboot module date would check
these values and in case of being invalid display also timezone
tab in firstboot date selection window.

The patch adds also checking in 3) (timezone.py patch), but only to defer
the raise of exception (which should never happen with checking in 1) and asking)
to firstboot phase where it can eventually be 'solved' with reconfig.
Well, I am not sure if this second patch is necessary/justifiable.


If the ability to set the timezone to some value available only in installed
packages (ignore invalid value in 1), check in 3)) was really desired,
I'd add an option to ks for it?

Radek Vykydal



Patch against rhel-5 branch:

diff --git a/kickstart.py b/kickstart.py
index 3c18853..4340d72 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -569,6 +569,10 @@ class AnacondaKSHandlers(KickstartHandlers):
def doTimezone(self, args):
KickstartHandlers.doTimezone(self, args)
dict = self.ksdata.timezone
+ tzfile = "/usr/share/zoneinfo" + dict["timezone"]
+ if not os.access(tzfile, os.R_OK):
+ log.warning("Can't read timezone file set in kickstart, will ask")
+ return

self.id.instClass.setTimezoneInfo(self.id, dict["timezone"], dict["isUtc"])
self.skipSteps.append("timezone")
diff --git a/timezone.py b/timezone.py
index d63fcfb..7bab9f9 100644
--- a/timezone.py
+++ b/timezone.py
@@ -13,6 +13,7 @@

import shutil
import iutil
+import os
from flags import flags

import logging
@@ -37,10 +38,13 @@ class Timezone:

fromFile = instPath + "/usr/share/zoneinfo/" + self.tz

- try:
- shutil.copyfile(fromFile, instPath + "/etc/localtime")
- except OSError, (errno, msg):
- log.error("Error copying timezone (from %s): %s" % (fromFile, msg))
+ if not os.access(fromFile, os.R_OK):
+ log.error("Timezone to be copied (%s) doesn't exist" % fromFile)
+ else:
+ try:
+ shutil.copyfile(fromFile, instPath + "/etc/localtime")
+ except OSError, (errno, msg):
+ log.error("Error copying timezone (from %s): %s" % (fromFile, msg))

f = open(instPath + "/etc/sysconfig/clock", "w")


Patch against rawhide:

diff --git a/kickstart.py b/kickstart.py
index 7b0ea3d..d71d251 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -705,6 +705,11 @@ class Timezone(commands.timezone.FC6_Timezone):
def parse(self, args):
commands.timezone.FC6_Timezone.parse(self, args)

+ tzfile = "/usr/share/zoneinfo" + self.timezone
+ if not os.access(tzfile, os.R_OK):
+ log.warning("Can't read timezone file set in kickstart, will ask")
+ return
+
self.handler.id.timezone.setTimezoneInfo(self.time zone, self.isUtc)
self.handler.skipSteps.append("timezone")

diff --git a/timezone.py b/timezone.py
index 3960d81..1ed7491 100644
--- a/timezone.py
+++ b/timezone.py
@@ -19,6 +19,7 @@

import shutil
import iutil
+import os
from flags import flags

import logging
@@ -43,10 +44,13 @@ class Timezone:

fromFile = instPath + "/usr/share/zoneinfo/" + self.tz

- try:
- shutil.copyfile(fromFile, instPath + "/etc/localtime")
- except OSError, (errno, msg):
- log.error("Error copying timezone (from %s): %s" % (fromFile, msg))
+ if not os.access(fromFile, os.R_OK):
+ log.error("Timezone to be copied (%s) doesn't exist" % fromFile)
+ else:
+ try:
+ shutil.copyfile(fromFile, instPath + "/etc/localtime")
+ except OSError, (errno, msg):
+ log.error("Error copying timezone (from %s): %s" % (fromFile, msg))

f = open(instPath + "/etc/sysconfig/clock", "w")


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 06-18-2008, 11:53 AM
Joel Andres Granados
 
Default check values of kickstart option timezone

Looks good to me

Radek Vykydal wrote:
Hi,

this patch should solve unhandled exception caused by invalid value
of kickstart option timezone (bug #404321).

Why this way:

The timezone value read from ks can be checked
(by checking the presence of respective timezone file in usr/share/zoneinfo):

1) when reading ks
2) in setuptime step (where it actually is checked now)
3) in writeconfig step (where it raises IOError which is subj of this bug)
4) in firstboot date module

I think the cleanest way is to check it in 1), because then, in case of
invalid value, you can ask the user for a valid one in timezone step. This is
what the patch of kickstart.py does.

Other possibility is to defer the check to 3) with an advantage of wider
choice of installed timezone files (/mnt/sysimage/usr/share/zoneinfo).
Then, in case of invalid value, there would be 2 options:
- some default ('America/New_York') value would be set in /etc/sysconfig/clock
and /etc/localtime (otherwise the exception would be raised by system-config-date
during firstboot date configuration)
- or the invalid value from ks would be saved into /etc/sysconfig/clock,
/etc/localtime would not be copied, and firstboot module date would check
these values and in case of being invalid display also timezone
tab in firstboot date selection window.

The patch adds also checking in 3) (timezone.py patch), but only to defer

the raise of exception (which should never happen with checking in 1) and asking)
to firstboot phase where it can eventually be 'solved' with reconfig.
Well, I am not sure if this second patch is necessary/justifiable.


If the ability to set the timezone to some value available only in installed
packages (ignore invalid value in 1), check in 3)) was really desired,
I'd add an option to ks for it?

Radek Vykydal



Patch against rhel-5 branch:

diff --git a/kickstart.py b/kickstart.py
index 3c18853..4340d72 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -569,6 +569,10 @@ class AnacondaKSHandlers(KickstartHandlers):
def doTimezone(self, args):
KickstartHandlers.doTimezone(self, args)
dict = self.ksdata.timezone
+ tzfile = "/usr/share/zoneinfo" + dict["timezone"]
+ if not os.access(tzfile, os.R_OK):
+ log.warning("Can't read timezone file set in kickstart, will ask")
+ return

self.id.instClass.setTimezoneInfo(self.id, dict["timezone"], dict["isUtc"])
self.skipSteps.append("timezone")
diff --git a/timezone.py b/timezone.py
index d63fcfb..7bab9f9 100644

--- a/timezone.py
+++ b/timezone.py
@@ -13,6 +13,7 @@

import shutil
import iutil
+import os
from flags import flags

import logging
@@ -37,10 +38,13 @@ class Timezone:

fromFile = instPath + "/usr/share/zoneinfo/" + self.tz

- try:
- shutil.copyfile(fromFile, instPath + "/etc/localtime")
- except OSError, (errno, msg):
- log.error("Error copying timezone (from %s): %s" % (fromFile, msg))
+ if not os.access(fromFile, os.R_OK):
+ log.error("Timezone to be copied (%s) doesn't exist" % fromFile)
+ else:
+ try:
+ shutil.copyfile(fromFile, instPath + "/etc/localtime")
+ except OSError, (errno, msg):
+ log.error("Error copying timezone (from %s): %s" % (fromFile, msg))

f = open(instPath + "/etc/sysconfig/clock", "w")


Patch against rawhide:

diff --git a/kickstart.py b/kickstart.py
index 7b0ea3d..d71d251 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -705,6 +705,11 @@ class Timezone(commands.timezone.FC6_Timezone):
def parse(self, args):
commands.timezone.FC6_Timezone.parse(self, args)

+ tzfile = "/usr/share/zoneinfo" + self.timezone
+ if not os.access(tzfile, os.R_OK):
+ log.warning("Can't read timezone file set in kickstart, will ask")
+ return
+
self.handler.id.timezone.setTimezoneInfo(self.time zone, self.isUtc)
self.handler.skipSteps.append("timezone")

diff --git a/timezone.py b/timezone.py
index 3960d81..1ed7491 100644
--- a/timezone.py
+++ b/timezone.py
@@ -19,6 +19,7 @@

import shutil
import iutil
+import os
from flags import flags

import logging
@@ -43,10 +44,13 @@ class Timezone:

fromFile = instPath + "/usr/share/zoneinfo/" + self.tz

- try:
- shutil.copyfile(fromFile, instPath + "/etc/localtime")
- except OSError, (errno, msg):
- log.error("Error copying timezone (from %s): %s" % (fromFile, msg))
+ if not os.access(fromFile, os.R_OK):
+ log.error("Timezone to be copied (%s) doesn't exist" % fromFile)
+ else:
+ try:
+ shutil.copyfile(fromFile, instPath + "/etc/localtime")
+ except OSError, (errno, msg):
+ log.error("Error copying timezone (from %s): %s" % (fromFile, msg))

f = open(instPath + "/etc/sysconfig/clock", "w")


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


--
Joel Andres Granados
Red Hat / Brno, Czech Republic

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 03:36 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org