umask(0);
/* Open any logs here */
-
- /* Create a new SID for the child process */
- sid = setsid();
- if (sid < 0) {
- /* Log the failure */
- exit(EXIT_FAILURE);
- }
std::string name, dirname;
name = getenv("USER");
dirname = "/home/" + name + "/.mnenc/";
exit(EXIT_FAILURE);
}
}
-
+ /*This is log stuff */
+ std::string logname = "/home/" + name + "/.mnenc/log";
+ std::ofstream log; //Log stream
+ log.open(logname.c_str(), ios::app); // open log
+ time_t rawtime; //Time stuff here
+ struct tm * timeinfo;
+ time ( &rawtime );
+ timeinfo = localtime ( &rawtime );
+ std::string current_time = asctime (timeinfo); //Holds current time
+
+ /* Create a new SID for the child process */
+ sid = setsid();
+ if (sid < 0) {
+ log << current_time << ": Unable to create a new SID for the child process\n";
+ exit(EXIT_FAILURE);
+ }
+
/* Change the current working directory */
if ((chdir("/tmp/")) < 0) {
- /* Log the failure */
+ log << current_time << ": Could not change to /tmp\n";
exit(EXIT_FAILURE);
}
close(STDERR_FILENO);
/* Daemon-specific initialization goes here */
-
- mkfifo("./mnencdfifo", 0777);
+ mkfifo("./mnencdfifo", 0777); //This is the fifo for communications
signal(SIGTERM, term); // register a SIGTERM handler
- //raise(SIGTERM); // will cause term() to run
+ log.close(); //Closing log
/* The Big Loop */
while (1) {
--- /dev/null
+#############################################################################
+# Makefile for building: unlock
+# Generated by qmake (2.01a) (Qt 4.6.0) on: sön jan 10 19:41:04 2010
+# Project: unlock.pro
+# Template: app
+# Command: /usr/bin/qmake -unix -o Makefile unlock.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+INCPATH = -I/usr/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -I.
+LINK = g++
+LFLAGS = -Wl,-O1 -Wl,-rpath,/usr/lib
+LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread
+AR = ar cqs
+RANLIB =
+QMAKE = /usr/bin/qmake
+TAR = tar -cf
+COMPRESS = gzip -9f
+COPY = cp -f
+SED = sed
+COPY_FILE = $(COPY)
+COPY_DIR = $(COPY) -r
+STRIP = strip
+INSTALL_FILE = install -m 644 -p
+INSTALL_DIR = $(COPY_DIR)
+INSTALL_PROGRAM = install -m 755 -p
+DEL_FILE = rm -f
+SYMLINK = ln -sf
+DEL_DIR = rmdir
+MOVE = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR = ./
+
+####### Files
+
+SOURCES = main.cpp \
+ unlock.cpp moc_unlock.cpp
+OBJECTS = main.o \
+ unlock.o \
+ moc_unlock.o
+DIST = /usr/mkspecs/common/g++.conf \
+ /usr/mkspecs/common/unix.conf \
+ /usr/mkspecs/common/linux.conf \
+ /usr/mkspecs/qconfig.pri \
+ /usr/mkspecs/features/qt_functions.prf \
+ /usr/mkspecs/features/qt_config.prf \
+ /usr/mkspecs/features/exclusive_builds.prf \
+ /usr/mkspecs/features/default_pre.prf \
+ /usr/mkspecs/features/release.prf \
+ /usr/mkspecs/features/default_post.prf \
+ /usr/mkspecs/features/warn_on.prf \
+ /usr/mkspecs/features/qt.prf \
+ /usr/mkspecs/features/unix/thread.prf \
+ /usr/mkspecs/features/moc.prf \
+ /usr/mkspecs/features/resources.prf \
+ /usr/mkspecs/features/uic.prf \
+ /usr/mkspecs/features/yacc.prf \
+ /usr/mkspecs/features/lex.prf \
+ /usr/mkspecs/features/include_source_dir.prf \
+ unlock.pro
+QMAKE_TARGET = unlock
+DESTDIR =
+TARGET = unlock
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .o .c .cpp .cc .cxx .C
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
+
+####### Build rules
+
+all: Makefile $(TARGET)
+
+$(TARGET): ui_unlock.h $(OBJECTS)
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
+
+Makefile: unlock.pro /usr/mkspecs/linux-g++/qmake.conf /usr/mkspecs/common/g++.conf \
+ /usr/mkspecs/common/unix.conf \
+ /usr/mkspecs/common/linux.conf \
+ /usr/mkspecs/qconfig.pri \
+ /usr/mkspecs/features/qt_functions.prf \
+ /usr/mkspecs/features/qt_config.prf \
+ /usr/mkspecs/features/exclusive_builds.prf \
+ /usr/mkspecs/features/default_pre.prf \
+ /usr/mkspecs/features/release.prf \
+ /usr/mkspecs/features/default_post.prf \
+ /usr/mkspecs/features/warn_on.prf \
+ /usr/mkspecs/features/qt.prf \
+ /usr/mkspecs/features/unix/thread.prf \
+ /usr/mkspecs/features/moc.prf \
+ /usr/mkspecs/features/resources.prf \
+ /usr/mkspecs/features/uic.prf \
+ /usr/mkspecs/features/yacc.prf \
+ /usr/mkspecs/features/lex.prf \
+ /usr/mkspecs/features/include_source_dir.prf \
+ /usr/lib/libQtGui.prl \
+ /usr/lib/libQtCore.prl
+ $(QMAKE) -unix -o Makefile unlock.pro
+/usr/mkspecs/common/g++.conf:
+/usr/mkspecs/common/unix.conf:
+/usr/mkspecs/common/linux.conf:
+/usr/mkspecs/qconfig.pri:
+/usr/mkspecs/features/qt_functions.prf:
+/usr/mkspecs/features/qt_config.prf:
+/usr/mkspecs/features/exclusive_builds.prf:
+/usr/mkspecs/features/default_pre.prf:
+/usr/mkspecs/features/release.prf:
+/usr/mkspecs/features/default_post.prf:
+/usr/mkspecs/features/warn_on.prf:
+/usr/mkspecs/features/qt.prf:
+/usr/mkspecs/features/unix/thread.prf:
+/usr/mkspecs/features/moc.prf:
+/usr/mkspecs/features/resources.prf:
+/usr/mkspecs/features/uic.prf:
+/usr/mkspecs/features/yacc.prf:
+/usr/mkspecs/features/lex.prf:
+/usr/mkspecs/features/include_source_dir.prf:
+/usr/lib/libQtGui.prl:
+/usr/lib/libQtCore.prl:
+qmake: FORCE
+ @$(QMAKE) -unix -o Makefile unlock.pro
+
+dist:
+ @$(CHK_DIR_EXISTS) .tmp/unlock1.0.0 || $(MKDIR) .tmp/unlock1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/unlock1.0.0/ && $(COPY_FILE) --parents unlock.hpp .tmp/unlock1.0.0/ && $(COPY_FILE) --parents main.cpp unlock.cpp .tmp/unlock1.0.0/ && $(COPY_FILE) --parents unlock.ui .tmp/unlock1.0.0/ && (cd `dirname .tmp/unlock1.0.0` && $(TAR) unlock1.0.0.tar unlock1.0.0 && $(COMPRESS) unlock1.0.0.tar) && $(MOVE) `dirname .tmp/unlock1.0.0`/unlock1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/unlock1.0.0
+
+
+clean:compiler_clean
+ -$(DEL_FILE) $(OBJECTS)
+ -$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+ -$(DEL_FILE) $(TARGET)
+ -$(DEL_FILE) Makefile
+
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: moc_unlock.cpp
+compiler_moc_header_clean:
+ -$(DEL_FILE) moc_unlock.cpp
+moc_unlock.cpp: ui_unlock.h \
+ unlock.hpp
+ /usr/bin/moc $(DEFINES) $(INCPATH) unlock.hpp -o moc_unlock.cpp
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+ -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all: ui_unlock.h
+compiler_uic_clean:
+ -$(DEL_FILE) ui_unlock.h
+ui_unlock.h: unlock.ui
+ /usr/bin/uic unlock.ui -o ui_unlock.h
+
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean compiler_uic_clean
+
+####### Compile
+
+main.o: main.cpp unlock.hpp \
+ ui_unlock.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
+
+unlock.o: unlock.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o unlock.o unlock.cpp
+
+moc_unlock.o: moc_unlock.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_unlock.o moc_unlock.cpp
+
+####### Install
+
+install: FORCE
+
+uninstall: FORCE
+
+FORCE:
+
--- /dev/null
+// main.cpp
+//
+// Copyright 2010 Micke Nordin <micke@hal>
+//
+// 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.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+
+#include <QApplication>
+ #include "unlock.hpp"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Unlock *dialog = new Unlock;
+
+ dialog->show();
+ return app.exec();
+}
--- /dev/null
+/********************************************************************************
+** Form generated from reading UI file 'unlock.ui'
+**
+** Created: Sun Jan 10 19:35:33 2010
+** by: Qt User Interface Compiler version 4.6.0
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef UI_UNLOCK_H
+#define UI_UNLOCK_H
+
+#include <QtCore/QVariant>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QButtonGroup>
+#include <QtGui/QDialog>
+#include <QtGui/QDialogButtonBox>
+#include <QtGui/QHeaderView>
+#include <QtGui/QLabel>
+#include <QtGui/QLineEdit>
+
+QT_BEGIN_NAMESPACE
+
+class Ui_Dialog
+{
+public:
+ QDialogButtonBox *buttonBox;
+ QLineEdit *lineEdit;
+ QLabel *label;
+
+ void setupUi(QDialog *Dialog)
+ {
+ if (Dialog->objectName().isEmpty())
+ Dialog->setObjectName(QString::fromUtf8("Dialog"));
+ Dialog->resize(255, 77);
+ buttonBox = new QDialogButtonBox(Dialog);
+ buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
+ buttonBox->setGeometry(QRect(150, 10, 81, 301));
+ buttonBox->setOrientation(Qt::Vertical);
+ buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
+ lineEdit = new QLineEdit(Dialog);
+ lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
+ lineEdit->setGeometry(QRect(30, 40, 113, 26));
+ label = new QLabel(Dialog);
+ label->setObjectName(QString::fromUtf8("label"));
+ label->setGeometry(QRect(30, 10, 111, 20));
+
+ retranslateUi(Dialog);
+ QObject::connect(buttonBox, SIGNAL(rejected()), Dialog, SLOT(reject()));
+ QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept()));
+
+ QMetaObject::connectSlotsByName(Dialog);
+ } // setupUi
+
+ void retranslateUi(QDialog *Dialog)
+ {
+ Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8));
+#ifndef QT_NO_WHATSTHIS
+ lineEdit->setWhatsThis(QString());
+#endif // QT_NO_WHATSTHIS
+ label->setText(QApplication::translate("Dialog", "Enter password", 0, QApplication::UnicodeUTF8));
+ } // retranslateUi
+
+};
+
+namespace Ui {
+ class Dialog: public Ui_Dialog {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // UI_UNLOCK_H
--- /dev/null
+// unlock.cpp
+//
+// Copyright 2010 Micke Nordin <micke@hal>
+//
+// 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 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+
+#include <QtGui>
+#include "unlock.h"
+
+// if we include <QtGui> there is no need to include every class used: <QString>, <QFileDialog>,...
+
+Unlock::Unlock(QWidget *parent) {
+ setupUi(this); // this sets up GUI
+
+ // signals/slots mechanism in action
+ connect( pushButton_browse, SIGNAL( clicked() ), this, SLOT( accepted() ) );
+ connect( pushButton_do, SIGNAL( clicked() ), this, SLOT( rejected() ) );
+}
+
+
+void Unlock::accepted() {
+//
+}
+
+
+void Unlock::rejected() {
+ //
+}
--- /dev/null
+// unlock.hpp
+//
+// Copyright 2010 Micke Nordin <micke@hal>
+//
+// 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.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+
+#ifndef _unlock_h_included_
+#define _unlock_h_included_
+
+#include "ui_unlock.h"
+
+class Unlock : public QWidget, private Ui::QDialog {
+ Q_OBJECT
+
+public:
+ Unlock(QWidget *parent = 0);
+
+
+public slots:
+ void accepted();
+ void rejected();
+};
+
+
+#endif
--- /dev/null
+######################################################################
+# Automatically generated by qmake (2.01a) sön jan 10 19:35:11 2010
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += unlock.hpp
+FORMS += unlock.ui
+SOURCES += main.cpp unlock.cpp
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>255</width>
+ <height>77</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>10</y>
+ <width>81</width>
+ <height>301</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="lineEdit">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>40</y>
+ <width>113</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="whatsThis">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>10</y>
+ <width>111</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Enter password</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>Dialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>Dialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>