Skip to content

Commit

Permalink
firejail-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Dec 27, 2016
1 parent bd766d7 commit b071b28
Show file tree
Hide file tree
Showing 10 changed files with 684 additions and 10 deletions.
4 changes: 4 additions & 0 deletions RELNOTES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
firetools (0.9.45) baseline; urgency=low
* development version
-- netblue30 <[email protected]> Fri, 11 Nov 2016 08:00:00 -0500

firetools (0.9.44) baseline; urgency=low
* support for firejail --x11 detection
* bugfixes
Expand Down
19 changes: 10 additions & 9 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for firetools 0.9.44.
# Generated by GNU Autoconf 2.69 for firetools 0.9.45.
#
# Report bugs to <[email protected]>.
#
Expand Down Expand Up @@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='firetools'
PACKAGE_TARNAME='firetools'
PACKAGE_VERSION='0.9.44'
PACKAGE_STRING='firetools 0.9.44'
PACKAGE_VERSION='0.9.45'
PACKAGE_STRING='firetools 0.9.45'
PACKAGE_BUGREPORT='[email protected]'
PACKAGE_URL='http:https://firejail.wordpress.com'

Expand Down Expand Up @@ -1237,7 +1237,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures firetools 0.9.44 to adapt to many kinds of systems.
\`configure' configures firetools 0.9.45 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1298,7 +1298,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of firetools 0.9.44:";;
short | recursive ) echo "Configuration of firetools 0.9.45:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1386,7 +1386,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
firetools configure 0.9.44
firetools configure 0.9.45
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1726,7 +1726,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by firetools $as_me 0.9.44, which was
It was created by firetools $as_me 0.9.45, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
Expand Down Expand Up @@ -3835,6 +3835,7 @@ $QMAKE -v

cd src/firetools && $QMAKE && cd ../..
cd src/firemgr && $QMAKE && cd ../..
cd src/firejail-ui && $QMAKE && cd ../..

# build sanitizer.sh file
echo "#!/bin/bash" >sanitizer.sh
Expand Down Expand Up @@ -4389,7 +4390,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by firetools $as_me 0.9.44, which was
This file was extended by firetools $as_me 0.9.45, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -4443,7 +4444,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
firetools config.status 0.9.44
firetools config.status 0.9.45
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_PREREQ([2.68])
AC_INIT(firetools, 0.9.44, [email protected], , http:https://firejail.wordpress.com)
AC_INIT(firetools, 0.9.45, [email protected], , http:https://firejail.wordpress.com)
AC_CONFIG_SRCDIR([src/firetools/main.cpp])
#AC_CONFIG_HEADERS([config.h])

Expand Down Expand Up @@ -50,6 +50,7 @@ $QMAKE -v

cd src/firetools && $QMAKE && cd ../..
cd src/firemgr && $QMAKE && cd ../..
cd src/firejail-ui && $QMAKE && cd ../..

# build sanitizer.sh file
echo "#!/bin/bash" >sanitizer.sh
Expand Down
14 changes: 14 additions & 0 deletions src/firejail-ui/firejail-ui.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
QMAKE_CXXFLAGS += $$(CXXFLAGS) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security
QMAKE_CFLAGS += $$(CFLAGS) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security
QMAKE_LFLAGS += $$(LDFLAGS) -Wl,-z,relro -Wl,-z,now
QT += widgets
HEADERS = ../common/utils.h ../common/pid.h ../common/common.h \
firejail_ui.h wizard.h home_widget.h
SOURCES = main.cpp \
wizard.cpp \
home_widget.cpp \
../common/utils.cpp \
../common/pid.cpp
#RESOURCES = firejail-ui.qrc
#TARGET=../../build/firejail-ui
TARGET=firejail-ui
28 changes: 28 additions & 0 deletions src/firejail-ui/firejail_ui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2015-2016 Firetools Authors
*
* This file is part of firetools project
*
* 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 FIREJAIL_UI_H
#define FIREJAIL_UI_H
#include "../common/common.h"

extern int arg_debug;
extern int svg_not_found;
class QWizardPage;

#endif
77 changes: 77 additions & 0 deletions src/firejail-ui/home_widget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2015-2016 Firetools Authors
*
* This file is part of firetools project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public as published by
* the Free Software Foundation; either version 2 of the , 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 for more details.
*
* You should have received a copy of the GNU General Public along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif

#include <QCheckBox>
#include "firejail_ui.h"
#include "home_widget.h"
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>


HomeWidget::HomeWidget(QWidget * parent): QListWidget(parent) {
readFiles();
}

void HomeWidget::readFiles() {
DIR *dir = opendir("/home/netblue");
if (!dir)
// todo: error recovery
errExit("opendir");

struct dirent *entry;
while ((entry = readdir(dir))) {
// with a few exceptions, reject all dot files
bool accept = false;
if (strcmp(entry->d_name, ".config") == 0 ||
strcmp(entry->d_name, ".mozilla") == 0)
accept = true;
if (!accept && *entry->d_name == '.')
continue;

// allow only directorries
struct stat s;
char *name;
if (asprintf(&name, "/home/netblue/%s", entry->d_name) == -1)
errExit("asprintf");
if (stat(name, &s) == -1) {
free(name);
continue;
}
free(name);
if (!S_ISDIR(s.st_mode))
continue;

QCheckBox *box = new QCheckBox(entry->d_name);
QListWidgetItem *item = new QListWidgetItem();
addItem(item);
setItemWidget(item, box);
}

closedir(dir);

}
37 changes: 37 additions & 0 deletions src/firejail-ui/home_widget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2015-2016 Firetools Authors
*
* This file is part of firetools project
*
* 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 HOME_WIDGET_H
#define HOME_WIDGET_H

#include <QListWidget>


class HomeWidget : public QListWidget {
Q_OBJECT

public:
HomeWidget(QWidget * parent = 0);

private:
void readFiles();
};

#endif

104 changes: 104 additions & 0 deletions src/firejail-ui/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright (C) 2015-2016 Firetools Authors
*
* This file is part of firetools project
*
* 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 <QMenu>
#include <QSystemTrayIcon>
#include <QLibraryInfo>
#include <QWizard>

#include "firejail_ui.h"
#include "wizard.h"
#include "../common/utils.h"
#include "../../firetools_config.h"

int arg_debug = 0;
int svg_not_found = 0;

static void usage() {
printf("Firejail-ui - graphical user interface for Firejail security sandbox\n\n");
printf("Usage: firejail-ui [options]\n\n");
printf("Options:\n");
printf("\t--debug - debug mode\n\n");
printf("\t--help - this help screen\n\n");
printf("\t--version - print software version and exit\n\n");
}


int main(int argc, char *argv[]) {
// parse arguments
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--debug") == 0)
arg_debug = 1;
else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0) {
usage();
return 0;
}
else if (strcmp(argv[i], "--version") == 0) {
printf("Firejail-ui version " PACKAGE_VERSION "\n");
return 0;
}
else {
fprintf(stderr, "Error: invalid option\n");
usage();
return 1;
}
}

struct stat s;
#if QT_VERSION >= 0x050000
// test run time dependencies - print warning and continue program
QString ppath = QLibraryInfo::location(QLibraryInfo::PluginsPath);
ppath += "/imageformats/libqsvg.so";
if (stat(ppath.toUtf8().constData(), &s) == -1) {
fprintf(stderr, "Warning: QT5 SVG support not installed, please install libqt5svg5 package\n");
svg_not_found = 1;
}
#endif

// test run time dependencies - exit
if (!which("firejail")) {
fprintf(stderr, "Error: firejail package not found, please install it!\n");
exit(1);
}

// create firetools directory if it doesn't exist
char *path;
char *homedir = get_home_directory();
if (asprintf(&path, "%s/.config/firetools", homedir) == -1)
errExit("asprintf");
free(homedir);
if (stat(path, &s) == -1) {
/* coverity[toctou] */
int rv = mkdir(path, 0755);
if (rv == -1) {
fprintf(stderr, "Error: cannot create %s directory\n", path);
exit(1);
}
}
free(path);

// initialize resources
// Q_INIT_RESOURCE(firetools);

QApplication app(argc, argv);
Wizard wizard;
wizard.show();
return app.exec();
}
Loading

0 comments on commit b071b28

Please sign in to comment.