summaryrefslogtreecommitdiffstats
path: root/k3bsetup
diff options
context:
space:
mode:
Diffstat (limited to 'k3bsetup')
-rw-r--r--k3bsetup/Makefile.am18
-rw-r--r--k3bsetup/base_k3bsetup2.ui380
-rw-r--r--k3bsetup/k3bsetup20
-rw-r--r--k3bsetup/k3bsetup2.cpp560
-rw-r--r--k3bsetup/k3bsetup2.desktop148
-rw-r--r--k3bsetup/k3bsetup2.h65
6 files changed, 1191 insertions, 0 deletions
diff --git a/k3bsetup/Makefile.am b/k3bsetup/Makefile.am
new file mode 100644
index 0000000..42d3bee
--- /dev/null
+++ b/k3bsetup/Makefile.am
@@ -0,0 +1,18 @@
+AM_CPPFLAGS = -I$(srcdir)/../src -I$(srcdir)/../libk3b/core -I$(srcdir)/../libk3b/tools -I$(srcdir)/../libk3bdevice $(all_includes)
+
+METASOURCES = AUTO
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = kcm_k3bsetup2.la
+
+kcm_k3bsetup2_la_SOURCES = base_k3bsetup2.ui k3bsetup2.cpp
+kcm_k3bsetup2_la_LIBADD = $(LIB_KDEUI) ../libk3b/libk3b.la
+kcm_k3bsetup2_la_LDFLAGS = -module -avoid-version $(all_libraries) -no-undefined
+
+k3bsetup2_DATA = k3bsetup2.desktop
+k3bsetup2dir = $(kde_appsdir)/Settings/System
+
+bin_SCRIPTS = k3bsetup
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/k3bsetup.pot
diff --git a/k3bsetup/base_k3bsetup2.ui b/k3bsetup/base_k3bsetup2.ui
new file mode 100644
index 0000000..05af5fd
--- /dev/null
+++ b/k3bsetup/base_k3bsetup2.ui
@@ -0,0 +1,380 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>base_K3bSetup2</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>500</width>
+ <height>450</height>
+ </rect>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Settings</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_checkUseBurningGroup</cstring>
+ </property>
+ <property name="text">
+ <string>Use burning group:</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;If this option is checked, only the users in the specified group will be able to burn CDs and DVDs, since only they will have access to the devices and the CD recording programs used by K3b.&lt;/p&gt;
+&lt;p&gt;Otherwise all users on the system have access to the devices and to all K3b functionality.</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>m_editBurningGroup</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>burning</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Users allowed to burn (separated by space):</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>m_editUsers</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Devices</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Check the devices whose permissions you want to be changed</string>
+ </property>
+ </widget>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>Device</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Devicenode</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Permissions</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Permissions</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_viewDevices</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_buttonAddDevice</cstring>
+ </property>
+ <property name="text">
+ <string>Add Device...</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>External Programs</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>tabWidget2</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Found Programs</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Check the programs whose permissions you want to be changed</string>
+ </property>
+ </widget>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>Program</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Version</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Path</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Permissions</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Permissions</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_viewPrograms</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Search Path</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBox">
+ <property name="name">
+ <cstring>m_editSearchPath</cstring>
+ </property>
+ <property name="title">
+ <string>Search Path</string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;qt&gt;&lt;b&gt;Hint:&lt;/b&gt; to force K3b to use another than the default name for the executable specify it in the search path.&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+</widget>
+<connections>
+ <connection>
+ <sender>m_checkUseBurningGroup</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_editBurningGroup</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>m_checkUseBurningGroup</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_editUsers</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+ <includehint>klistview.h</includehint>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/k3bsetup/k3bsetup b/k3bsetup/k3bsetup
new file mode 100644
index 0000000..0851430
--- /dev/null
+++ b/k3bsetup/k3bsetup
@@ -0,0 +1,20 @@
+#
+# $Id: k3bsetup 476230 2005-10-31 23:05:34Z thiago $
+# Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
+#
+# This file is part of the K3b project.
+# Copyright (C) 1998-2003 Sebastian Trueg <trueg@k3b.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# See the file "COPYING" for the exact licensing terms.
+#
+
+
+#!/usr/bin/sh
+
+#TODO: if kdesu not found and not currently root use kdialog to display an error message
+
+kdesu kcmshell k3bsetup2
diff --git a/k3bsetup/k3bsetup2.cpp b/k3bsetup/k3bsetup2.cpp
new file mode 100644
index 0000000..37c23a1
--- /dev/null
+++ b/k3bsetup/k3bsetup2.cpp
@@ -0,0 +1,560 @@
+/*
+ *
+ * $Id: k3bsetup2.cpp 623771 2007-01-15 13:47:39Z trueg $
+ * Copyright (C) 2003-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include <config.h>
+
+#include <qlayout.h>
+#include <qmap.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qscrollview.h>
+#include <qtimer.h>
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kgenericfactory.h>
+#include <klistview.h>
+#include <keditlistbox.h>
+#include <kmessagebox.h>
+#include <kinputdialog.h>
+#include <kstandarddirs.h>
+#include <kconfig.h>
+#include <kdeversion.h>
+#include <ktextedit.h>
+
+#include "k3bsetup2.h"
+#include "base_k3bsetup2.h"
+
+#include <k3bdevicemanager.h>
+#include <k3bdevice.h>
+#include <k3bexternalbinmanager.h>
+#include <k3bdefaultexternalprograms.h>
+#include <k3bglobals.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <grp.h>
+
+
+
+static bool shouldRunSuidRoot( K3bExternalBin* bin )
+{
+ //
+ // Since kernel 2.6.8 older cdrecord versions are not able to use the SCSI subsystem when running suid root anymore
+ // So for we ignore the suid root issue with kernel >= 2.6.8 and cdrecord < 2.01.01a02
+ //
+ // Some kernel version 2.6.16.something again introduced a problem here. Since I do not know the exact version
+ // and a workaround was introduced in cdrecord 2.01.01a05 just use that version as the first for suid root.
+ //
+ // Seems as if cdrdao never had problems with suid root...
+ //
+
+ if( bin->name() == "cdrecord" ) {
+ return ( K3b::simpleKernelVersion() < K3bVersion( 2, 6, 8 ) ||
+ bin->version >= K3bVersion( 2, 1, 1, "a05" ) ||
+ bin->hasFeature( "wodim" ) );
+ }
+ else if( bin->name() == "cdrdao" ) {
+ return true;
+ }
+ else if( bin->name() == "growisofs" ) {
+ //
+ // starting with 6.0 growiofs raises it's priority using nice(-20)
+ // BUT: newer kernels have ridiculously low default memorylocked resource limit, which prevents privileged
+ // users from starting growisofs 6.0 with "unable to anonymously mmap 33554432: Resource temporarily unavailable"
+ // error message. Until Andy releases a version including a workaround we simply never configure growisofs suid root
+ return false; // bin->version >= K3bVersion( 6, 0 );
+ }
+ else
+ return false;
+}
+
+
+class K3bSetup2::Private
+{
+public:
+ K3bDevice::DeviceManager* deviceManager;
+ K3bExternalBinManager* externalBinManager;
+
+ bool changesNeeded;
+
+ QMap<QCheckListItem*, QString> listDeviceMap;
+ QMap<QString, QCheckListItem*> deviceListMap;
+
+ QMap<QCheckListItem*, K3bExternalBin*> listBinMap;
+ QMap<K3bExternalBin*, QCheckListItem*> binListMap;
+
+ KConfig* config;
+};
+
+
+
+K3bSetup2::K3bSetup2( QWidget *parent, const char *, const QStringList& )
+ : KCModule( parent, "k3bsetup" )
+{
+ d = new Private();
+ d->config = new KConfig( "k3bsetup2rc" );
+
+ m_aboutData = new KAboutData("k3bsetup2",
+ "K3bSetup 2",
+ 0, 0, KAboutData::License_GPL,
+ "(C) 2003-2007 Sebastian Trueg");
+ m_aboutData->addAuthor("Sebastian Trueg", 0, "trueg@k3b.org");
+
+ setButtons( KCModule::Apply|KCModule::Cancel|KCModule::Ok|KCModule::Default );
+
+ QHBoxLayout* box = new QHBoxLayout( this );
+ box->setAutoAdd(true);
+ box->setMargin(0);
+ box->setSpacing( KDialog::spacingHint() );
+
+ KTextEdit* label = new KTextEdit( this );
+ label->setText( "<h2>K3bSetup</h2>"
+ + i18n("<p>This simple setup assistant is able to set the permissions needed by K3b in order to "
+ "burn CDs and DVDs. "
+ "<p>It does not take things like devfs or resmgr into account. In most cases this is not a "
+ "problem but on some systems the permissions may be altered the next time you login or restart "
+ "your computer. In those cases it is best to consult the distribution documentation."
+ "<p><b>Caution:</b> Although K3bSetup 2 should not be able "
+ "to mess up your system no guarantee can be given.") );
+ label->setReadOnly( true );
+ label->setFixedWidth( 200 );
+
+ w = new base_K3bSetup2( this );
+
+ // TODO: enable this and let root specify users
+ w->m_editUsers->hide();
+ w->textLabel2->hide();
+
+
+ connect( w->m_checkUseBurningGroup, SIGNAL(toggled(bool)),
+ this, SLOT(updateViews()) );
+ connect( w->m_editBurningGroup, SIGNAL(textChanged(const QString&)),
+ this, SLOT(updateViews()) );
+ connect( w->m_editSearchPath, SIGNAL(changed()),
+ this, SLOT(slotSearchPrograms()) );
+ connect( w->m_buttonAddDevice, SIGNAL(clicked()),
+ this, SLOT(slotAddDevice()) );
+
+
+ d->externalBinManager = new K3bExternalBinManager( this );
+ d->deviceManager = new K3bDevice::DeviceManager( this );
+
+ // these are the only programs that need special permissions
+ d->externalBinManager->addProgram( new K3bCdrdaoProgram() );
+ d->externalBinManager->addProgram( new K3bCdrecordProgram(false) );
+ d->externalBinManager->addProgram( new K3bGrowisofsProgram() );
+
+ d->externalBinManager->search();
+ d->deviceManager->scanBus();
+
+ load();
+
+ //
+ // This is a hack to work around a kcm bug which makes the faulty assumption that
+ // every module starts without anything to apply
+ //
+ QTimer::singleShot( 0, this, SLOT(updateViews()) );
+
+ if( getuid() != 0 || !d->config->checkConfigFilesWritable( true ) )
+ makeReadOnly();
+}
+
+
+K3bSetup2::~K3bSetup2()
+{
+ delete d->config;
+ delete d;
+ delete m_aboutData;
+}
+
+
+void K3bSetup2::updateViews()
+{
+ d->changesNeeded = false;
+
+ updatePrograms();
+ updateDevices();
+
+ emit changed( ( getuid() != 0 ) ? false : d->changesNeeded );
+}
+
+
+void K3bSetup2::updatePrograms()
+{
+ // first save which were checked
+ QMap<K3bExternalBin*, bool> checkMap;
+ QListViewItemIterator listIt( w->m_viewPrograms );
+ for( ; listIt.current(); ++listIt )
+ checkMap.insert( d->listBinMap[(QCheckListItem*)*listIt], ((QCheckListItem*)*listIt)->isOn() );
+
+ w->m_viewPrograms->clear();
+ d->binListMap.clear();
+ d->listBinMap.clear();
+
+ // load programs
+ const QMap<QString, K3bExternalProgram*>& map = d->externalBinManager->programs();
+ for( QMap<QString, K3bExternalProgram*>::const_iterator it = map.begin(); it != map.end(); ++it ) {
+ K3bExternalProgram* p = it.data();
+
+ QPtrListIterator<K3bExternalBin> binIt( p->bins() );
+ for( ; binIt.current(); ++binIt ) {
+ K3bExternalBin* b = *binIt;
+
+ QFileInfo fi( b->path );
+ // we need the uid bit which is not supported by QFileInfo
+ struct stat s;
+ if( ::stat( QFile::encodeName(b->path), &s ) ) {
+ kdDebug() << "(K3bSetup2) unable to stat " << b->path << endl;
+ }
+ else {
+ // create a checkviewitem
+ QCheckListItem* bi = new QCheckListItem( w->m_viewPrograms, b->name(), QCheckListItem::CheckBox );
+ bi->setText( 1, b->version );
+ bi->setText( 2, b->path );
+
+ d->listBinMap.insert( bi, b );
+ d->binListMap.insert( b, bi );
+
+ // check the item on first insertion or if it was checked before
+ bi->setOn( checkMap.contains(b) ? checkMap[b] : true );
+
+ int perm = s.st_mode & 0007777;
+
+ QString wantedGroup("root");
+ if( w->m_checkUseBurningGroup->isChecked() )
+ wantedGroup = burningGroup();
+
+ int wantedPerm = 0;
+ if( shouldRunSuidRoot( b ) ) {
+ if( w->m_checkUseBurningGroup->isChecked() )
+ wantedPerm = 0004710;
+ else
+ wantedPerm = 0004711;
+ }
+ else {
+ if( w->m_checkUseBurningGroup->isChecked() )
+ wantedPerm = 0000750;
+ else
+ wantedPerm = 0000755;
+ }
+
+ bi->setText( 3, QString::number( perm, 8 ).rightJustify( 4, '0' ) + " " + fi.owner() + "." + fi.group() );
+ if( perm != wantedPerm ||
+ fi.owner() != "root" ||
+ fi.group() != wantedGroup ) {
+ bi->setText( 4, QString("%1 root.%2").arg(wantedPerm,0,8).arg(wantedGroup) );
+ if( bi->isOn() )
+ d->changesNeeded = true;
+ }
+ else
+ bi->setText( 4, i18n("no change") );
+ }
+ }
+ }
+}
+
+
+void K3bSetup2::updateDevices()
+{
+ // first save which were checked
+ QMap<QString, bool> checkMap;
+ QListViewItemIterator listIt( w->m_viewDevices );
+ for( ; listIt.current(); ++listIt )
+ checkMap.insert( d->listDeviceMap[(QCheckListItem*)*listIt], ((QCheckListItem*)*listIt)->isOn() );
+
+ w->m_viewDevices->clear();
+ d->listDeviceMap.clear();
+ d->deviceListMap.clear();
+
+ QPtrListIterator<K3bDevice::Device> it( d->deviceManager->allDevices() );
+ for( ; it.current(); ++it ) {
+ K3bDevice::Device* device = *it;
+ // check the item on first insertion or if it was checked before
+ QCheckListItem* item = createDeviceItem( device->blockDeviceName() );
+ item->setOn( checkMap.contains(device->blockDeviceName()) ? checkMap[device->blockDeviceName()] : true );
+ item->setText( 0, device->vendor() + " " + device->description() );
+
+ if( !device->genericDevice().isEmpty() ) {
+ QCheckListItem* item = createDeviceItem( device->genericDevice() );
+ item->setOn( checkMap.contains(device->genericDevice()) ? checkMap[device->genericDevice()] : true );
+ item->setText( 0, device->vendor() + " " + device->description() + " (" + i18n("Generic SCSI Device") + ")" );
+ }
+ }
+}
+
+
+QCheckListItem* K3bSetup2::createDeviceItem( const QString& deviceNode )
+{
+ QFileInfo fi( deviceNode );
+ struct stat s;
+ if( ::stat( QFile::encodeName(deviceNode), &s ) ) {
+ kdDebug() << "(K3bSetup2) unable to stat " << deviceNode << endl;
+ return 0;
+ }
+ else {
+ // create a checkviewitem
+ QCheckListItem* bi = new QCheckListItem( w->m_viewDevices,
+ deviceNode,
+ QCheckListItem::CheckBox );
+
+ d->listDeviceMap.insert( bi, deviceNode );
+ d->deviceListMap.insert( deviceNode, bi );
+
+ bi->setText( 1, deviceNode );
+
+ int perm = s.st_mode & 0000777;
+
+ bi->setText( 2, QString::number( perm, 8 ).rightJustify( 3, '0' ) + " " + fi.owner() + "." + fi.group() );
+ if( w->m_checkUseBurningGroup->isChecked() ) {
+ // we ignore the device's owner here
+ if( perm != 0000660 ||
+ fi.group() != burningGroup() ) {
+ bi->setText( 3, "660 " + fi.owner() + "." + burningGroup() );
+ if( bi->isOn() )
+ d->changesNeeded = true;
+ }
+ else
+ bi->setText( 3, i18n("no change") );
+ }
+ else {
+ // we ignore the device's owner and group here
+ if( perm != 0000666 ) {
+ bi->setText( 3, "666 " + fi.owner() + "." + fi.group() );
+ if( bi->isOn() )
+ d->changesNeeded = true;
+ }
+ else
+ bi->setText( 3, i18n("no change") );
+ }
+
+ return bi;
+ }
+}
+
+
+void K3bSetup2::load()
+{
+ if( d->config->hasGroup("External Programs") ) {
+ d->config->setGroup( "External Programs" );
+ d->externalBinManager->readConfig( d->config );
+ }
+ if( d->config->hasGroup("Devices") ) {
+ d->config->setGroup( "Devices" );
+ d->deviceManager->readConfig( d->config );
+ }
+
+ d->config->setGroup( "General Settings" );
+ w->m_checkUseBurningGroup->setChecked( d->config->readBoolEntry( "use burning group", false ) );
+ w->m_editBurningGroup->setText( d->config->readEntry( "burning group", "burning" ) );
+
+
+ // load search path
+ w->m_editSearchPath->clear();
+ w->m_editSearchPath->insertStringList( d->externalBinManager->searchPath() );
+
+ updateViews();
+}
+
+
+void K3bSetup2::defaults()
+{
+ w->m_checkUseBurningGroup->setChecked(false);
+ w->m_editBurningGroup->setText( "burning" );
+
+ //
+ // This is a hack to work around a kcm bug which makes the faulty assumption that
+ // every module defaults to a state where nothing is to be applied
+ //
+ QTimer::singleShot( 0, this, SLOT(updateViews()) );
+}
+
+
+void K3bSetup2::save()
+{
+ d->config->setGroup( "General Settings" );
+ d->config->writeEntry( "use burning group", w->m_checkUseBurningGroup->isChecked() );
+ d->config->writeEntry( "burning group", burningGroup() );
+ d->config->setGroup( "External Programs");
+ d->externalBinManager->saveConfig( d->config );
+ d->config->setGroup( "Devices");
+ d->deviceManager->saveConfig( d->config );
+
+
+ bool success = true;
+
+ struct group* g = 0;
+ if( w->m_checkUseBurningGroup->isChecked() ) {
+ // TODO: create the group if it's not there
+ g = getgrnam( burningGroup().local8Bit() );
+ if( !g ) {
+ KMessageBox::error( this, i18n("There is no group %1.").arg(burningGroup()) );
+ return;
+ }
+ }
+
+
+ // save the device permissions
+ QListViewItemIterator listIt( w->m_viewDevices );
+ for( ; listIt.current(); ++listIt ) {
+
+ QCheckListItem* checkItem = (QCheckListItem*)listIt.current();
+
+ if( checkItem->isOn() ) {
+ QString dev = d->listDeviceMap[checkItem];
+
+ if( w->m_checkUseBurningGroup->isChecked() ) {
+ if( ::chmod( QFile::encodeName(dev), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP ) )
+ success = false;
+
+ if( ::chown( QFile::encodeName(dev), (gid_t)-1, g->gr_gid ) )
+ success = false;
+ }
+ else {
+ if( ::chmod( QFile::encodeName(dev), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH ) )
+ success = false;
+ }
+ }
+ }
+
+
+ // save the program permissions
+ listIt = QListViewItemIterator( w->m_viewPrograms );
+ for( ; listIt.current(); ++listIt ) {
+
+ QCheckListItem* checkItem = (QCheckListItem*)listIt.current();
+
+ if( checkItem->isOn() ) {
+
+ K3bExternalBin* bin = d->listBinMap[checkItem];
+
+ if( w->m_checkUseBurningGroup->isChecked() ) {
+ if( ::chown( QFile::encodeName(bin->path), (gid_t)0, g->gr_gid ) )
+ success = false;
+
+ int perm = 0;
+ if( shouldRunSuidRoot( bin ) )
+ perm = S_ISUID|S_IRWXU|S_IXGRP;
+ else
+ perm = S_IRWXU|S_IXGRP|S_IRGRP;
+
+ if( ::chmod( QFile::encodeName(bin->path), perm ) )
+ success = false;
+ }
+ else {
+ if( ::chown( QFile::encodeName(bin->path), 0, 0 ) )
+ success = false;
+
+ int perm = 0;
+ if( shouldRunSuidRoot( bin ) )
+ perm = S_ISUID|S_IRWXU|S_IXGRP|S_IXOTH;
+ else
+ perm = S_IRWXU|S_IXGRP|S_IRGRP|S_IXOTH|S_IROTH;
+
+ if( ::chmod( QFile::encodeName(bin->path), perm ) )
+ success = false;
+ }
+ }
+ }
+
+
+ if( success )
+ KMessageBox::information( this, i18n("Successfully updated all permissions.") );
+ else {
+ if( getuid() )
+ KMessageBox::error( this, i18n("Could not update all permissions. You should run K3bSetup 2 as root.") );
+ else
+ KMessageBox::error( this, i18n("Could not update all permissions.") );
+ }
+
+ // WE MAY USE "newgrp -" to reinitialize the environment if we add users to a group
+
+ updateViews();
+}
+
+
+QString K3bSetup2::quickHelp() const
+{
+ return i18n("<h2>K3bSetup 2</h2>"
+ "<p>This simple setup assistant is able to set the permissions needed by K3b in order to "
+ "burn CDs and DVDs."
+ "<p>It does not take into account devfs or resmgr, or similar. In most cases this is not a "
+ "problem, but on some systems the permissions may be altered the next time you login or restart "
+ "your computer. In these cases it is best to consult the distribution's documentation."
+ "<p>The important task that K3bSetup 2 performs is grant write access to the CD and DVD devices."
+ "<p><b>Caution:</b> Although K3bSetup 2 should not be able "
+ "to damage your system, no guarantee can be given.");
+}
+
+
+QString K3bSetup2::burningGroup() const
+{
+ QString g = w->m_editBurningGroup->text();
+ return g.isEmpty() ? QString("burning") : g;
+}
+
+
+void K3bSetup2::slotSearchPrograms()
+{
+ d->externalBinManager->setSearchPath( w->m_editSearchPath->items() );
+ d->externalBinManager->search();
+ updatePrograms();
+
+ emit changed( d->changesNeeded );
+}
+
+
+void K3bSetup2::slotAddDevice()
+{
+ bool ok;
+ QString newDevicename = KInputDialog::getText( i18n("Location of New Drive"),
+ i18n("Please enter the device name where K3b should search\n"
+ "for a new drive (example: /dev/mebecdrom):"),
+ "/dev/", &ok, this );
+
+ if( ok ) {
+ if( d->deviceManager->addDevice( newDevicename ) ) {
+ updateDevices();
+
+ emit changed( d->changesNeeded );
+ }
+ else
+ KMessageBox::error( this, i18n("Could not find an additional device at\n%1").arg(newDevicename),
+ i18n("Error"), false );
+ }
+}
+
+void K3bSetup2::makeReadOnly()
+{
+ w->m_checkUseBurningGroup->setEnabled( false );
+ w->m_editBurningGroup->setEnabled( false );
+ w->m_editUsers->setEnabled( false );
+ w->m_viewDevices->setEnabled( false );
+ w->m_buttonAddDevice->setEnabled( false );
+ w->m_viewPrograms->setEnabled( false );
+ w->m_editSearchPath->setEnabled( false );
+}
+
+
+typedef KGenericFactory<K3bSetup2, QWidget> K3bSetup2Factory;
+K_EXPORT_COMPONENT_FACTORY( kcm_k3bsetup2, K3bSetup2Factory("k3bsetup") )
+
+
+#include "k3bsetup2.moc"
diff --git a/k3bsetup/k3bsetup2.desktop b/k3bsetup/k3bsetup2.desktop
new file mode 100644
index 0000000..5f73b03
--- /dev/null
+++ b/k3bsetup/k3bsetup2.desktop
@@ -0,0 +1,148 @@
+[Desktop Entry]
+Encoding=UTF-8
+Comment=K3bSetup 2 - modify permission for CD/DVD burning with K3b
+Comment[af]=K3bSetup 2 - verander regte vir CD/DVD skryf met K3b
+Comment[ar]= اعداد K3B 2 - غيًر الصلاحيات (الاذون ) كي تستطيع كتابة الاقراص المدمجة (CD) او الاقراص المرئية الرقمية (DVD) بواسطة K3B
+Comment[bg]=Настройване на K3b (2) - промяна на правата за запис на CD/DVD с K3b
+Comment[bn]=কে-থ্রি-বি ব্যবস্থাপনা ২ - কে-থ্রি-বি দিয়ে সিডি/ডিভিডি লিখনের জন্য অনুমতি পরিবর্তন করে
+Comment[bs]=K3bSetup 2 - promijenite privilegije za CD/DVD prženje sa K3b-om
+Comment[ca]=K3bSetup 2 - modifica els permisos per a cremar CD i DVD amb K3b
+Comment[cs]=K3bSetup 2 - změna oprávnění pro vypalování CD/DVD s K3b
+Comment[da]=K3bSetup 2 - ændring af tilladelser for cd/dvd-brænding med K3b
+Comment[de]=K3b Einrichtungsassistent - Zugriffsrechte zum Brennen mit K3b anpassen
+Comment[el]=Ρύθμιση K3b 2 - τροποποίηση δικαιωμάτων για εγγραφή CD/DVD με το K3b
+Comment[eo]=K3bAgordo 2 - ŝanĝu rajtojn por KD/DVD enskribo per K3b
+Comment[es]=K3bSetup 2 - modifica los permisos para la grabación de CD o DVD con K3b
+Comment[et]=K3b seadistamine - võimalus muuta õigusi CD/DVD kirjutamiseks K3b-ga
+Comment[fa]=K3bSetup 2 - تغییر مجوز برای سوزاندن دیسک فشرده/دی وی دی با K3b
+Comment[fi]=K3bSetup 2 - aseta K3b:n poltto-oikeudet
+Comment[fr]=K3bSetup 2 - Modification des permissions pour la gravure de CD / DVD avec K3b
+Comment[gl]=K3bSetup 2 - modifica os permisos para gravar CDs/DVDs con K3b
+Comment[he]=K3bSetup 2 - שינוי הרשאות עבור צריבת תקליטורי CD/DVD עם K3b
+Comment[hi]=के3बी-सेटअप 2 - के3बी के साथ सीडी/डीवीडी बर्निंग हेतु आज्ञाएँ परिवर्धित करें
+Comment[hu]=K3bSetup 2 - jogosultságbeállítás CD/DVD-íráshoz a K3b-ben
+Comment[is]=K3b uppsetning 2 - breyta aðgangsheimildum á CD/DVD skrifun með K3b
+Comment[it]=Impostazioni di K3b 2 - modifica i permessi per CD/DVD per scrivere con K3b
+Comment[ja]=K3bSetup 2 - K3b で CD/DVD に書き込むための権限を設定
+Comment[ka]=K3bSetup 2 - K3b-ით CD/DVD-ის ჩაწერის უფლების შეცვლა
+Comment[km]=K3bSetup 2 - កែប្រែ​សិទ្ធិ​ដើម្បី​ដុត​ស៊ីឌី ឬ ឌីវីឌី​​ដោយ​ប្រើ K3b
+Comment[lt]=K3bSetup 2 – pakeiskite leidimus CD/DVD kūrimui su K3b
+Comment[mk]=K3bSetup 2 - менување на дозволите за снимање на CD/DVD со K3b
+Comment[ms]=K3bSetup2 - mengubahsuai kebenaran untuk membakar CD/DVD dengan K3b
+Comment[nb]=K3bSetup 2 – endre tillatelser for CD-/DVD-brenning med K3b
+Comment[nds]=K3b-Inrichthölper - Verlöven för't Brennen vun CD/DVD mit K3b ännern
+Comment[ne]=K3bSetup 2 - ले K3b सँग सीडी/डीभीडी बर्निङका लागि अनुमति परिमार्जन गर्दछ
+Comment[nl]=K3bSetup 2 - stelt de toegangsrechten in voor cd/dvd-branden met K3b
+Comment[nn]=K3b-oppsett 2 – endra løyve for CD- og DVD-brenning med K3b
+Comment[pa]=K3bSetup 2 - K3b ਨਾਲ CD/DVD ਲਿਖਣ ਲਈ ਅਧਿਕਾਰ ਸੋਧ
+Comment[pl]=K3bSetup 2 - modyfikacja uprawnień do nagrywania płyt CD/DVD za pomocą K3b
+Comment[pt]=K3bSetup 2 - modificar as permissões para a gravação de CDs/DVDs com o K3b
+Comment[pt_BR]=Configurações Avançadas do K3b - modificar as permissões para a queima de CD/DVD com o K3b
+Comment[ru]=K3bSetup 2 - настроить права для записи при помощи K3b
+Comment[sk]=K3bSetup 2 - zmena práv pre napaľovanie CD/DVD s K3b
+Comment[sl]=K3bSetup - spremeni dovoljenja za pisanje CD/DVD-jev s K3b
+Comment[sr]=K3bSetup 2 — мења дозволе за резање CD/DVD-а помоћу K3b-а
+Comment[sr@Latn]=K3bSetup 2 — menja dozvole za rezanje CD/DVD-a pomoću K3b-a
+Comment[sv]=Ställ in K3b 2: ändra rättigheter för att bränna cd/dvd med K3b
+Comment[ta]= K3bஅமைவு2 - K3b ஐ CD/DVD களோடு எழுதுவதற்காக அனுமதி மாற்றுவதற்காக
+Comment[tg]=K3bSetup 2 - танзим кардани иҷозат барои сабт бо ёрии K3b
+Comment[tr]=K3bSetup 2 - K3b ile CD/DVD kaydetme izinlerini ayarlama
+Comment[uk]=K3bSetup 2 - зміна прав доступу для запису КД/DVD за допомогою K3b
+Comment[uz]=K3bSetup 2 - K3b yordamida CD/DVD'ga yozish huquqini moslash
+Comment[uz@cyrillic]=K3bSetup 2 - K3b ёрдамида CD/DVD'га ёзиш ҳуқуқини мослаш
+Comment[zh_CN]=K3b 设置 2 - 修改使用 K3b 烧录 CD/DVD 的权限
+Comment[zh_TW]=K3bSetup 2 - 為 K3b 燒錄 CD/DVD 修改權限
+Exec=k3bsetup
+Keywords=K3bSetup2,k3bsetup2
+Keywords[ar]=اعداد K3b , K3b2
+Keywords[bg]=K3bSetup2,k3bsetup2,Настройване на K3b (2)
+Keywords[de]=K3b, Einrichtungsassistent, Rechte
+Keywords[el]=Ρύθμιση K3b 2,k3bsetup2
+Keywords[eo]=K3bAgordo2,k3bagordo2
+Keywords[et]=K3bSetup2,k3bsetup2,k3b seadistamine
+Keywords[hi]=के3बी-सेटअप 2,के3बी-सेटअप2
+Keywords[nds]=K3bSetup2,k3bsetup2,K3b-Inrichthölper
+Keywords[nl]=K3bSetup2,k3bsetup2,branden,cd branden,dvd,dvd branden
+Keywords[nn]=K3b-oppsett 2,k3b-oppsett 2
+Keywords[pl]=K3bSetup2,k3bsetup2,k3b,ustawienia,uprawnienia
+Keywords[pt_BR]=Configurações Avançadas do K3b,configurações avançadas do K3b
+Keywords[sv]=Ställ in K3b 2,k3bsetup2
+Keywords[ta]=K3bஅமைவு2,K3bஅமைவு2
+Keywords[tg]=ТанзимиK3b2,танзимиk3b2
+Keywords[uz]=K3bSetup2,k3bsetup2,CD,kompakt-disk
+Keywords[uz@cyrillic]=K3bSetup2,k3bsetup2,CD,компакт-диск
+Name=K3bSetup
+Name[ar]= اعداد K3b
+Name[bg]=Настройване на K3b
+Name[bn]=কে-থ্রি-বি ব্যবস্থাপনা
+Name[de]=K3b Einrichtungsassistent
+Name[eo]=K3bAgordo
+Name[et]=K3b seadistamine
+Name[hi]=के3बी-सेटअप
+Name[is]=K3b uppsetning
+Name[it]=Impostazioni di K3b
+Name[nds]=K3b-Inrichthölper
+Name[nn]=K3b-oppsett
+Name[pa]=K3b-ਸੈੱਟਅੱਪ
+Name[pt_BR]=Configurar K3b
+Name[sv]=Ställ in K3b
+Name[ta]=K3b அமைவு
+Name[tg]=ТанзимиK3b
+Name[zh_TW]=K3b 設定
+Terminal=false
+Type=Application
+Icon=k3b
+X-KDE-FactoryName=k3bsetup2
+X-KDE-Library=k3bsetup2
+X-KDE-ModuleType=Library
+X-KDE-RootOnly=true
+Categories=Application;System;X-KDE-System;
+GenericName=CD & DVD Burning Setup
+GenericName[af]=CD & DVD Skryf Opstelling
+GenericName[ar]=العام اعداد كتابة القرص المدمج (CD) و القرص المرئي الرقمي (DVD)
+GenericName[bg]=Настройване записа на CD и DVD
+GenericName[bn]=সিডি এবং ডিভিডি লিখন ব্যবস্থাপনা
+GenericName[ca]=Programa per gravar CDs i DVDs
+GenericName[cs]=Nastavení vypalování CD a DVD
+GenericName[da]=Cd & dvd opsætning til brænding
+GenericName[de]=CD & DVD-Brennen einrichten
+GenericName[el]=Ρύθμιση εγγραφής CD & DVD
+GenericName[eo]=KD & DVD Enskriba agordo
+GenericName[es]=Configurar grabación de CD y DVD
+GenericName[et]=CD ja DVD kirjutamise seadistamine
+GenericName[fa]=برپایی سوزاندن دیسک فشرده و دی وی دی
+GenericName[fi]=K3b-poltto-ohjelman asetusten määritys
+GenericName[fr]=Configuration de la gravure de CD et de DVD
+GenericName[gl]=Configurazón da Grabazón de CDs e DVDs
+GenericName[hu]=CD- és DVD-írási beállítások
+GenericName[is]=Uppsetning á CD og DVD brennslu
+GenericName[it]=Impostazioni di masterizzazione CD e DVD
+GenericName[ja]=CD / DVD 作成の設定
+GenericName[ka]=CD-ის და DVD-ის ჩაწერის გამართვა
+GenericName[km]=រៀបចំ​ការ​ដុត​ស៊ីឌី & ឌីវីឌី
+GenericName[lt]=CD & DVD kūrimo parinktys
+GenericName[mk]=Поставувања за снимање на CD и DVD
+GenericName[ms]=Tetapan Membakar CD & DVD
+GenericName[nb]=Oppsett av CD- og DVD-brenning
+GenericName[nds]=Brennen vun CD & DVD instellen
+GenericName[ne]=सीडी र डीभीडी बर्निङ सेटअप
+GenericName[nl]=CD- en dvd-branden instellen
+GenericName[nn]=Oppsett av CD- og DVD-brenning
+GenericName[pa]=CD & DVD ਲਿਖਣ ਸੈਟਅੱਪ
+GenericName[pl]=Konfiguracja nagrywania płyt CD i DVD
+GenericName[pt]=Configuração da Gravação de CDs e DVDs
+GenericName[pt_BR]=Configuração da Queima de CD & DVD
+GenericName[ru]=Настройка записи CD и DVD
+GenericName[sk]=Nastavenie CD & DVD napaľovania
+GenericName[sl]=Nastavitve za pisanje CD-jev in DVD-jev
+GenericName[sr]=Подешавање резања CD-а и DVD-а
+GenericName[sr@Latn]=Podešavanje rezanja CD-a i DVD-a
+GenericName[sv]=Cd och dvd-bränninställning
+GenericName[ta]=சிடி & DVD நகல் எடுக்கும் அமைப்பு
+GenericName[tg]=Танзимоти сабткунии CD ва DVD
+GenericName[tr]=CD ve DVD Kaydetme Kurulumu
+GenericName[uk]=Налажтування запису КД та DVD
+GenericName[uz]=CD va DVD diskka yozishni moslash
+GenericName[uz@cyrillic]=CD ва DVD дискка ёзишни мослаш
+GenericName[zh_CN]=CD & DVD 刻录程序设置
+GenericName[zh_TW]=CD & DVD 燒錄設定
diff --git a/k3bsetup/k3bsetup2.h b/k3bsetup/k3bsetup2.h
new file mode 100644
index 0000000..ea86664
--- /dev/null
+++ b/k3bsetup/k3bsetup2.h
@@ -0,0 +1,65 @@
+/*
+ *
+ * $Id: k3bsetup2.h 619556 2007-01-03 17:38:12Z trueg $
+ * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+
+#ifndef _K3BSETUP2_H_
+#define _K3BSETUP2_H_
+
+#include <kcmodule.h>
+#include <kaboutdata.h>
+
+
+class base_K3bSetup2;
+class QCheckListItem;
+
+
+class K3bSetup2: public KCModule
+{
+ Q_OBJECT
+
+ public:
+ K3bSetup2( QWidget* parent = 0, const char* name = 0, const QStringList& args = QStringList() );
+ ~K3bSetup2();
+
+ QString quickHelp() const;
+ const KAboutData* aboutData() { return m_aboutData; };
+
+ void load();
+ void save();
+ void defaults();
+
+ public slots:
+ void updateViews();
+
+ private slots:
+ void slotSearchPrograms();
+ void slotAddDevice();
+
+ private:
+ void updatePrograms();
+ void updateDevices();
+ QString burningGroup() const;
+ void makeReadOnly();
+ QCheckListItem* createDeviceItem( const QString& deviceNode );
+
+ class Private;
+ Private* d;
+
+ base_K3bSetup2* w;
+
+ KAboutData* m_aboutData;
+};
+
+#endif