Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 132652 - mrtg init-script fails in UTF8 environment
Summary: mrtg init-script fails in UTF8 environment
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Other
: High normal (vote)
Assignee: Gentoo Netmon project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-08 02:20 UTC by cilly
Modified: 2006-05-11 04:03 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for files/mrtg.rc (mrtg.rc.patch,297 bytes, patch)
2006-05-08 14:06 UTC, Angelo Leto
Details | Diff
patch for "files/mrtg.rc" (mrtg.rc.patch,336 bytes, patch)
2006-05-09 02:12 UTC, Angelo Leto
Details | Diff
patch for "files/mrtg.rc" (mrtg.rc.patch,336 bytes, patch)
2006-05-09 02:19 UTC, Angelo Leto
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cilly 2006-05-08 02:20:28 UTC
If LANG is set to utf8, then the init.d script starts, but mrtg quits. The init.d script still says "started". Zapping is needed.

Add:

LANG=C
export LANG

to /etc/init.d/mrtg.
Comment 1 Angelo Leto 2006-05-08 11:12:02 UTC
mrtg will not work properly if LANG=utf8 
(see http://gentoo-wiki.com/HOWTO_SNMP_and_MRTG_Made_Easy#UTF-8).
The file /etc/init.d/mrtg coming with the version 2.11.1 does include the following line at the beginning of the start function:
[[ "${LANG}" == *[uU][tT][fF]?8 ]] && LANG='C'
so it will never start with LANG=utf8.

Comment 2 cilly 2006-05-08 12:13:34 UTC
The line is not working. I still get the UTF-error dialog of mrtg. I had to add LANG at the topmost. Probably, the line is buggy, or it is not working.

I pasted my mods:

# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/mrtg/files/mrtg.rc,v 1.3 2005/06/19 18:24:49 vanquirius Exp $

depend() {
    need net
    
    # if monitoring snmp variables on this machine:
    # use net-snmpd
}

LANG=C
export LANG
 
checkconfig() {
    if [[ ! -f ${MRTG_CONF} ]] ; then
                eerror "Please create ${MRTG_CONF} (try man cfgmaker)"
                return 1
        fi

        mrtg --check ${MRTG_CONF}
        return $?
}

start() {
        # mrtg will not run if LANG=*utf8
        [[ "${LANG}" == *[uU][tT][fF]?8 ]] && LANG='C'

        checkconfig || return $?

... cut ...
Comment 3 cilly 2006-05-08 12:26:53 UTC
Here is my setting of LANG:

echo $LANG
en_US.utf8

Probably, the language string has changed and does not match the pattern anymore.
Comment 4 Angelo Leto 2006-05-08 14:06:23 UTC
Created attachment 86444 [details, diff]
patch for files/mrtg.rc

This reg. exp. should fit for all the needed cases:
[[ "${LANG}" == *[uU][tT][fF]8 ]] && LANG='C'
Comment 5 Jens-Uwe Mager 2006-05-08 14:42:10 UTC
If I look at what is possible to set the LANG variable to on my Gentoo machine:

jum@shadow ~ $ locale -a
C
POSIX
de_DE
de_DE.utf8
de_DE@euro
de_DE@euro.UTF-8
en_US
en_US.utf8
jum@shadow ~ $ locale -m |grep -i utf
UTF-8


then an optional dash between utf and 8 should be allowed as well.
Comment 6 Angelo Leto 2006-05-09 02:12:28 UTC
Created attachment 86464 [details, diff]
patch for "files/mrtg.rc"

This reg. exp. should work better ;)
[[ "${LANG}" =~ '((^[A-Za-z0-9\_\@\-]+\.)|(^))([uU][tT][fF]-?8)$' ]]
Comment 7 Angelo Leto 2006-05-09 02:19:56 UTC
Created attachment 86465 [details, diff]
patch for "files/mrtg.rc"

This reg. exp. should work better ;)
[[ "${LANG}" =~ '((^[A-Za-z0-9\_\@\-]+\.)|(^))([uU][tT][fF]-?8)$' ]]
Comment 8 Angelo Leto 2006-05-09 02:23:42 UTC
Comment on attachment 86444 [details, diff]
patch for files/mrtg.rc

new reg. exp. produced.
Comment 9 Daniel Black (RETIRED) gentoo-dev 2006-05-11 03:08:50 UTC
Angelo,
I've heard a-z is bad in regex as it doesn't include the entire language in some alphabets (e.g. ethopian)
Is [[:alphanum:]] or something possible?
Comment 10 Daniel Black (RETIRED) gentoo-dev 2006-05-11 04:03:52 UTC
ignore previous comment. fixed in 2.13.2-r2 thanks Angelo