add more spacing
[personal-kdebase.git] / workspace / kcontrol / kfontinst / kio / SuProc.cpp
blobbc03ee5aee58ce6b71ce1b9dcd75c0b7aa36b2c9
1 /*
2 * KFontInst - KDE Font Installer
4 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
6 * ----
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "SuProc.h"
25 #include "KfiConstants.h"
26 #include <QtCore/QFile>
27 #include <KDE/KShell>
28 #include <KDE/KStandardDirs>
29 #include <KDE/SuProcess>
30 #include <KDE/KDebug>
31 #include <unistd.h>
32 #include <config-workspace.h>
34 namespace KFI
37 CSuProc::CSuProc(QByteArray &sock, QString &passwd)
38 : itsPasswd(passwd)
40 QString exe(KStandardDirs::findExe(QLatin1String("kio_fonts_helper"), KStandardDirs::installPath("libexec")));
42 if(exe.isEmpty())
43 kError(7000) << "Could not locate kio_fonts_helper";
44 else
46 itsCmd=QByteArray(QFile::encodeName(KShell::quoteArg(exe)));
48 itsCmd+=' ';
49 itsCmd+=QFile::encodeName(KShell::quoteArg(sock));
50 itsCmd+=' ';
51 itsCmd+=QString().setNum(getuid()).toLatin1();
55 void CSuProc::run()
57 if(!itsCmd.isEmpty())
59 KDESu::SuProcess proc(KFI_SYS_USER);
60 proc.setCommand(itsCmd);
61 proc.exec(itsPasswd.toLocal8Bit());