Bug 132421 - kxkb multiuserproblem with files in /tmp
Summary: kxkb multiuserproblem with files in /tmp
Status: RESOLVED FIXED
Alias: None
Product: kxkb
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Andriy Rysin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-14 22:07 UTC by Bernd Schubert
Modified: 2006-08-26 02:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
patch to fix the problem (1.43 KB, patch)
2006-08-20 17:50 UTC, Bernd Schubert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Schubert 2006-08-14 22:07:26 UTC
Version:           unknown (using KDE 3.5.4, Debian Package 4:3.5.4-3 (testing/unstable))
OS:                Linux

Hi,

kxkb creates {layoutname}.xkm files in /tmp. Now think of a multi-usersystem as with xdmcp. Since those *.xkm files won't be deleted, only one user can create them. For all other users there's a problem.
I have a patch for kdebase-3.3.2 of Debian Sarge adding a .username to the filename. However, it looks rather C stylish.

Thanks,
Bernd
Comment 1 Bernd Schubert 2006-08-20 17:50:44 UTC
Created attachment 17429 [details]
patch to fix the problem

patch for kde 3.5.4
Comment 2 Krzysztof Lichota 2006-08-24 16:41:29 UTC
I don't have any *.xkm files in my /tmp directory. It seems your configuration is broken, temporary directory is taken from KDE configuration:
KGlobal::dirs()->findDirs ( "tmp", "")
Comment 3 Bernd Schubert 2006-08-24 18:38:47 UTC
On Thursday 24 August 2006 16:41, Krzysztof Lichota wrote:
[bugs.kde.org quoted mail]

That means its broken for about 50 users of our group, my home workstation and 
my laptop.  I tend to see this as a bug of whatever kind. Maybe debian 
specific?

> configuration: KGlobal::dirs()->findDirs ( "tmp", "")


Well, apperently that fails and doesn't return anything.

	QStringList dirs = KGlobal::dirs()->findDirs ( "tmp", "" );
	m_tempDir = dirs.count() == 0 ? "/tmp/" : dirs[0];

Don't ask me why, I'm just tracing trough the sources and I don't see why 
findDirs() fails. In principle its only  a list provided by 
KStandardDirs::resourceDirs(). To to further unstand that, I would need libs 
with gdb symbols or many couts (if it only wouldn't take ages to compile c++ 
sources), there's even already a debug statement for resourceDirs().

Anyway may I ask why not simply "m_tempDir = KTempDir::name();"  is used?

Cheers,
Bernd
Comment 4 Bernd Schubert 2006-08-24 19:12:01 UTC
>
> Anyway may I ask why not simply "m_tempDir = KTempDir::name();"  is used?
>


Ah, stupid me, that can't work of course, without creating a KTemDir object 
first.
Comment 5 Bernd Schubert 2006-08-25 01:58:22 UTC
> Well, apperently that fails and doesn't return anything.
>
> 	QStringList dirs = KGlobal::dirs()->findDirs ( "tmp", "" );
> 	m_tempDir = dirs.count() == 0 ? "/tmp/" : dirs[0];


Ok, I just run through it with gdb and see that 
KGlobal::dirs()->findDirs ( "tmp", "") returns proper directories. 
Unfortunately dirs[0] = "/tmp/" and dirs[1] = "/tmp/kde-bernd/".

So my question, should I find out why /tmp/ is at the first place or should I 
write a patch inserting an iterator searching for the next dir not 
being "/tmp/"?

Thanks,
Bernd
Comment 6 Bernd Schubert 2006-08-25 20:34:08 UTC
On Friday 25 August 2006 01:58, Bernd Schubert wrote:
> > Well, apperently that fails and doesn't return anything.
> >
> > 	QStringList dirs = KGlobal::dirs()->findDirs ( "tmp", "" );
> > 	m_tempDir = dirs.count() == 0 ? "/tmp/" : dirs[0];
>
> Ok, I just run through it with gdb and see that
> KGlobal::dirs()->findDirs ( "tmp", "") returns proper directories.
> Unfortunately dirs[0] = "/tmp/" and dirs[1] = "/tmp/kde-bernd/".
>
> So my question, should I find out why /tmp/ is at the first place or should
> I write a patch inserting an iterator searching for the next dir not being
> "/tmp/"?


I further read the sources and see that apperently kxkb is the only 
application in kdelibs and kdebase using findDirs("tmp", ...). All other tmp 
files are created by KTempFile(locateLocal("tmp", prefix), extension) or at 
least locateLocal() is used to return the tmp directory.

I think for kde-3.5 at least this patch should be used

--- extension.cpp.old   2006-03-17 11:17:41.000000000 +0100
+++ extension.cpp       2006-08-25 10:34:12.000000000 +0200
@@ -40,8 +40,7 @@
                d = qt_xdisplay();
        m_dpy = d;

-       QStringList dirs = KGlobal::dirs()->findDirs ( "tmp", "" );
-       m_tempDir = dirs.count() == 0 ? "/tmp/" : dirs[0];
+       m_tempDir = locateLocal("tmp", "");
 }

Would it make sense to remove findDirs ( "tmp", ...) support in kde-4.0? So 
far I havn't checked in detail if locateLocal() is using it.

Cheers,
Bernd
Comment 7 Andriy Rysin 2006-08-26 02:40:07 UTC
SVN commit 577258 by rysin:

BUG: 132421
Use locateLocal() to find tmp directory



 M  +3 -2      extension.cpp  


--- branches/KDE/3.5/kdebase/kxkb/extension.cpp #577257:577258
@@ -40,8 +40,9 @@
 		d = qt_xdisplay();
 	m_dpy = d;
 	
-	QStringList dirs = KGlobal::dirs()->findDirs ( "tmp", "" );
-	m_tempDir = dirs.count() == 0 ? "/tmp/" : dirs[0];
+//	QStringList dirs = KGlobal::dirs()->findDirs ( "tmp", "" );
+//	m_tempDir = dirs.count() == 0 ? "/tmp/" : dirs[0];
+	m_tempDir = locateLocal("tmp", "");
 }
 
 bool XKBExtension::init()
Comment 8 Andriy Rysin 2006-08-26 02:45:36 UTC
In my distro tmp chosen is always in home directory so I never seen this as a problem, but I applied the patch and it worked fine so I've commited it.
Thanks for the research Bernd!