Bug#443743: gnome-utils: gnome-system-log gives a bad error message if file fails to open

Jack Grahl jack.grahl at yahoo.co.uk
Sun Sep 23 18:31:57 UTC 2007


Package: gnome-utils
Version: 2.14.0.dfsg-5
Severity: minor
Tags: patch


I have patched the gnome-utils source to fix a bug with the 
"gnome-system-log" app for displaying system logs (called 'logview' in 
the source tree). At the moment if the program cannot either open or 
parse a file, it gives the error message "<filename> is not a log file". 
This is a bit unuseful if your file couldn't be opened for some other 
reason, eg permissions. The patch fixes this so that there are several 
different possible error messages. This fixes bug #349756 reported on 
bugs.gnome.org. I will also send a patch to the upstream maintainers.

The patch is against the version on stable, 2.14.0.

diff -ru o/gnome-utils-2.14.0.dfsg/logview/logrtns.c 
gnome-utils-2.14.0.dfsg/logview/logrtns.c
--- o/gnome-utils-2.14.0.dfsg/logview/logrtns.c    2005-11-23 
19:30:00.000000000 +0000
+++ gnome-utils-2.14.0.dfsg/logview/logrtns.c    2007-09-06 
03:15:15.000000000 +0100
@@ -36,7 +36,7 @@

char *error_main = N_("One file or more could not be opened");

-static LogStats *log_stats_new (char *filename, gboolean show_error);
+static int log_stats_new (LogStats **stats_ref, char *filename, 
gboolean show_error);

/* File checking */

@@ -104,12 +104,13 @@
file_is_log (char *filename, gboolean show_error)
{
     LogStats *stats;
+    int s;

     if (filename == NULL)
         return;

-    stats = log_stats_new (filename, show_error);
-    if (stats==NULL)
+    s = log_stats_new (&stats, filename, show_error);
+    if (s!=0)
         return FALSE;
     else {
         g_free (stats);
@@ -299,11 +300,11 @@
/*
    log_stats_new
    Read the log and get some statistics from it.
-   Returns NULL if the file is not a log.
+   Returns an non-zero error code if it cannot open or parse the file.
*/

-static LogStats *
-log_stats_new (char *filename, gboolean show_error)
+static int
+log_stats_new (LogStats** stats_ref, char *filename, gboolean 
show_error)
{
    GnomeVFSResult result;
    GnomeVFSFileInfo *info;
@@ -314,12 +315,12 @@
    char *found_space;

    if (filename == NULL)
-       return NULL;
+       return 1;

    /* Read first line and check that it is text */
    result = gnome_vfs_open (&handle, filename, GNOME_VFS_OPEN_READ);
    if (result != GNOME_VFS_OK) {
-       return NULL;
+          return 2;
    }

    info = gnome_vfs_file_info_new ();
@@ -327,20 +328,20 @@
    if (result != GNOME_VFS_OK || info->type != 
GNOME_VFS_FILE_TYPE_REGULAR) {
        gnome_vfs_file_info_unref (info);
        gnome_vfs_close (handle);
-       return NULL;
+           return -1;
    }

    result = gnome_vfs_read (handle, buff, sizeof(buff), &size);
    gnome_vfs_close (handle);
    if (result != GNOME_VFS_OK) {
        gnome_vfs_file_info_unref (info);
-       return NULL;
+       return -1;
    }
    
    found_space = g_strstr_len (buff, 1024, " ");
    if (found_space == NULL) {
        gnome_vfs_file_info_unref (info);
-       return NULL;
+       return -1;
    }
    
    stats = g_new (LogStats, 1);  
@@ -348,7 +349,8 @@
    stats->file_size = info->size;
    gnome_vfs_file_info_unref (info);

-   return (stats);
+   *stats_ref = stats;
+   return (0);
}

Log *
@@ -361,13 +363,14 @@
    int i, size;
    GList *days;
    Log *log;
+   int err;
    
-   stats = log_stats_new (filename, show_error);
-   if (stats == NULL) {
+   err = log_stats_new (&stats, filename, show_error);
+   if (err != 0) {
        if (file_is_zipped (filename)) {    
            zipped_name = g_strdup_printf ("%s#gzip:", filename);
-           stats = log_stats_new (filename, show_error);
-           if (stats == NULL) {
+       err = log_stats_new (&stats, filename, show_error);
+       if (err != 0) {
                opened = FALSE;
            }
        } else
@@ -375,8 +378,17 @@
    }
    
    if (opened == FALSE) {
+     switch( err ) {
+     case 2:
+       error_message = g_strdup_printf (_("File with no name"));
+       goto error;
+     case 1:
+       error_message = g_strdup_printf (_("Could not open file %s"), 
filename);
+       goto error;
+     default:
        error_message = g_strdup_printf (_("%s is not a log file."), 
filename);
        goto error;
+     }
    }

    log = g_new0 (Log, 1);  
@@ -475,7 +487,7 @@
void log_stats_reload (Log *log)
{
   g_free (log->stats);
-  log->stats = log_stats_new (log->name, TRUE);
+  log_stats_new (&log->stats, log->name, TRUE);
}

/* log_read_new_lines */

---end of patch---


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18jack-100907
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)

Versions of packages gnome-utils depends on:
ii  e2fslibs 1.39+1.40-WIP-2006.11.14+dfsg-2 ext2 filesystem libraries
ii  gconf2   2.16.1-1                        GNOME configuration database syste
ii  libart-2 2.3.17-1                        Library of functions for 2D graphi
ii  libatk1. 1.12.4-3                        The ATK accessibility toolkit
ii  libaudio 0.2.6-6                         Open-source version of SGI's audio
ii  libavahi 0.6.16-3etch1                   Avahi client library
ii  libavahi 0.6.16-3etch1                   Avahi common library
ii  libavahi 0.6.16-3etch1                   Avahi glib integration library
ii  libbonob 2.14.0-3                        Bonobo CORBA interfaces library
ii  libbonob 2.14.0-5                        The Bonobo UI library
ii  libc6    2.3.6.ds1-13etch2               GNU C Library: Shared libraries
ii  libcairo 1.2.4-4                         The Cairo 2D vector graphics libra
ii  libdbus- 1.0.2-1                         simple interprocess messaging syst
ii  libesd0  0.2.36-3                        Enlightened Sound Daemon - Shared 
ii  libfontc 2.4.2-1.2                       generic font configuration library
ii  libfreet 2.2.1-5+etch1                   FreeType 2 font engine, shared lib
ii  libgconf 2.16.1-1                        GNOME configuration database syste
ii  libgcryp 1.2.3-2                         LGPL Crypto library - runtime libr
ii  libglade 1:2.6.0-4                       library to load .glade files at ru
ii  libglib2 2.12.4-2                        The GLib library of C routines
ii  libgnome 2.14.3-2                        Utility library for loading .deskt
ii  libgnome 0.6.0-3                         GNOME keyring services library
ii  libgnome 2.16.0-2                        The GNOME 2 library - runtime file
ii  libgnome 2.14.0-2                        A powerful object-oriented display
ii  libgnome 2.12.1-7                        The GNOME 2.2 print architecture -
ii  libgnome 2.12.1-4                        GNOME 2.2 print architecture User 
ii  libgnome 2.14.1-2                        The GNOME 2 libraries (User Interf
ii  libgnome 1:2.14.2-7                      GNOME virtual file-system (runtime
ii  libgnutl 1.4.4-3                         the GNU TLS library - runtime libr
ii  libgpg-e 1.4-1                           library for common error values an
ii  libgtk2. 2.8.20-7                        The GTK+ graphical user interface 
ii  libhal1  0.5.8.1-9                       Hardware Abstraction Layer - share
ii  libice6  1:1.0.1-2                       X11 Inter-Client Exchange library
ii  libjpeg6 6b-13                           The Independent JPEG Group's JPEG 
ii  liborbit 1:2.14.3-0.2                    libraries for ORBit2 - a CORBA ORB
ii  libpanel 2.14.3-5                        library for GNOME 2 panel applets
ii  libpango 1.14.8-5                        Layout and rendering of internatio
ii  libpng12 1.2.15~beta5-1                  PNG library - runtime
ii  libpopt0 1.10-3                          lib for parsing cmdline parameters
ii  libsm6   1:1.0.1-3                       X11 Session Management library
ii  libstart 0.8-2                           library for program launch feedbac
ii  libtasn1 0.3.6-2                         Manage ASN.1 structures (runtime)
ii  libx11-6 2:1.0.3-7                       X11 client-side library
ii  libxcurs 1.1.7-4                         X cursor management library
ii  libxext6 1:1.0.1-2                       X11 miscellaneous extension librar
ii  libxfixe 1:4.0.1-5                       X11 miscellaneous 'fixes' extensio
ii  libxi6   1:1.0.1-4                       X11 Input extension library
ii  libxiner 1:1.0.1-4.1                     X11 Xinerama extension library
ii  libxml2  2.6.27.dfsg-1                   GNOME XML library
ii  libxrand 2:1.1.0.2-5                     X11 RandR extension library
ii  libxrend 1:0.9.1-3                       X Rendering Extension client libra
ii  scrollke 0.3.14-13                       A free electronic cataloging syste
ii  zlib1g   1:1.2.3-13                      compression library - runtime

Versions of packages gnome-utils recommends:
ii  gksu                          2.0.0-1    graphical frontend to su

-- no debconf information






More information about the pkg-gnome-maintainers mailing list