summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2011-03-04 14:43:20 +0100
committerAles Kozumplik <akozumpl@redhat.com>2011-03-07 09:07:00 +0100
commit23b7d2c8862f0ffed2dba038ddf4e223f4a42002 (patch)
tree50461655d5877e736ad745460910c1f76db0c253 /loader
parentd3af47fb68a5b6c58fd022fadecf39aedfcdab13 (diff)
Another fix for the loader translations.
Fixes a sigsegv in loadLanguage(). While at it make sure /tmp/translations is really removed (frees some 700kB of the ramdisk). Resolves: rhbz#682213
Diffstat (limited to 'loader')
-rw-r--r--loader/lang.c25
-rw-r--r--loader/loadermisc.c2
2 files changed, 10 insertions, 17 deletions
diff --git a/loader/lang.c b/loader/lang.c
index 4caaeeb2c..6fe5c59e1 100644
--- a/loader/lang.c
+++ b/loader/lang.c
@@ -142,7 +142,8 @@ int getLangInfo(struct langInfo ** langs) {
return numLanguages;
}
-void loadLanguage (char * file) {
+void loadLanguage(void)
+{
char *filename;
int fd, hash, rc;
char * key = getenv("LANGKEY");
@@ -151,31 +152,20 @@ void loadLanguage (char * file) {
free(strings), strings = NULL;
numStrings = allocedStrings = 0;
}
-
+
/* english requires no files */
if (!strcmp(key, "en"))
return;
- if (!file) {
- file = filename;
- sprintf(filename, "/etc/loader.tr");
- }
-
- if (access(file, R_OK) == -1) {
- newtWinMessage("Error", "OK", "Translation for %s is not available. "
- "The Installation will proceed in English.", key);
- return ;
- }
+ checked_asprintf(&filename, "/tmp/translation/%s.tr", key);
rc = unpack_archive_file("/etc/loader.tr", "/tmp/translation");
-
if (rc != ARCHIVE_OK || access("/tmp/translation", R_OK) == -1) {
newtWinMessage("Error", "OK", "Cannot get translation file %s.\n",
filename);
return;
}
- checked_asprintf(&filename, "/tmp/translation/%s.tr", key);
fd = open(filename, O_RDONLY);
if (fd < 0) {
newtWinMessage("Error", "OK", "Failed to open /tmp/translation: %m\n");
@@ -200,7 +190,10 @@ void loadLanguage (char * file) {
close(fd);
free(filename);
- unlink("/tmp/translation");
+ int translation_dir_fd = open("/tmp/translation", O_RDONLY);
+ recursiveRemove(translation_dir_fd);
+ close(translation_dir_fd);
+ rmdir("/tmp/translation");
qsort(strings, numStrings, sizeof(*strings), aStringCmp);
}
@@ -222,7 +215,7 @@ static void setLangEnv (int i) {
setenv("LANG", languages[i].lc_all, 1);
setenv("LANGKEY", languages[i].key, 1);
setenv("LINGUAS", languages[i].lang, 1);
- loadLanguage (NULL);
+ loadLanguage();
}
/* choice is the index of the chosen language in languages */
diff --git a/loader/loadermisc.c b/loader/loadermisc.c
index d0ff3d408..61e77bf04 100644
--- a/loader/loadermisc.c
+++ b/loader/loadermisc.c
@@ -93,7 +93,7 @@ int copyFile(char * source, char * dest) {
* Do "rm -rf" on the target directory.
*
* Returns 0 on success, nonzero otherwise (i.e. directory doesn't exist or
- * some of its contents couldn't be removed.
+ * some of its contents couldn't be removed).
*
* This is copied from the util-linux-ng project.
*/