From ce0542746844a2e96331b3f51c2b581221a98abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Wed, 16 Mar 2016 23:34:05 +0100 Subject: [PATCH 01/27] Makefile paths for 32/64 bits systems, configuration and documentation more apropiate for certain OS distributions --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 16273a15..da6973c6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,13 @@ # Set to 'yes' to include debugging information, e.g. DEBUG=yes make -e -DEBUG := no +DEBUG := yes PREFIX ?= /usr -LIBDIR ?= lib +ARCH := $(shell getconf LONG_BIT) +ifeq ($(ARCH),64) + LIBDIR := lib64 +else + LIBDIR := lib +endif # compiler/linker options CC := gcc @@ -43,11 +48,11 @@ TOOLS_SRC := tools # Conf CONFS := doc/pamusb.conf -CONFS_DEST := $(DESTDIR)/etc +CONFS_DEST := $(DESTDIR)/etc/security # Doc DOCS := doc/CONFIGURATION.md -DOCS_DEST := $(DESTDIR)$(PREFIX)/share/doc/pamusb +DOCS_DEST := $(DESTDIR)$(PREFIX)/share/doc/pam_usb # Man MANS := doc/pamusb-conf.1.gz doc/pamusb-agent.1.gz doc/pamusb-check.1.gz From fb1d08a8d7f5a8a19fd6d6f986728399cbd99808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Tsao=20Sant=C3=ADn?= Date: Wed, 16 Mar 2016 23:56:42 +0100 Subject: [PATCH 02/27] Updated Free Software Foundation address in license notes --- COPYING | 2 +- src/conf.c | 4 ++-- src/conf.h | 4 ++-- src/device.c | 4 ++-- src/device.h | 4 ++-- src/hal.c | 4 ++-- src/hal.h | 4 ++-- src/local.c | 4 ++-- src/local.h | 4 ++-- src/log.c | 4 ++-- src/log.h | 4 ++-- src/mem.c | 4 ++-- src/mem.h | 4 ++-- src/pad.c | 4 ++-- src/pad.h | 4 ++-- src/pam.c | 4 ++-- src/pamusb-check.c | 4 ++-- src/version.h | 4 ++-- src/volume.c | 4 ++-- src/volume.h | 4 ++-- src/xpath.c | 4 ++-- src/xpath.h | 4 ++-- tools/pamusb-agent | 4 ++-- tools/pamusb-conf | 4 ++-- 24 files changed, 47 insertions(+), 47 deletions(-) diff --git a/COPYING b/COPYING index d60c31a9..dcd427ae 100644 --- a/COPYING +++ b/COPYING @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/src/conf.c b/src/conf.c index 0d8f101c..5eda4110 100644 --- a/src/conf.c +++ b/src/conf.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/conf.h b/src/conf.h index c43f5987..e77171e9 100644 --- a/src/conf.h +++ b/src/conf.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_CONF_H_ diff --git a/src/device.c b/src/device.c index dfe9ae0b..05bdd391 100644 --- a/src/device.c +++ b/src/device.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/device.h b/src/device.h index e9a38512..793d0a04 100644 --- a/src/device.h +++ b/src/device.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_DEVICE_H_ diff --git a/src/hal.c b/src/hal.c index f9517927..c4c0357d 100644 --- a/src/hal.c +++ b/src/hal.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/hal.h b/src/hal.h index 78cbd0b9..930e91c9 100644 --- a/src/hal.h +++ b/src/hal.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_HAL_H_ diff --git a/src/local.c b/src/local.c index 8f3ce8d3..ffa2ec54 100644 --- a/src/local.c +++ b/src/local.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/local.h b/src/local.h index 1efb66c9..7de8beaf 100644 --- a/src/local.h +++ b/src/local.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_LOCAL_H_ diff --git a/src/log.c b/src/log.c index 1e99cc51..ed8da0ce 100644 --- a/src/log.c +++ b/src/log.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/log.h b/src/log.h index 7c779e8c..31994c5b 100644 --- a/src/log.h +++ b/src/log.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_LOG_H_ diff --git a/src/mem.c b/src/mem.c index e76f6662..dcc94e99 100644 --- a/src/mem.c +++ b/src/mem.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/mem.h b/src/mem.h index b5fbd0d9..1b69cd9c 100644 --- a/src/mem.h +++ b/src/mem.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_MEM_H_ diff --git a/src/pad.c b/src/pad.c index b1b54d17..7906ce5d 100644 --- a/src/pad.c +++ b/src/pad.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/pad.h b/src/pad.h index 6491c719..4c4fec81 100644 --- a/src/pad.h +++ b/src/pad.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_OTP_H_ diff --git a/src/pam.c b/src/pam.c index b68ac5af..38327707 100644 --- a/src/pam.c +++ b/src/pam.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define PAM_SM_AUTH diff --git a/src/pamusb-check.c b/src/pamusb-check.c index 72a44da5..d2e0de31 100644 --- a/src/pamusb-check.c +++ b/src/pamusb-check.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/version.h b/src/version.h index 87d08a72..987825cd 100644 --- a/src/version.h +++ b/src/version.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_VERSION_H_ diff --git a/src/volume.c b/src/volume.c index c5a55e67..de703639 100644 --- a/src/volume.c +++ b/src/volume.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/volume.h b/src/volume.h index f7c2fe00..3055a005 100644 --- a/src/volume.h +++ b/src/volume.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef VOLUME_H_ diff --git a/src/xpath.c b/src/xpath.c index 9673bea5..1372106b 100644 --- a/src/xpath.c +++ b/src/xpath.c @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/src/xpath.h b/src/xpath.h index 1a74cbc1..6b6bcc50 100644 --- a/src/xpath.h +++ b/src/xpath.h @@ -11,8 +11,8 @@ * 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA + * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin + * Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PUSB_XPATH_H_ diff --git a/tools/pamusb-agent b/tools/pamusb-agent index ffb6b3d4..faaf3187 100755 --- a/tools/pamusb-agent +++ b/tools/pamusb-agent @@ -12,8 +12,8 @@ # 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., 59 Temple -# Place, Suite 330, Boston, MA 02111-1307 USA +# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +# Street, Fifth Floor, Boston, MA 02110-1301 USA. import os import sys diff --git a/tools/pamusb-conf b/tools/pamusb-conf index c253fb2d..79a71a02 100755 --- a/tools/pamusb-conf +++ b/tools/pamusb-conf @@ -12,8 +12,8 @@ # 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., 59 Temple -# Place, Suite 330, Boston, MA 02111-1307 USA +# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +# Street, Fifth Floor, Boston, MA 02110-1301 USA. import dbus From 1ccae6671c2570d46db35e8d11aecfc8ebb5926c Mon Sep 17 00:00:00 2001 From: Luka Novsak Date: Sun, 7 Feb 2016 13:30:41 +0100 Subject: [PATCH 03/27] port to udisks2 --- Makefile | 5 +- src/device.c | 77 ++++++---- src/device.h | 1 + src/hal.c | 345 --------------------------------------------- src/hal.h | 31 ---- src/pad.c | 24 ++-- src/pad.h | 4 +- src/volume.c | 225 ++++++++++++++++------------- src/volume.h | 15 +- tools/pamusb-agent | 53 ++++--- tools/pamusb-conf | 43 +++--- 11 files changed, 266 insertions(+), 557 deletions(-) delete mode 100644 src/hal.c delete mode 100644 src/hal.h diff --git a/Makefile b/Makefile index 16273a15..14a8c974 100644 --- a/Makefile +++ b/Makefile @@ -7,16 +7,15 @@ LIBDIR ?= lib # compiler/linker options CC := gcc CFLAGS := $(CFLAGS) -Wall -fPIC `pkg-config --cflags libxml-2.0` \ - `pkg-config --cflags dbus-1` + `pkg-config --cflags udisks2` LIBS := `pkg-config --libs libxml-2.0` \ - `pkg-config --libs dbus-1` + `pkg-config --libs udisks2` # common source files SRCS := src/conf.c \ src/mem.c \ src/log.c \ src/xpath.c \ - src/hal.c \ src/pad.c \ src/volume.c \ src/local.c \ diff --git a/src/device.c b/src/device.c index dfe9ae0b..fdab4ffc 100644 --- a/src/device.c +++ b/src/device.c @@ -1,4 +1,7 @@ +/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t; -*- */ + /* + * Copyright (c) 2016 Luka Novsak * Copyright (c) 2003-2007 Andrea Luzzardi * * This file is part of the pam_usb project. pam_usb is free software; @@ -18,56 +21,74 @@ #include #include #include -#include -#include "mem.h" + +#include + #include "conf.h" -#include "hal.h" #include "log.h" #include "pad.h" #include "device.h" -static int pusb_device_connected(t_pusb_options *opts, DBusConnection *dbus) +static int pusb_device_connected(t_pusb_options *opts, UDisksClient *udisks) { - char *udi = NULL; + GDBusObjectManager *manager = udisks_client_get_object_manager(udisks); + GList *objects = g_dbus_object_manager_get_objects(manager); + int retval = 0; + int i; + UDisksObject *object = NULL; + UDisksDrive *drive = NULL; + + manager = udisks_client_get_object_manager(udisks); + objects = g_dbus_object_manager_get_objects(manager); log_debug("Searching for \"%s\" in the hardware database...\n", opts->device.name); - udi = pusb_hal_find_item(dbus, - "DriveSerial", opts->device.serial, - "DriveVendor", opts->device.vendor, - "DriveModel", opts->device.model, - NULL); - if (!udi) + + for (i = 0; i < g_list_length(objects); ++i) { - log_error("Device \"%s\" is not connected.\n", - opts->device.name); - return (0); + object = UDISKS_OBJECT(g_list_nth(objects, i)->data); + if (udisks_object_peek_drive(object)) + { + drive = udisks_object_get_drive(object); + retval = strcmp(udisks_drive_get_serial(drive), opts->device.serial) == 0 && + strcmp(udisks_drive_get_vendor(drive), opts->device.vendor) == 0 && + strcmp(udisks_drive_get_model(drive), opts->device.model) == 0; + g_object_unref(drive); + if (retval) + break; + } } - xfree(udi); - log_info("Device \"%s\" is connected (good).\n", opts->device.name); - return (1); + + if (retval) + log_info("Device \"%s\" is connected (good).\n", + opts->device.name); + else + log_error("Device \"%s\" is not connected (bad).\n", + opts->device.name); + + g_list_foreach (objects, (GFunc) g_object_unref, NULL); + g_list_free (objects); + + return (retval); } -int pusb_device_check(t_pusb_options *opts, - const char *user) +int pusb_device_check(t_pusb_options *opts, const char *user) { - DBusConnection *dbus = NULL; - int retval = 0; + UDisksClient *udisks = NULL; + int retval = 0; - log_debug("Connecting to HAL...\n"); - if (!(dbus = pusb_hal_dbus_connect())) - return (0); + udisks = udisks_client_new_sync(NULL, NULL); - if (!pusb_device_connected(opts, dbus)) + if (!pusb_device_connected(opts, udisks)) { - pusb_hal_dbus_disconnect(dbus); + g_object_unref(udisks); return (0); } if (opts->one_time_pad) { log_info("Performing one time pad verification...\n"); - retval = pusb_pad_check(opts, dbus, user); + retval = pusb_pad_check(opts, udisks, user); } else { @@ -75,6 +96,6 @@ int pusb_device_check(t_pusb_options *opts, retval = 1; } - pusb_hal_dbus_disconnect(dbus); + g_object_unref(udisks); return (retval); } diff --git a/src/device.h b/src/device.h index e9a38512..6d97d996 100644 --- a/src/device.h +++ b/src/device.h @@ -17,6 +17,7 @@ #ifndef PUSB_DEVICE_H_ # define PUSB_DEVICE_H_ +# include "conf.h" int pusb_device_check(t_pusb_options *opts, const char *user); diff --git a/src/hal.c b/src/hal.c deleted file mode 100644 index f9517927..00000000 --- a/src/hal.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2003-2007 Andrea Luzzardi - * - * This file is part of the pam_usb project. pam_usb is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * pam_usb 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include "mem.h" -#include "log.h" -#include "hal.h" - -DBusConnection *pusb_hal_dbus_connect(void) -{ - DBusConnection *dbus = NULL; - DBusError error; - - dbus_error_init(&error); - if (!(dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) - { - /* Workaround for https://bugs.freedesktop.org/show_bug.cgi?id=11876 */ - uid_t ruid; - uid_t euid; - - if (!(euid = geteuid()) && (ruid = getuid())) - { - dbus_error_free(&error); - setreuid(euid, euid); - dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); - setreuid(ruid, euid); - } - if (!dbus) - { - log_error("Cannot connect to system bus: %s\n", - error.message); - dbus_error_free(&error); - return (NULL); - } - } - return (dbus); -} - -void pusb_hal_dbus_disconnect(DBusConnection *dbus) -{ - dbus_connection_unref(dbus); -} - -void pusb_hal_free_string_array(char **str_array, int length) -{ - int i; - - if (str_array == NULL) - return ; - - for (i = 0; i < length; ++i) - xfree(str_array[i]); - xfree(str_array); -} - -char **pusb_hal_get_string_array_from_iter(DBusMessageIter *iter, int *num_elements) -{ - int count; - char **buffer; - - count = 0; - buffer = (char **)xmalloc(sizeof(char *) * 8); - - buffer[0] = NULL; - while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING || - dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_OBJECT_PATH) - { - const char *value; - - if ((count % 8) == 0 && count != 0) { - buffer = xrealloc(buffer, sizeof (char *) * (count + 8)); - } - - dbus_message_iter_get_basic(iter, &value); - buffer[count] = xstrdup(value); - - dbus_message_iter_next(iter); - count++; - } - - if (num_elements != NULL) - *num_elements = count; - return buffer; -} - - - -DBusMessage *pusb_hal_get_raw_property(DBusConnection *dbus, - const char *udi, - const char *name) -{ - DBusMessage *message; - DBusMessage *reply; - DBusMessageIter iter; - DBusError error; - char *iface = "org.freedesktop.UDisks.Device"; - - message = dbus_message_new_method_call("org.freedesktop.UDisks", udi, - "org.freedesktop.DBus.Properties", - "Get"); - if (message == NULL) { - log_error("Could not allocate D-BUS message\n"); - return (NULL); - } - dbus_message_iter_init_append(message, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &iface); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); - - dbus_error_init(&error); - reply = dbus_connection_send_with_reply_and_block(dbus, - message, -1, - &error); - dbus_message_unref(message); - if (dbus_error_is_set(&error)) { - log_error("Error communicating with D-BUS\n"); - return (NULL); - } - dbus_error_free(&error); - return (reply); -} - -char *pusb_hal_get_string_property(DBusConnection *dbus, - const char *udi, - const char *name) -{ - DBusMessage *reply; - DBusMessageIter reply_iter; - char *data; - char *dbus_str; - - reply = pusb_hal_get_raw_property(dbus, udi, name); - if (reply == NULL) { - return (NULL); - } - - dbus_message_iter_init(reply, &reply_iter); - - if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_VARIANT) - { - dbus_message_unref(reply); - return (NULL); - } - - DBusMessageIter subiter; - dbus_message_iter_recurse(&reply_iter, &subiter); - dbus_message_iter_get_basic(&subiter, &dbus_str); - if (dbus_str != NULL) - data = xstrdup(dbus_str); - dbus_message_unref(reply); - return (data); -} - -char **pusb_hal_get_string_array_property(DBusConnection *dbus, - const char *udi, - const char *name, - int *n_items) -{ - DBusMessage *reply; - DBusMessageIter reply_iter; - char **items; - - reply = pusb_hal_get_raw_property(dbus, udi, name); - if (reply == NULL) { - return (NULL); - } - - dbus_message_iter_init(reply, &reply_iter); - - if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_VARIANT) - { - dbus_message_unref(reply); - return (NULL); - } - - DBusMessageIter subiter, subsubiter; - dbus_message_iter_recurse(&reply_iter, &subiter); - dbus_message_iter_recurse(&subiter, &subsubiter); - items = pusb_hal_get_string_array_from_iter(&subsubiter, n_items); - dbus_message_unref(reply); - if (!*n_items) - { - pusb_hal_free_string_array(items, *n_items); - return (NULL); - } - return (items); -} - - - -int pusb_hal_get_bool_property(DBusConnection *dbus, - const char *udi, - const char *name, - dbus_bool_t *value) -{ - DBusMessage *reply; - DBusMessageIter reply_iter; - - reply = pusb_hal_get_raw_property(dbus, udi, name); - if (reply == NULL) { - return (0); - } - - dbus_message_iter_init(reply, &reply_iter); - - if (dbus_message_iter_get_arg_type(&reply_iter) != - DBUS_TYPE_VARIANT) - { - dbus_message_unref(reply); - return (0); - } - - DBusMessageIter subiter; - dbus_message_iter_recurse(&reply_iter, &subiter); - dbus_message_iter_get_basic(&subiter, value); - dbus_message_unref(reply); - return (1); -} - -int pusb_hal_check_property(DBusConnection *dbus, - const char *udi, - const char *name, - const char *value) -{ - char *data; - int retval; - - data = pusb_hal_get_string_property(dbus, udi, name); - if (!data) - return (0); - retval = (strcmp(data, value) == 0); - xfree(data); - return (retval); -} - -char **pusb_hal_find_all_items(DBusConnection *dbus, int *count) -{ - DBusError error; - DBusMessage *message; - DBusMessage *reply; - DBusMessageIter iter_array, reply_iter; - char **devices; - int n_devices; - - *count = 0; - message = dbus_message_new_method_call("org.freedesktop.UDisks", - "/org/freedesktop/UDisks", - "org.freedesktop.UDisks", - "EnumerateDevices"); - if (message == NULL) - { - log_error("Couldn't allocate D-BUS message\n"); - return (NULL); - } - dbus_error_init(&error); - reply = dbus_connection_send_with_reply_and_block(dbus, - message, -1, - &error); - dbus_message_unref(message); - if (dbus_error_is_set(&error)) { - log_error("Error communicating with D-BUS\n"); - return (NULL); - } - if (reply == NULL) { - return (NULL); - } - dbus_message_iter_init(reply, &reply_iter); - if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) { - log_error("Malformed D-BUS reply"); - return (NULL); - } - dbus_message_iter_recurse(&reply_iter, &iter_array); - devices = pusb_hal_get_string_array_from_iter(&iter_array, &n_devices); - dbus_message_unref(reply); - if (!n_devices) - { - pusb_hal_free_string_array(devices, n_devices); - return (NULL); - } - *count = n_devices; - return (devices); -} - -char *pusb_hal_find_item(DBusConnection *dbus, - ...) -{ - char **devices; - int n_devices; - char *udi = NULL; - va_list ap; - int i; - - devices = pusb_hal_find_all_items(dbus, &n_devices); - if (!devices) - return (NULL); - if (!n_devices) - return (NULL); - - for (i = 0; i < n_devices; ++i) - { - char *key = NULL; - int match = 1; - - va_start(ap, dbus); - while ((key = va_arg(ap, char *))) - { - char *value = NULL; - - value = va_arg(ap, char *); - if (!value || *value == 0x0) - continue ; - if (!pusb_hal_check_property(dbus, devices[i], - key, value)) - { - match = 0; - break; - } - } - if (match) - { - udi = xstrdup(devices[i]); - break; - } - va_end(ap); - } - pusb_hal_free_string_array(devices, n_devices); - return (udi); -} diff --git a/src/hal.h b/src/hal.h deleted file mode 100644 index 78cbd0b9..00000000 --- a/src/hal.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003-2007 Andrea Luzzardi - * - * This file is part of the pam_usb project. pam_usb is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * pam_usb 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., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PUSB_HAL_H_ -# define PUSB_HAL_H_ -# include - -DBusConnection *pusb_hal_dbus_connect(void); -void pusb_hal_dbus_disconnect(DBusConnection *dbus); -char *pusb_hal_get_string_property(DBusConnection *dbus, const char *udi, const char *name); -int pusb_hal_get_bool_property(DBusConnection *dbus, const char *udi, const char *name, dbus_bool_t *value); -char **pusb_hal_get_string_array_property(DBusConnection *dbus, const char *udi, const char *name, int *n_items); -int pusb_hal_check_property(DBusConnection *dbus, const char *udi, const char *name, const char *value); -char *pusb_hal_find_item(DBusConnection *dbus, ...); -void pusb_hal_free_string_array(char **str_array, int length); - -#endif /* !PUSB_HAL_H_ */ diff --git a/src/pad.c b/src/pad.c index b1b54d17..c5c7699b 100644 --- a/src/pad.c +++ b/src/pad.c @@ -1,4 +1,7 @@ +/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t; -*- */ + /* + * Copyright (c) 2016 Luka Novsak * Copyright (c) 2003-2007 Andrea Luzzardi * * This file is part of the pam_usb project. pam_usb is free software; @@ -15,6 +18,8 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pad.h" + #include #include #include @@ -25,10 +30,10 @@ #include #include #include + #include "conf.h" #include "log.h" #include "volume.h" -#include "pad.h" static FILE *pusb_pad_open_device(t_pusb_options *opts, const char *mnt_point, @@ -262,20 +267,23 @@ static int pusb_pad_compare(t_pusb_options *opts, const char *volume, return (retval == 0); } -int pusb_pad_check(t_pusb_options *opts, DBusConnection *dbus, +int pusb_pad_check(t_pusb_options *opts, + UDisksClient *udisks, const char *user) { - char *volume = NULL; - int retval = 0; + t_pusb_volume *volume = NULL; + int retval = 0; - volume = pusb_volume_get(opts, dbus); + volume = pusb_volume_get(opts, udisks); if (!volume) return (0); - retval = pusb_pad_compare(opts, volume, user); + + retval = pusb_pad_compare(opts, volume->mount_point, user); if (retval) - pusb_pad_update(opts, volume, user); + pusb_pad_update(opts, volume->mount_point, user); else - log_error("Pad checking failed !\n"); + log_error("Pad checking failed!\n"); + pusb_volume_destroy(volume); return (retval); } diff --git a/src/pad.h b/src/pad.h index 6491c719..f161d90a 100644 --- a/src/pad.h +++ b/src/pad.h @@ -17,7 +17,9 @@ #ifndef PUSB_OTP_H_ # define PUSB_OTP_H_ +# include +# include "conf.h" -int pusb_pad_check(t_pusb_options *opts, DBusConnection *dbus, const char *user); +int pusb_pad_check(t_pusb_options *opts, UDisksClient *udisks, const char *user); #endif /* !PUSB_OTP_H_ */ diff --git a/src/volume.c b/src/volume.c index c5a55e67..74555d99 100644 --- a/src/volume.c +++ b/src/volume.c @@ -1,4 +1,7 @@ +/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t; -*- */ + /* + * Copyright (c) 2016 Luka Novsak * Copyright (c) 2003-2007 Andrea Luzzardi * * This file is part of the pam_usb project. pam_usb is free software; @@ -24,145 +27,177 @@ #ifndef __GNU__ #include #endif + #include "mem.h" #include "conf.h" #include "log.h" -#include "hal.h" #include "volume.h" -static int pusb_volume_mount(t_pusb_options *opts, char *udi, - DBusConnection *dbus) +static int pusb_volume_mount(t_pusb_volume *volume) { - char command[1024]; - char tempname[32]; - const char *devname; + GError *error = NULL; + GVariant *options = NULL; + GVariantBuilder builder; + int retval = 0; + const gchar *const *mount_points = NULL; - snprintf(tempname, sizeof(tempname), "pam_usb%d", getpid()); - if (!(devname = pusb_hal_get_string_property(dbus, udi, "DeviceFile"))) - { - log_error("Unable to retrieve device filename\n"); - return (0); - } - log_debug("Attempting to mount device %s with label %s\n", - devname, tempname); - snprintf(command, sizeof(command), "pmount -A -s %s %s", - devname, tempname); - log_debug("Executing \"%s\"\n", command); - if (system(command) != 0) - { - log_error("Mount failed\n"); - return (0); - } + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + options = g_variant_builder_end(&builder); - log_debug("Mount succeeded.\n"); - return (1); -} + log_debug("Attempting to mount device %s.\n", volume->device); -static char *pusb_volume_mount_path(t_pusb_options *opts, char *udi, DBusConnection* dbus) -{ - dbus_bool_t is_mounted; - if (!pusb_hal_get_bool_property(dbus, udi, "DeviceIsMounted", &is_mounted)) - { - return (NULL); - } - if (is_mounted != TRUE) + udisks_filesystem_call_mount_sync(volume->filesystem, + options, + &volume->mount_point, + NULL, + &error); + + if (!error) { - log_debug("Device %s is not mounted\n", udi); - return (NULL); + volume->unmount = 1; + retval = 1; + log_debug("Mounted device %s to %s.\n", + volume->device, volume->mount_point); } - - int n_mount; - char **mount_pathes = pusb_hal_get_string_array_property(dbus, udi, "DeviceMountPaths", &n_mount); - if (!mount_pathes) + else if (error->code == UDISKS_ERROR_ALREADY_MOUNTED) { - log_debug("Failed to retrieve device %s mount path\n", udi); - return (NULL); + g_main_context_iteration(NULL, FALSE); + mount_points = udisks_filesystem_get_mount_points(volume->filesystem); + volume->mount_point = xstrdup(*mount_points); + retval = 1; + log_debug("Device %s mounted in between our probe and mount.\n", + volume->device); } - if (n_mount > 1) + else { - log_debug("Device %s is mounted more than once\n", udi); + log_error("Failed to mount device %s.\n", volume->device); } - char *mount_path = xstrdup(mount_pathes[0]); - pusb_hal_free_string_array(mount_pathes, n_mount); - log_debug("Device %s is mounted on %s\n", udi, mount_path); - return (mount_path); + + if (error) + g_error_free(error); + + return (retval); } -static char *pusb_volume_probe(t_pusb_options *opts, - DBusConnection *dbus) +static t_pusb_volume *pusb_volume_probe(t_pusb_options *opts, + UDisksClient *udisks) { - int maxtries = 0; - int i; + t_pusb_volume *volume = NULL; + int maxtries = (opts->probe_timeout * 1000000) / 250000; + int i; + int j; + GList *blocks = NULL; + UDisksBlock *block = NULL; + UDisksObject *object = NULL; + const gchar *const *mount_points = NULL; if (!*(opts->device.volume_uuid)) { - log_debug("No UUID configured for device\n"); + log_debug("No UUID configured for device.\n"); return (NULL); } - log_debug("Searching for volume with uuid %s\n", opts->device.volume_uuid); - maxtries = ((opts->probe_timeout * 1000000) / 250000); + + log_debug("Searching for volume with uuid %s.\n", + opts->device.volume_uuid); + for (i = 0; i < maxtries; ++i) { - char *udi = NULL; + blocks = udisks_client_get_block_for_uuid(udisks, opts->device.volume_uuid); if (i == 1) log_info("Probing volume (this could take a while)...\n"); - udi = pusb_hal_find_item(dbus, - "IdUuid", opts->device.volume_uuid, - NULL); - if (!udi) + + for (j = 0; j < g_list_length(blocks); ++j) { - usleep(250000); - continue; + block = UDISKS_BLOCK(g_list_nth(blocks, j)->data); + object = UDISKS_OBJECT(g_dbus_interface_get_object(G_DBUS_INTERFACE(block))); + + if (udisks_object_peek_filesystem(object)) + { + volume = xmalloc(sizeof(t_pusb_volume)); + volume->filesystem = udisks_object_get_filesystem(object); + volume->unmount = 0; + volume->device = xstrdup(udisks_block_get_device(block)); + volume->mount_point = NULL; + + mount_points = udisks_filesystem_get_mount_points(volume->filesystem); + if (mount_points && *mount_points) + volume->mount_point = xstrdup(*mount_points); + + break; + } + } + + g_list_foreach (blocks, (GFunc) g_object_unref, NULL); + g_list_free (blocks); + + if (volume) + { + log_debug("Found volume %s.\n", opts->device.volume_uuid); + break; } - return (udi); + + usleep(250000); + g_main_context_iteration(NULL, FALSE); } - return (NULL); + + if (!volume) + log_debug("Could not find volume %s.\n", + opts->device.volume_uuid); + + return (volume); } -char *pusb_volume_get(t_pusb_options *opts, DBusConnection *dbus) +t_pusb_volume *pusb_volume_get(t_pusb_options *opts, UDisksClient *udisks) { - char *volume_udi; - char *mount_point; + t_pusb_volume *volume = pusb_volume_probe(opts, udisks); - if (!(volume_udi = pusb_volume_probe(opts, dbus))) + if (!volume) return (NULL); - log_debug("Found volume %s\n", opts->device.volume_uuid); - mount_point = pusb_volume_mount_path(opts, volume_udi, dbus); - if (mount_point) - { - log_debug("Volume is already mounted.\n"); - return (mount_point); - } - if (!pusb_volume_mount(opts, volume_udi, dbus)) + + if (volume->mount_point) { - xfree(volume_udi); - return (NULL); + log_debug("Volume %s is already mounted.\n", + opts->device.volume_uuid); + return (volume); } - mount_point = pusb_volume_mount_path(opts, volume_udi, dbus); - if (!mount_point) + + if(!pusb_volume_mount(volume)) { - log_error("Unable to retrieve %s mount point\n", volume_udi); - pusb_volume_destroy(mount_point); + pusb_volume_destroy(volume); return (NULL); } - return (mount_point); + + return (volume); } -void pusb_volume_destroy(char *mntpoint) +void pusb_volume_destroy(t_pusb_volume *volume) { - if (mntpoint && strstr(mntpoint, "pam_usb")) + GVariantBuilder builder; + GVariant *options; + int ret; + + if (volume->unmount) { - char command[1024]; - - log_debug("Attempting to umount %s\n", - mntpoint); - snprintf(command, sizeof(command), "pumount %s", mntpoint); - log_debug("Executing \"%s\"\n", command); - if (!system(command)) - log_debug("Umount succeeded.\n"); - else - log_error("Unable to umount %s\n", mntpoint); + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + options = g_variant_builder_end(&builder); + + log_debug("Attempting to unmount %s from %s.\n", + volume->device, volume->mount_point); + + ret = udisks_filesystem_call_unmount_sync(volume->filesystem, + options, + NULL, + NULL); + if (!ret) + log_error("Unable to unmount %s from %s\n", + volume->device, volume->mount_point); + + log_debug("Unmount succeeded.\n"); } - xfree(mntpoint); + + g_object_unref(volume->filesystem); + xfree(volume->device); + xfree(volume->mount_point); + xfree(volume); } diff --git a/src/volume.h b/src/volume.h index f7c2fe00..3f83ef46 100644 --- a/src/volume.h +++ b/src/volume.h @@ -17,9 +17,18 @@ #ifndef VOLUME_H_ # define VOLUME_H_ -# include "hal.h" +# include +# include "conf.h" -char *pusb_volume_get(t_pusb_options *opts, DBusConnection *dbus); -void pusb_volume_destroy(char *mntpoint); +typedef struct pusb_volume +{ + UDisksFilesystem *filesystem; + int unmount; + char *device; + char *mount_point; +} t_pusb_volume; + +t_pusb_volume *pusb_volume_get(t_pusb_options *opts, UDisksClient *udisks); +void pusb_volume_destroy(t_pusb_volume *volume); #endif /* !VOLUME_H_ */ diff --git a/tools/pamusb-agent b/tools/pamusb-agent index ffb6b3d4..c2f21443 100755 --- a/tools/pamusb-agent +++ b/tools/pamusb-agent @@ -20,10 +20,13 @@ import sys import pwd import getopt import syslog -import gobject -import dbus -if getattr(dbus, 'version', (0,0,0)) >= (0,41,0): - import dbus.glib +import gi + +gi.require_version('UDisks', '2.0') + +from gi.repository import GLib +from gi.repository import UDisks + try: # Python 2.5 import xml.etree.ElementTree as et @@ -39,41 +42,46 @@ class HotPlugDevice: self.__udi = None self.__serial = serial self.__callbacks = [] - self.__bus = dbus.SystemBus() self.__running = False def run(self): self.__scanDevices() self.__registerSignals() self.__running = True - gobject.MainLoop().run() + GLib.MainLoop().run() print 'signals registered' def addCallback(self, callback): self.__callbacks.append(callback) def __scanDevices(self): - halService = self.__bus.get_object('org.freedesktop.UDisks', - '/org/freedesktop/UDisks') - halManager = dbus.Interface(halService, 'org.freedesktop.UDisks') - for udi in halManager.EnumerateDevices(): - self.__deviceAdded(udi) + for udi in udisksObjectManager.get_objects(): + if udi.get_block(): + device = udisks.get_drive_for_block(udi.get_block()) + if device: + self.__deviceAdded(device) def __registerSignals(self): - halService = self.__bus.get_object('org.freedesktop.UDisks', - '/org/freedesktop/UDisks') - halManager = dbus.Interface(halService, 'org.freedesktop.UDisks') - for signal, callback in (('DeviceAdded', self.__deviceAdded), - ('DeviceRemoved', self.__deviceRemoved)): - halManager.connect_to_signal(signal, callback) + for signal, callback in (('object-added', self.__objectAdded), + ('object-removed', self.__objectRemoved)): + udisksObjectManager.connect(signal, callback) + + def __objectAdded(self, _, udi): + if udi.get_block(): + device = udisks.get_drive_for_block(udi.get_block()) + if device: + self.__deviceAdded(device) + + def __objectRemoved(self, _, udi): + if udi.get_block(): + device = udisks.get_drive_for_block(udi.get_block()) + if device: + self.__deviceRemoved(device) def __deviceAdded(self, udi): if self.__udi is not None: return - deviceObj = self.__bus.get_object('org.freedesktop.UDisks', - udi) - deviceProperties = dbus.Interface(deviceObj, dbus.PROPERTIES_IFACE) - if deviceProperties.Get('org.freedesktop.UDisks.Device', 'DriveSerial') != self.__serial: + if udi.get_property('serial') != self.__serial: return self.__udi = udi if self.__running: @@ -197,6 +205,9 @@ def authChangeCallback(event): logger.info('Authentication failed for device %s. ' \ 'Keeping user "%s" locked down.' % (deviceName, username)) +udisks = UDisks.Client.new_sync() +udisksObjectManager = udisks.get_object_manager() + hpDev = HotPlugDevice(serial) hpDev.addCallback(authChangeCallback) diff --git a/tools/pamusb-conf b/tools/pamusb-conf index 14cfe73f..64aabda4 100755 --- a/tools/pamusb-conf +++ b/tools/pamusb-conf @@ -15,40 +15,41 @@ # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place, Suite 330, Boston, MA 02111-1307 USA - -import dbus import sys import os +import gi + +gi.require_version('UDisks', '2.0') + +from gi.repository import UDisks from xml.dom import minidom class Device: def __init__(self, udi): self.__udi = udi - deviceObj = bus.get_object('org.freedesktop.UDisks', - udi) - deviceProperties = dbus.Interface(deviceObj, dbus.PROPERTIES_IFACE) - if deviceProperties.Get('org.freedesktop.UDisks.Device', 'DeviceIsRemovable') != 1: + deviceObj = udisksObjectManager.get_object(udi) + driveObj = deviceObj.get_drive() + if not driveObj.get_property('removable'): # Workaround for removable devices with fixed media (such as SD cards) if not "mmcblk" in udi: raise Exception, 'Not a removable device' - self.vendor = deviceProperties.Get('org.freedesktop.UDisks.Device', 'DriveVendor') - self.product = deviceProperties.Get('org.freedesktop.UDisks.Device', 'DriveModel') - self.serialNumber = deviceProperties.Get('org.freedesktop.UDisks.Device', 'DriveSerial') + self.vendor = driveObj.get_property('vendor') + self.product = driveObj.get_property('model') + self.serialNumber = driveObj.get_property('serial') if len(self.volumes()) < 1: raise Exception, 'Device does not contain any volume' def volumes(self): vols = [] - for udi in halManager.get_dbus_method('EnumerateDevices')(): - deviceObj = bus.get_object('org.freedesktop.UDisks', - udi) - deviceProperties = dbus.Interface(deviceObj, dbus.PROPERTIES_IFACE) - if deviceProperties.Get('org.freedesktop.UDisks.Device', 'DeviceIsPartition') != 1: + for udi in [o.get_object_path() for o in udisksObjectManager.get_objects() if o.get_block()]: + obj = udisks.get_object(udi) + blockObj = obj.get_block() + if blockObj.get_property('drive') != self.__udi: continue - if deviceProperties.Get('org.freedesktop.UDisks.Device', 'PartitionSlave') != self.__udi: + if not obj.get_filesystem(): continue - vols.append({'uuid' : deviceProperties.Get('org.freedesktop.UDisks.Device', 'IdUuid'), - 'device' : deviceProperties.Get('org.freedesktop.UDisks.Device', 'DeviceFile')}) + vols.append({'uuid' : blockObj.get_property('id-uuid'), + 'device' : blockObj.get_property('device')}) return vols def __repr__(self): @@ -143,7 +144,7 @@ def addUser(options): def addDevice(options): devices = [] - for udi in halManager.get_dbus_method('EnumerateDevices')(): + for udi in [o.get_object_path() for o in udisksObjectManager.get_objects() if o.get_drive()]: try: if options['verbose']: print 'Inspecting %s' % udi @@ -259,10 +260,8 @@ if options['deviceName'] is None and options['userName'] is None: usage() if options['deviceName'] is not None: - bus = dbus.SystemBus() - halService = bus.get_object('org.freedesktop.UDisks', - '/org/freedesktop/UDisks') - halManager = dbus.Interface(halService, 'org.freedesktop.UDisks') + udisks = UDisks.Client.new_sync() + udisksObjectManager = udisks.get_object_manager() try: addDevice(options) except KeyboardInterrupt: From 9c55f042d87b34bc5c035397e9ab4ce7c1da8d81 Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 05:30:21 -0400 Subject: [PATCH 04/27] Update Makefile - disable DEBUG --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index da6973c6..5fac316f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Set to 'yes' to include debugging information, e.g. DEBUG=yes make -e -DEBUG := yes +DEBUG := no PREFIX ?= /usr ARCH := $(shell getconf LONG_BIT) From fe2c595bfc97d84435a9c3b209372ba8ba00b3e3 Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 05:44:45 -0400 Subject: [PATCH 05/27] Delete hal.c in prep for udisks2 merge --- src/hal.c | 345 ------------------------------------------------------ 1 file changed, 345 deletions(-) delete mode 100644 src/hal.c diff --git a/src/hal.c b/src/hal.c deleted file mode 100644 index c4c0357d..00000000 --- a/src/hal.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2003-2007 Andrea Luzzardi - * - * This file is part of the pam_usb project. pam_usb is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * pam_usb 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 -#include -#include -#include -#include -#include "mem.h" -#include "log.h" -#include "hal.h" - -DBusConnection *pusb_hal_dbus_connect(void) -{ - DBusConnection *dbus = NULL; - DBusError error; - - dbus_error_init(&error); - if (!(dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) - { - /* Workaround for https://bugs.freedesktop.org/show_bug.cgi?id=11876 */ - uid_t ruid; - uid_t euid; - - if (!(euid = geteuid()) && (ruid = getuid())) - { - dbus_error_free(&error); - setreuid(euid, euid); - dbus = dbus_bus_get(DBUS_BUS_SYSTEM, &error); - setreuid(ruid, euid); - } - if (!dbus) - { - log_error("Cannot connect to system bus: %s\n", - error.message); - dbus_error_free(&error); - return (NULL); - } - } - return (dbus); -} - -void pusb_hal_dbus_disconnect(DBusConnection *dbus) -{ - dbus_connection_unref(dbus); -} - -void pusb_hal_free_string_array(char **str_array, int length) -{ - int i; - - if (str_array == NULL) - return ; - - for (i = 0; i < length; ++i) - xfree(str_array[i]); - xfree(str_array); -} - -char **pusb_hal_get_string_array_from_iter(DBusMessageIter *iter, int *num_elements) -{ - int count; - char **buffer; - - count = 0; - buffer = (char **)xmalloc(sizeof(char *) * 8); - - buffer[0] = NULL; - while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING || - dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_OBJECT_PATH) - { - const char *value; - - if ((count % 8) == 0 && count != 0) { - buffer = xrealloc(buffer, sizeof (char *) * (count + 8)); - } - - dbus_message_iter_get_basic(iter, &value); - buffer[count] = xstrdup(value); - - dbus_message_iter_next(iter); - count++; - } - - if (num_elements != NULL) - *num_elements = count; - return buffer; -} - - - -DBusMessage *pusb_hal_get_raw_property(DBusConnection *dbus, - const char *udi, - const char *name) -{ - DBusMessage *message; - DBusMessage *reply; - DBusMessageIter iter; - DBusError error; - char *iface = "org.freedesktop.UDisks.Device"; - - message = dbus_message_new_method_call("org.freedesktop.UDisks", udi, - "org.freedesktop.DBus.Properties", - "Get"); - if (message == NULL) { - log_error("Could not allocate D-BUS message\n"); - return (NULL); - } - dbus_message_iter_init_append(message, &iter); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &iface); - dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); - - dbus_error_init(&error); - reply = dbus_connection_send_with_reply_and_block(dbus, - message, -1, - &error); - dbus_message_unref(message); - if (dbus_error_is_set(&error)) { - log_error("Error communicating with D-BUS\n"); - return (NULL); - } - dbus_error_free(&error); - return (reply); -} - -char *pusb_hal_get_string_property(DBusConnection *dbus, - const char *udi, - const char *name) -{ - DBusMessage *reply; - DBusMessageIter reply_iter; - char *data; - char *dbus_str; - - reply = pusb_hal_get_raw_property(dbus, udi, name); - if (reply == NULL) { - return (NULL); - } - - dbus_message_iter_init(reply, &reply_iter); - - if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_VARIANT) - { - dbus_message_unref(reply); - return (NULL); - } - - DBusMessageIter subiter; - dbus_message_iter_recurse(&reply_iter, &subiter); - dbus_message_iter_get_basic(&subiter, &dbus_str); - if (dbus_str != NULL) - data = xstrdup(dbus_str); - dbus_message_unref(reply); - return (data); -} - -char **pusb_hal_get_string_array_property(DBusConnection *dbus, - const char *udi, - const char *name, - int *n_items) -{ - DBusMessage *reply; - DBusMessageIter reply_iter; - char **items; - - reply = pusb_hal_get_raw_property(dbus, udi, name); - if (reply == NULL) { - return (NULL); - } - - dbus_message_iter_init(reply, &reply_iter); - - if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_VARIANT) - { - dbus_message_unref(reply); - return (NULL); - } - - DBusMessageIter subiter, subsubiter; - dbus_message_iter_recurse(&reply_iter, &subiter); - dbus_message_iter_recurse(&subiter, &subsubiter); - items = pusb_hal_get_string_array_from_iter(&subsubiter, n_items); - dbus_message_unref(reply); - if (!*n_items) - { - pusb_hal_free_string_array(items, *n_items); - return (NULL); - } - return (items); -} - - - -int pusb_hal_get_bool_property(DBusConnection *dbus, - const char *udi, - const char *name, - dbus_bool_t *value) -{ - DBusMessage *reply; - DBusMessageIter reply_iter; - - reply = pusb_hal_get_raw_property(dbus, udi, name); - if (reply == NULL) { - return (0); - } - - dbus_message_iter_init(reply, &reply_iter); - - if (dbus_message_iter_get_arg_type(&reply_iter) != - DBUS_TYPE_VARIANT) - { - dbus_message_unref(reply); - return (0); - } - - DBusMessageIter subiter; - dbus_message_iter_recurse(&reply_iter, &subiter); - dbus_message_iter_get_basic(&subiter, value); - dbus_message_unref(reply); - return (1); -} - -int pusb_hal_check_property(DBusConnection *dbus, - const char *udi, - const char *name, - const char *value) -{ - char *data; - int retval; - - data = pusb_hal_get_string_property(dbus, udi, name); - if (!data) - return (0); - retval = (strcmp(data, value) == 0); - xfree(data); - return (retval); -} - -char **pusb_hal_find_all_items(DBusConnection *dbus, int *count) -{ - DBusError error; - DBusMessage *message; - DBusMessage *reply; - DBusMessageIter iter_array, reply_iter; - char **devices; - int n_devices; - - *count = 0; - message = dbus_message_new_method_call("org.freedesktop.UDisks", - "/org/freedesktop/UDisks", - "org.freedesktop.UDisks", - "EnumerateDevices"); - if (message == NULL) - { - log_error("Couldn't allocate D-BUS message\n"); - return (NULL); - } - dbus_error_init(&error); - reply = dbus_connection_send_with_reply_and_block(dbus, - message, -1, - &error); - dbus_message_unref(message); - if (dbus_error_is_set(&error)) { - log_error("Error communicating with D-BUS\n"); - return (NULL); - } - if (reply == NULL) { - return (NULL); - } - dbus_message_iter_init(reply, &reply_iter); - if (dbus_message_iter_get_arg_type(&reply_iter) != DBUS_TYPE_ARRAY) { - log_error("Malformed D-BUS reply"); - return (NULL); - } - dbus_message_iter_recurse(&reply_iter, &iter_array); - devices = pusb_hal_get_string_array_from_iter(&iter_array, &n_devices); - dbus_message_unref(reply); - if (!n_devices) - { - pusb_hal_free_string_array(devices, n_devices); - return (NULL); - } - *count = n_devices; - return (devices); -} - -char *pusb_hal_find_item(DBusConnection *dbus, - ...) -{ - char **devices; - int n_devices; - char *udi = NULL; - va_list ap; - int i; - - devices = pusb_hal_find_all_items(dbus, &n_devices); - if (!devices) - return (NULL); - if (!n_devices) - return (NULL); - - for (i = 0; i < n_devices; ++i) - { - char *key = NULL; - int match = 1; - - va_start(ap, dbus); - while ((key = va_arg(ap, char *))) - { - char *value = NULL; - - value = va_arg(ap, char *); - if (!value || *value == 0x0) - continue ; - if (!pusb_hal_check_property(dbus, devices[i], - key, value)) - { - match = 0; - break; - } - } - if (match) - { - udi = xstrdup(devices[i]); - break; - } - va_end(ap); - } - pusb_hal_free_string_array(devices, n_devices); - return (udi); -} From 5c67b751466edb822b0325d572b708e8e227a20b Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 05:45:01 -0400 Subject: [PATCH 06/27] Delete hal.h in prep for udisks2 merge --- src/hal.h | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/hal.h diff --git a/src/hal.h b/src/hal.h deleted file mode 100644 index 930e91c9..00000000 --- a/src/hal.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003-2007 Andrea Luzzardi - * - * This file is part of the pam_usb project. pam_usb is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * pam_usb 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 PUSB_HAL_H_ -# define PUSB_HAL_H_ -# include - -DBusConnection *pusb_hal_dbus_connect(void); -void pusb_hal_dbus_disconnect(DBusConnection *dbus); -char *pusb_hal_get_string_property(DBusConnection *dbus, const char *udi, const char *name); -int pusb_hal_get_bool_property(DBusConnection *dbus, const char *udi, const char *name, dbus_bool_t *value); -char **pusb_hal_get_string_array_property(DBusConnection *dbus, const char *udi, const char *name, int *n_items); -int pusb_hal_check_property(DBusConnection *dbus, const char *udi, const char *name, const char *value); -char *pusb_hal_find_item(DBusConnection *dbus, ...); -void pusb_hal_free_string_array(char **str_array, int length); - -#endif /* !PUSB_HAL_H_ */ From 0ac18e38a6cfe44c87263e9368977b4e59fb0488 Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 05:46:23 -0400 Subject: [PATCH 07/27] Cleanup device.c --- src/device.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/device.c b/src/device.c index bc4ceabb..c5039164 100644 --- a/src/device.c +++ b/src/device.c @@ -1,7 +1,4 @@ -/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t; -*- */ - /* - * Copyright (c) 2016 Luka Novsak * Copyright (c) 2003-2007 Andrea Luzzardi * * This file is part of the pam_usb project. pam_usb is free software; From 3ec70983ac5a56d66a3ff94acf9b36112b126430 Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 05:47:03 -0400 Subject: [PATCH 08/27] Cleanup pad.c --- src/pad.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pad.c b/src/pad.c index 0ab461fe..3f39717e 100644 --- a/src/pad.c +++ b/src/pad.c @@ -1,7 +1,4 @@ -/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t; -*- */ - /* - * Copyright (c) 2016 Luka Novsak * Copyright (c) 2003-2007 Andrea Luzzardi * * This file is part of the pam_usb project. pam_usb is free software; From d946be588c8d288c760845ab0e80d736634f5878 Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 05:48:03 -0400 Subject: [PATCH 09/27] Cleanup volume.c --- src/volume.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/volume.c b/src/volume.c index 04f32b6d..e1b2bb6a 100644 --- a/src/volume.c +++ b/src/volume.c @@ -1,7 +1,4 @@ -/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t; -*- */ - /* - * Copyright (c) 2016 Luka Novsak * Copyright (c) 2003-2007 Andrea Luzzardi * * This file is part of the pam_usb project. pam_usb is free software; From 3f3e503221fa6faf6154ec36693a0f918d97b68d Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 06:24:17 -0400 Subject: [PATCH 10/27] Update volume.c - more iters with less sleeping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 250000μs to 100000μs --- src/volume.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/volume.c b/src/volume.c index e1b2bb6a..433762a1 100644 --- a/src/volume.c +++ b/src/volume.c @@ -80,7 +80,7 @@ static t_pusb_volume *pusb_volume_probe(t_pusb_options *opts, UDisksClient *udisks) { t_pusb_volume *volume = NULL; - int maxtries = (opts->probe_timeout * 1000000) / 250000; + int maxtries = (opts->probe_timeout * 1000000) / 100000; int i; int j; GList *blocks = NULL; @@ -134,7 +134,7 @@ static t_pusb_volume *pusb_volume_probe(t_pusb_options *opts, break; } - usleep(250000); + usleep(100000); g_main_context_iteration(NULL, FALSE); } From 1053d923e2f4c6999688b3089fb96aba490dc1c7 Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 14:46:34 -0400 Subject: [PATCH 11/27] Cleaning pad.c More cleaning. --- src/pad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pad.c b/src/pad.c index 3f39717e..a712a4f6 100644 --- a/src/pad.c +++ b/src/pad.c @@ -15,8 +15,6 @@ * Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "pad.h" - #include #include #include @@ -31,6 +29,7 @@ #include "conf.h" #include "log.h" #include "volume.h" +#include "pad.h" static FILE *pusb_pad_open_device(t_pusb_options *opts, const char *mnt_point, From a2fe52affa65611d142aba805ac4fa8b18e61359 Mon Sep 17 00:00:00 2001 From: IGP Date: Thu, 6 Oct 2016 14:49:09 -0400 Subject: [PATCH 12/27] Update conf.h Change conf file location to match updated Makefile. --- src/conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf.h b/src/conf.h index e77171e9..4dc64ab5 100644 --- a/src/conf.h +++ b/src/conf.h @@ -17,7 +17,7 @@ #ifndef PUSB_CONF_H_ # define PUSB_CONF_H_ -# define PUSB_CONF_FILE "/etc/pamusb.conf" +# define PUSB_CONF_FILE "/etc/security/pamusb.conf" # define CONF_DEVICE_XPATH "//configuration/devices/device[@id='%s']/%s" # define CONF_USER_XPATH "//configuration/users/user[@id='%s']/%s" # define CONF_SERVICE_XPATH "//configuration/services/service[@id='%s']/%s" From 088252ecd7d55a9d2ea2954ced0b33162e1bcefa Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:05:33 -0400 Subject: [PATCH 13/27] Update Makefile Switching to pam_usb.conf to match other pam module naming schemes. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 44b2952c..e5ace820 100644 --- a/Makefile +++ b/Makefile @@ -41,12 +41,12 @@ PAMUSB_CHECK := pamusb-check # Tools PAMUSB_CONF := pamusb-conf -PAMUSB_AGENT := pamusb-agent +PAMUSB_AGENT := pamusb-agent TOOLS_DEST := $(DESTDIR)$(PREFIX)/bin TOOLS_SRC := tools # Conf -CONFS := doc/pamusb.conf +CONFS := doc/pam_usb.conf CONFS_DEST := $(DESTDIR)/etc/security # Doc From d37d22261950ebd7035b450662bc23f7567e9b4f Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:11:28 -0400 Subject: [PATCH 14/27] Rename pamusb.conf to pam_usb.conf Switching to pam_usb.conf to match other pam module naming schemes. --- doc/{pamusb.conf => pam_usb.conf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/{pamusb.conf => pam_usb.conf} (100%) diff --git a/doc/pamusb.conf b/doc/pam_usb.conf similarity index 100% rename from doc/pamusb.conf rename to doc/pam_usb.conf From 52b610b635cbe99e031b08d972e57b6ce1234a8f Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:13:51 -0400 Subject: [PATCH 15/27] Update pamusb-agent Switching to pam_usb.conf to match other pam module naming schemes. --- tools/pamusb-agent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pamusb-agent b/tools/pamusb-agent index a252a5cd..8dd5027d 100755 --- a/tools/pamusb-agent +++ b/tools/pamusb-agent @@ -123,7 +123,7 @@ try: except getopt.GetoptError: usage() -options = {'configFile' : '/etc/pamusb.conf', +options = {'configFile' : '/etc/security/pam_usb.conf', 'daemon' : False, 'check' : '/usr/bin/pamusb-check'} From 7d1bc156ca8b94833e92a333f340afc898356c23 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:15:07 -0400 Subject: [PATCH 16/27] Update pamusb-conf Switching to pam_usb.conf to match other pam module naming schemes. --- tools/pamusb-conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pamusb-conf b/tools/pamusb-conf index ae2243c2..2e12a8fc 100755 --- a/tools/pamusb-conf +++ b/tools/pamusb-conf @@ -238,7 +238,7 @@ if len(args) != 0: usage() options = { 'deviceName' : None, 'userName' : None, - 'configFile' : '/etc/pamusb.conf', 'verbose' : False } + 'configFile' : '/etc/security/pam_usb.conf', 'verbose' : False } for o, a in opts: if o in ("-h", "--help"): From 15e30544e9d07065352050384c46fb0179374eb9 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:16:10 -0400 Subject: [PATCH 17/27] Update pam_usb.conf Switching to pam_usb.conf to match other pam module naming schemes. --- doc/pam_usb.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/pam_usb.conf b/doc/pam_usb.conf index 0d461320..02a92cdb 100644 --- a/doc/pam_usb.conf +++ b/doc/pam_usb.conf @@ -1,5 +1,5 @@ From 15f358b75869039ce4989769101737e7a02fbc76 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:17:11 -0400 Subject: [PATCH 18/27] Update CONFIGURATION.md Switching to pam_usb.conf to match other pam module naming schemes. --- doc/CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CONFIGURATION.md b/doc/CONFIGURATION.md index 68038a14..0613e0b4 100644 --- a/doc/CONFIGURATION.md +++ b/doc/CONFIGURATION.md @@ -299,7 +299,7 @@ Example: Location of the configuration file ---------------------------------- -By default, pam_usb.so and its tools will look for the configuration file at `/etc/pamusb.conf`. +By default, pam_usb.so and its tools will look for the configuration file at `/etc/security/pam_usb.conf`. If you want to use a different location, you will have to use the `-c` flag. From d23bce6db9936f178a5368ca1dcecffa8fafa01b Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:18:34 -0400 Subject: [PATCH 19/27] Update conf.h Switching to pam_usb.conf to match other pam module naming schemes. --- src/conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf.h b/src/conf.h index 4dc64ab5..22ff161f 100644 --- a/src/conf.h +++ b/src/conf.h @@ -17,7 +17,7 @@ #ifndef PUSB_CONF_H_ # define PUSB_CONF_H_ -# define PUSB_CONF_FILE "/etc/security/pamusb.conf" +# define PUSB_CONF_FILE "/etc/security/pam_usb.conf" # define CONF_DEVICE_XPATH "//configuration/devices/device[@id='%s']/%s" # define CONF_USER_XPATH "//configuration/users/user[@id='%s']/%s" # define CONF_SERVICE_XPATH "//configuration/services/service[@id='%s']/%s" From 0fe1ddb8926a2f61a4976cc9b8bb78edf3aa75e0 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:29:43 -0400 Subject: [PATCH 20/27] Update volume.h conf.h not needed here --- src/volume.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/volume.h b/src/volume.h index 8347b168..b70de7b2 100644 --- a/src/volume.h +++ b/src/volume.h @@ -18,7 +18,6 @@ #ifndef VOLUME_H_ # define VOLUME_H_ # include -# include "conf.h" typedef struct pusb_volume { From 39992883b38a1579b3e53bb323d81c3b8ae08030 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:30:23 -0400 Subject: [PATCH 21/27] Update pad.h conf.h not needed here --- src/pad.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pad.h b/src/pad.h index 5e8988ec..c0140382 100644 --- a/src/pad.h +++ b/src/pad.h @@ -18,7 +18,6 @@ #ifndef PUSB_OTP_H_ # define PUSB_OTP_H_ # include -# include "conf.h" int pusb_pad_check(t_pusb_options *opts, UDisksClient *udisks, const char *user); From c2b72949ced45ceb5cb71bbdf0e5a10631bcae33 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 02:31:19 -0400 Subject: [PATCH 22/27] Update device.h conf.h not needed here --- src/device.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/device.h b/src/device.h index 68ffcc30..793d0a04 100644 --- a/src/device.h +++ b/src/device.h @@ -17,7 +17,6 @@ #ifndef PUSB_DEVICE_H_ # define PUSB_DEVICE_H_ -# include "conf.h" int pusb_device_check(t_pusb_options *opts, const char *user); From 0c7b1b217f2d2f3ebef72fef1eebc86cfb511d8a Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 03:29:48 -0400 Subject: [PATCH 23/27] Rename doc/pam_usb.conf to doc/examples/pam_usb.conf --- doc/{ => examples}/pam_usb.conf | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/{ => examples}/pam_usb.conf (100%) diff --git a/doc/pam_usb.conf b/doc/examples/pam_usb.conf similarity index 100% rename from doc/pam_usb.conf rename to doc/examples/pam_usb.conf From 06b7432c2d0aa2ed105fd0fba8efd4fc279b5b94 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 03:40:49 -0400 Subject: [PATCH 24/27] Create pam_usb.conf Clean .conf, old one moved to examples/pam_usb.conf. --- doc/pam_usb.conf | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 doc/pam_usb.conf diff --git a/doc/pam_usb.conf b/doc/pam_usb.conf new file mode 100644 index 00000000..56a3431e --- /dev/null +++ b/doc/pam_usb.conf @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + From 5433482fc19fcb63f91c713b3033e525fb0d0cc4 Mon Sep 17 00:00:00 2001 From: IGP Date: Fri, 7 Oct 2016 03:59:47 -0400 Subject: [PATCH 25/27] Update Makefile MANS deinstall command was incorrect. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e5ace820..26477474 100644 --- a/Makefile +++ b/Makefile @@ -92,4 +92,4 @@ deinstall : $(RM) -f $(PAM_USB_DEST)/$(PAM_USB) $(RM) -f $(TOOLS_DEST)/$(PAMUSB_CHECK) $(TOOLS_DEST)/$(PAMUSB_CONF) $(TOOLS_DEST)/$(PAMUSB_AGENT) $(RM) -rf $(DOCS_DEST) - $(RM) -f $(MANS_DEST)/pusb_* + $(RM) -f $(MANS_DEST)/pamusb-*\.1\.gz From fea00c8dc5290b59427ccfd1ab60367bac75280e Mon Sep 17 00:00:00 2001 From: Dane Finlay Date: Sun, 26 Feb 2017 14:28:05 +1100 Subject: [PATCH 26/27] Removed extra spaces between function name and '(' in 4 places --- src/device.c | 4 ++-- src/volume.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index c5039164..8a591122 100644 --- a/src/device.c +++ b/src/device.c @@ -63,8 +63,8 @@ static int pusb_device_connected(t_pusb_options *opts, UDisksClient *udisks) log_error("Device \"%s\" is not connected (bad).\n", opts->device.name); - g_list_foreach (objects, (GFunc) g_object_unref, NULL); - g_list_free (objects); + g_list_foreach(objects, (GFunc) g_object_unref, NULL); + g_list_free(objects); return (retval); } diff --git a/src/volume.c b/src/volume.c index 433762a1..49946c12 100644 --- a/src/volume.c +++ b/src/volume.c @@ -125,8 +125,8 @@ static t_pusb_volume *pusb_volume_probe(t_pusb_options *opts, } } - g_list_foreach (blocks, (GFunc) g_object_unref, NULL); - g_list_free (blocks); + g_list_foreach(blocks, (GFunc) g_object_unref, NULL); + g_list_free(blocks); if (volume) { From afae3ebcd89fe5ea62efea2ef9aab66ce93b597e Mon Sep 17 00:00:00 2001 From: Dane Finlay Date: Sun, 26 Feb 2017 15:41:11 +1100 Subject: [PATCH 27/27] Created AUTHORS file --- AUTHORS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..ad43d3d4 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Andrea Luzzardi +Luka Novsak \ No newline at end of file