[PATCH] BUG 172567 support non ASCII user name to login in

潘卫平 wppan at redflag-linux.com
Mon Oct 13 04:38:57 BST 2008


This patch is for BUG 172567 .

Hi all,
I believe KDE should allow non-ASCII user name to login in computer.

I am chinese, so I want use chinese user name to login in my computer.
I find out that we only need to add a QCoreApplication object to
kdeinit4 and kstartupconfig4 program to achieve it, and I made two
simple patches.

I add a user "潘" by kuser(compiled from svn), and I set
Language=zh_CN.UTF-8
in /etc/kde/kdm/kdmrc.

restart X, kdm displays my name "潘" perfectly, but when I input my
password, login,
a message box shows "Could not start kstartupconfig4. Check your
installation."

Then I login in safe mode, run kdeinit4, got some error messages:
"
trying to create local folder /home/.kde: Permission denied
trying to create local folder /home/.kde: Permission denied
Link points to "/tmp/ksocket-潘"
trying to create local folder /home/.kde: Permission denied
kdeinit4: Aborting. bind() failed: : No such file or directory
Could not bind to socket
'/home/.kde/socket-localhost.localdomain/kdeinit4__0'
"

I infer that kdeinit4 doesn't get my "HOME" environment correctly, so it
tries to create local folder in /home/.kde, of course "Permission denied".

Then I look into why kdeinit4 doesn't get my "HOME" environment correctly.
>From the error messages, we could learn that maybe kdeinit4 exits when
binding a socket.

in kdelibs/kinit/kinit.cpp I find that:
1562 QByteArray socketName =
QFile::encodeName(KStandardDirs::locateLocal("socket", QString("kde
init4_%1").arg(QLatin1String(display)), *s_instance));

kdeinit_library_path() calls KStandardDirs::locateLocal to locate the
socket.
After I see how KStandardDirs::locateLocal is implemented I find that in
kdelibs/kdecore/kernel/kstandarddirs.cpp
KStandardDirs::addKDEDefaults() calls QDir::homePath() to get "HOME"
environment variable.
1499 #if defined(Q_WS_MACX)
1500 localKdeDir = QDir::homePath() +
QLatin1String("/Library/Preferences/KDE/");
1501 #elif defined(Q_WS_WIN)
1502 WCHAR wPath[MAX_PATH+1];
1503 if ( SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL,
SHGFP_TYPE_CURRENT, wPath) == S_OK) {
1504 localKdeDir = QString::fromUtf16((const ushort *) wPath) +
QLatin1Char('/') + KDE_DE FAULT_HOME + QLatin1Char('/');
1505 } else {
1506 localKdeDir = QDir::homePath() + QLatin1Char('/') +
KDE_DEFAULT_HOME + QLatin1Char( '/');
1507 }
1508 #else
1509 localKdeDir = QDir::homePath() + QLatin1Char('/') +
KDE_DEFAULT_HOME + QLatin1Char('/ ');
1510 #endif

Because kdeinit4 is a C++ program, it doesn't initialize any
QApplication instance, which cause that QDir::homePath() doesn't get the
correct "HOME" environment variable.

So I add a QCoreApplication in kdelibs/kinit/kinit.cpp and
kdebase/workspace/kstartupconfig/kdostartupconfig.cpp.

Then it works. Now I can use my own chinese name "潘" to login in my
computer.

In QT manual I find following descriptions:
http://doc.trolltech.com/4.4/qcoreapplication.html
"
QCoreApplication contains the main event loop, where all events from the
operating system (e.g., timer and network events) and other sources are
processed and dispatched. It also handles the application's
initialization and finalization, as well as system-wide and
application-wide settings.

Some Qt classes, such as QString, can be used without a QCoreApplication
object. However, in general, we recommend that you create a
QCoreApplication or a QApplication object in your main() function as
early as possible. The application will enter the event loop when exec()
is called. exit() will not return until the event loop exits, e.g., when
quit() is called.
"

kdeinit4 and kstartupconfig don't create a QCoreApplication, maybe it
would lead some encoding problems, I guess.


The kdeinit4.patch should apply to the directory kdelibs/kinit/
and kstartupconfig4.patch should apply to
kdebase/workspace/kstartupconfig/ .

Best regards

pwp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdeinit4.patch
Type: text/x-patch
Size: 567 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081013/13db2693/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kstartupconfig4.patch
Type: text/x-patch
Size: 778 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081013/13db2693/attachment-0001.bin>


More information about the kde-core-devel mailing list