summaryrefslogtreecommitdiffstats
path: root/secpolicy
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit37333bf25ad9a4c538250f5af2f9f1d666362883 (patch)
treec45e8df5b9efbffe07eb3d9340df7811c7e16943 /secpolicy
downloadtdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.tar.gz
tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'secpolicy')
-rw-r--r--secpolicy/Makefile.am14
-rw-r--r--secpolicy/main.cpp50
-rw-r--r--secpolicy/pamview.cpp113
-rw-r--r--secpolicy/pamview.h49
-rw-r--r--secpolicy/ppitem.cpp44
-rw-r--r--secpolicy/ppitem.h40
-rw-r--r--secpolicy/secpolicywin.cpp64
-rw-r--r--secpolicy/secpolicywin.h45
8 files changed, 419 insertions, 0 deletions
diff --git a/secpolicy/Makefile.am b/secpolicy/Makefile.am
new file mode 100644
index 0000000..0d221bc
--- /dev/null
+++ b/secpolicy/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES= $(all_includes)
+METASOURCES = AUTO
+
+bin_PROGRAMS = secpolicy
+secpolicy_SOURCES = main.cpp secpolicywin.cpp pamview.cpp ppitem.cpp
+secpolicy_LDADD = $(LIB_KIO)
+secpolicy_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+noinst_HEADERS = secpolicywin.h pamview.h ppitem.h
+
+EXTRA_DIST =
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/secpolicy.pot
diff --git a/secpolicy/main.cpp b/secpolicy/main.cpp
new file mode 100644
index 0000000..6060405
--- /dev/null
+++ b/secpolicy/main.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 1999 by Preston Brown <pbrown@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <kuniqueapplication.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <stdlib.h>
+
+#include "secpolicywin.h"
+
+static const char description[] =
+ I18N_NOOP("Display PAM security policies");
+
+static const char version[] = "v0.0.1";
+
+
+int main(int argc, char **argv)
+{
+ KCmdLineArgs::init(argc, argv, "secpolicy", description, version);
+
+ if (!KUniqueApplication::start())
+ exit(0);
+
+ KUniqueApplication app;
+ SecPolicyWin *spWin = new SecPolicyWin();
+
+ app.setMainWidget(spWin);
+ return app.exec();
+}
diff --git a/secpolicy/pamview.cpp b/secpolicy/pamview.cpp
new file mode 100644
index 0000000..f16ac4d
--- /dev/null
+++ b/secpolicy/pamview.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 1999 by Preston Brown <pbrown@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <qlayout.h>
+#include <qlistbox.h>
+#include <qlistview.h>
+#include <qlabel.h>
+#include <qdir.h>
+#include <qtextstream.h>
+#include <qfile.h>
+#include <qregexp.h>
+
+#include <kmessagebox.h>
+#include <kglobal.h>
+#include <klocale.h>
+
+#include "ppitem.h"
+#include "pamview.h"
+
+#include <stdlib.h>
+
+PamView::PamView(QWidget *parent, const char *name)
+ : QWidget(parent, name)
+{
+ QHBoxLayout *topl = new QHBoxLayout(this);
+
+ QVBoxLayout *leftl = new QVBoxLayout;
+ topl->addLayout(leftl);
+
+ QLabel *label = new QLabel(i18n("Available services:"), this);
+ leftl->addWidget(label);
+
+ servicesLB = new QListBox(this);
+ leftl->addWidget(servicesLB);
+
+ propertiesLV = new QListView(this);
+ propertiesLV->addColumn(i18n("Category"));
+ propertiesLV->addColumn(i18n("Level"));
+ propertiesLV->addColumn(i18n("Module"));
+ topl->addWidget(propertiesLV);
+
+ init();
+}
+
+PamView::~PamView()
+{
+}
+
+void PamView::init()
+{
+ initServices();
+}
+
+void PamView::initServices()
+{
+
+ QDir d("/etc/pam.d");
+ d.setFilter(QDir::Files|QDir::Readable);
+
+ if (!d.exists()) {
+ KMessageBox::error(this, i18n("/etc/pam.d folder does not exist.\n"
+ "Either your system does not have PAM support "
+ "or there is some other configuration problem."));
+ exit(1);
+ }
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it(*list);
+ QFileInfo *fi;
+ while ((fi = it.current()) != 0) {
+ servicesLB->insertItem(fi->fileName());
+ QFile f(fi->filePath());
+ if (f.open(IO_ReadOnly)) {
+ QTextStream t(&f);
+ QString s;
+ while (!t.eof()) {
+ s = t.readLine().stripWhiteSpace();
+ if (s.isEmpty() || (s[0] == '#'))
+ continue;
+
+ PamPropertiesItem *item = new PamPropertiesItem(fi->filePath(),
+ QStringList::split(QRegExp("\\s"), s),
+ propertiesLV);
+ propertiesLV->insertItem(item);
+ }
+ f.close();
+ }
+ ++it;
+ }
+}
+
+#include "pamview.moc"
diff --git a/secpolicy/pamview.h b/secpolicy/pamview.h
new file mode 100644
index 0000000..ea41634
--- /dev/null
+++ b/secpolicy/pamview.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1999 by Preston Brown <pbrown@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _PAMVIEW_H
+#define _PAMVIEW_H
+
+#include <qwidget.h>
+
+class QListBox;
+class QListView;
+
+class PamView : public QWidget
+{
+ Q_OBJECT
+public:
+ PamView(QWidget *parent = 0, const char *name = 0);
+ virtual ~PamView();
+
+protected:
+ void init();
+ void initServices();
+
+private:
+ QListBox *servicesLB;
+ QListView *propertiesLV;
+};
+
+#endif
diff --git a/secpolicy/ppitem.cpp b/secpolicy/ppitem.cpp
new file mode 100644
index 0000000..05fb358
--- /dev/null
+++ b/secpolicy/ppitem.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1999 by Preston Brown <pbrown@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <qstringlist.h>
+#include "ppitem.h"
+
+PamPropertiesItem::PamPropertiesItem(QString fileName,
+ QStringList properties,
+ QListView *parent)
+ : QListViewItem(parent)
+{
+ int i = properties.count();
+ if (i > 0)
+ category = properties[0];
+ if (i > 1)
+ level = properties[1];
+ if (i > 2)
+ lib = properties[2];
+
+ setText(0, category);
+ setText(1, level);
+ setText(2, lib);
+}
diff --git a/secpolicy/ppitem.h b/secpolicy/ppitem.h
new file mode 100644
index 0000000..591d729
--- /dev/null
+++ b/secpolicy/ppitem.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 1999 by Preston Brown <pbrown@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _PPITEM_H
+#define _PPITEM_H
+
+#include <qlistview.h>
+
+class PamPropertiesItem : public QListViewItem
+{
+ public:
+ PamPropertiesItem(QString fileName, QStringList properties,
+ QListView *parent);
+
+ private:
+ QString category, level, lib;
+};
+
+#endif
diff --git a/secpolicy/secpolicywin.cpp b/secpolicy/secpolicywin.cpp
new file mode 100644
index 0000000..64a454d
--- /dev/null
+++ b/secpolicy/secpolicywin.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1999 by Preston Brown <pbrown@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <kglobal.h>
+#include <klocale.h>
+#include <kapplication.h>
+#include <kmenubar.h>
+#include <kdialog.h>
+#include <dcopclient.h>
+#include <qpopupmenu.h>
+#include <kstdaccel.h>
+
+#include "pamview.h"
+#include "secpolicywin.h"
+
+SecPolicyWin::SecPolicyWin(const char *name)
+ : KMainWindow(0,name)
+{
+ view = new PamView(this);
+ setCentralWidget(view);
+
+ KMenuBar *mBar = menuBar();
+ QPopupMenu *fileMenu = new QPopupMenu(this);
+ fileMenu->insertItem(i18n("&Quit"), kapp, SLOT(closeAllWindows()), KStdAccel::shortcut(KStdAccel::Quit));
+ mBar->insertItem(i18n("&File"), fileMenu);
+
+ connect(kapp, SIGNAL(lastWindowClosed()), kapp, SLOT(quit()));
+
+ adjustSize();
+ // work around KTMainWindow sizing bug.
+ resize(sizeHint().width(), sizeHint().height() + mBar->height() +
+ KDialog::marginHint());
+ show();
+}
+
+SecPolicyWin::~SecPolicyWin()
+{
+}
+
+void SecPolicyWin::closeEvent(QCloseEvent *e)
+{
+ e->accept();
+}
diff --git a/secpolicy/secpolicywin.h b/secpolicy/secpolicywin.h
new file mode 100644
index 0000000..a58b8a6
--- /dev/null
+++ b/secpolicy/secpolicywin.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1999 by Preston Brown <pbrown@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _SECPOLICYWIN_H
+#define _SECPOLICYWIN_H
+
+#include <kmainwindow.h>
+
+class PamView;
+
+class SecPolicyWin : public KMainWindow
+{
+public:
+ SecPolicyWin(const char *name = 0);
+ ~SecPolicyWin();
+
+protected:
+ virtual void closeEvent(QCloseEvent *);
+
+private:
+ PamView *view;
+};
+
+#endif