From nobody@FreeBSD.org  Sat Oct 30 15:54:53 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 57A59106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Oct 2010 15:54:53 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 2A91D8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Oct 2010 15:54:53 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o9UFsqCi042351
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Oct 2010 15:54:52 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o9UFsqgW042344;
	Sat, 30 Oct 2010 15:54:52 GMT
	(envelope-from nobody)
Message-Id: <201010301554.o9UFsqgW042344@www.freebsd.org>
Date: Sat, 30 Oct 2010 15:54:52 GMT
From: daniele <glimp@live.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: sysutils/kiconvtool: I don't know how to load the pair (UTF-8 -> _wctype)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         151833
>Category:       ports
>Synopsis:       sysutils/kiconvtool: I don't know how to load the pair (UTF-8 -> _wctype)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    amdmi3
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 30 16:00:26 UTC 2010
>Closed-Date:    Wed Sep 07 23:54:45 UTC 2011
>Last-Modified:  Wed Sep 07 23:54:45 UTC 2011
>Originator:     daniele
>Release:        8.1-RELEASE #0
>Organization:
>Environment:
FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010     root@:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
As a standard user I could not succesfully execute 

'mount_msdosfs -L en_US.UTF-8 /dev/da0s1 local/mnt'

I installed kiconvtool and added the following lines to /etc/rc.conf 

kiconv_preload="YES"
kiconv_local_charsets="UTF-8"
kiconv_foreign_charsets="UTF-16BE UTF-8"

Even with this I could not execute the preceding command as a standard user.

Taking a look at the code I discovered that "mount_msdosfs -L en_US.UTF-8 /dev/da0s1 local/mnt" when starts up sets its locale to en_US.UTF-8 [1]. And this leads to loading also the pair (UTF-8,_wctype) [2]. So, apparently, if that pair is not loaded, standard users can not execute the preceding command.

At this point the problem that arises is that at command line I do not know how to specify the charset _wctype (unless this is not possible) and feed kiconvtool. 

To solve the problem, I then modified kiconvtool (explained below) so that the pair (UTF-8, _wctype) is loaded automatically.

d

[1] /usr/src/sbin/mount_msdosfs/mount_msdosfs.c    - Line 114
[2] /usr/src/lib/libkiconv/xlat16_iconv.c          - Line 123








>How-To-Repeat:

>Fix:
The workaround to solve this __specific__ problem was to apply the following patch and rebuild kiconvtool. 
Please *note* that this patch is not intended for general usage but just to give an idea of a base to further improve the port in case it is not possible to specify _wctype at command line (or to remove the requirement).

--- kiconvtool.c	2010-10-30 17:18:32.000000000 +0200
+++ kiconvtool.new	2010-10-30 17:18:32.000000000 +0200
@@ -35,6 +35,7 @@
 #include <sys/sysctl.h>
 #include <string.h>
 #include <memstat.h>
+#include <locale.h>
 
 enum arg_type_t_ {
 	ARGTYPE_LOCAL,
@@ -185,6 +186,7 @@
 		return 1;
 	}
 
+	setlocale(LC_CTYPE, "en_US.UTF-8");
 	enum arg_type_t_ arg_type = ARGTYPE_PAIR;
 	for (i = 1; i < argc; i++) {
 		if (argv[i][0] == '-') {


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->amdmi3 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sat Oct 30 16:00:33 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151833 
State-Changed-From-To: open->closed 
State-Changed-By: amdmi3 
State-Changed-When: Wed Sep 7 23:54:44 UTC 2011 
State-Changed-Why:  
Should be fixed with 0.95 update 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151833 
>Unformatted:
