diff options
author | Imran Zaman <imran.zaman@intel.com> | 2013-06-14 16:30:56 +0300 |
---|---|---|
committer | Imran Zaman <imran.zaman@intel.com> | 2013-06-14 16:30:56 +0300 |
commit | f03389054fb6aa786f9d82b77e7b3113fdbbe345 (patch) | |
tree | fbff5bca740905f1eb2ffd60802a4162415547a4 /src/common | |
parent | 75d5b6ec568d8ae9d54da087d20cfc6b47cf666b (diff) | |
download | gsignond-f03389054fb6aa786f9d82b77e7b3113fdbbe345.tar.gz gsignond-f03389054fb6aa786f9d82b77e7b3113fdbbe345.tar.bz2 gsignond-f03389054fb6aa786f9d82b77e7b3113fdbbe345.zip |
gsignond first release 0.0.1
Diffstat (limited to 'src/common')
37 files changed, 9542 insertions, 0 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am new file mode 100644 index 0000000..38ac909 --- /dev/null +++ b/src/common/Makefile.am @@ -0,0 +1,79 @@ +include $(top_srcdir)/common.mk + +SUBDIRS = db +NULL= + +lib_LTLIBRARIES = libgsignond-common.la + +BUILT_SOURCES = \ + gsignond-plugin-enum-types.h \ + gsignond-plugin-enum-types.c \ + $(NULL) + +GSIGNOND_INCLUDE_DIR=$(top_srcdir)/include/gsignond + +gsignond-plugin-enum-types.h: gsignond-enum.h.template $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h + $(GLIB_MKENUMS) --template gsignond-enum.h.template \ + --fhead "#ifndef GSIGNOND_PLUGIN_ENUM_TYPES_H_\n#define GSIGNOND_PLUGIND_ENUM_TYPES_H_\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS" \ + --identifier-prefix gsignond \ + --ftail "\nG_END_DECLS\n\n#endif\n" \ + $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h > $@ + +gsignond-plugin-enum-types.c: gsignond-enum.c.template $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h + $(GLIB_MKENUMS) --template gsignond-enum.c.template \ + --fhead "#include \"gsignond-plugin-enum-types.h\"\n" \ + --identifier-prefix gsignond \ + $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h > $@ + + +libgsignond_common_la_CPPFLAGS = \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/include \ + $(GSIGNOND_CFLAGS) \ + -DGSIGNOND_PLUGINS_DIR='"$(pluginsdir)"' \ + -DGSIGNOND_EXTENSIONS_DIR='"$(extensionsdir)"' \ + -DGSIGNOND_BIN_DIR='"$(bindir)"' \ + -DGSIGNOND_SYSCONF_DIR='"$(sysconfdir)"' \ + $(NULL) + +libgsignond_common_la_DEPENDENCIES = \ + $(top_builddir)/src/common/db/libgsignond-common-db.la \ + $(NULL) + +libgsignond_common_la_LIBADD = \ + $(GSIGNOND_LIBS) \ + $(top_builddir)/src/common/db/libgsignond-common-db.la \ + $(NULL) + +libgsignond_common_la_SOURCES = \ + gsignond-security-context.c \ + gsignond-access-control-manager.c \ + gsignond-extension-interface.c \ + gsignond-storage-manager.c \ + gsignond-identity-info-internal.h \ + gsignond-identity-info.c \ + gsignond-credentials.c \ + gsignond-config.c \ + gsignond-error.c \ + gsignond-plugin-interface.c \ + gsignond-dictionary.c \ + gsignond-session-data.c \ + gsignond-signonui-data.c \ + gsignond-plugin-loader.h \ + gsignond-plugin-loader.c \ + gsignond-utils.c \ + gsignond-pipe-stream.h \ + gsignond-pipe-stream.c \ + gsignond-disposable.h \ + gsignond-disposable.c \ + $(BUILT_SOURCES) \ + $(NULL) + +dist_libgsignond_common_la_SOURCES = \ + gsignond-enum.c.template \ + gsignond-enum.h.template \ + $(NULL) + +CLEANFILES = + diff --git a/src/common/Makefile.in b/src/common/Makefile.in new file mode 100644 index 0000000..a166acb --- /dev/null +++ b/src/common/Makefile.in @@ -0,0 +1,963 @@ +# Makefile.in generated by automake 1.11.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/common.mk +subdir = src/common +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +am__objects_1 = +am__objects_2 = libgsignond_common_la-gsignond-plugin-enum-types.lo \ + $(am__objects_1) +am_libgsignond_common_la_OBJECTS = \ + libgsignond_common_la-gsignond-security-context.lo \ + libgsignond_common_la-gsignond-access-control-manager.lo \ + libgsignond_common_la-gsignond-extension-interface.lo \ + libgsignond_common_la-gsignond-storage-manager.lo \ + libgsignond_common_la-gsignond-identity-info.lo \ + libgsignond_common_la-gsignond-credentials.lo \ + libgsignond_common_la-gsignond-config.lo \ + libgsignond_common_la-gsignond-error.lo \ + libgsignond_common_la-gsignond-plugin-interface.lo \ + libgsignond_common_la-gsignond-dictionary.lo \ + libgsignond_common_la-gsignond-session-data.lo \ + libgsignond_common_la-gsignond-signonui-data.lo \ + libgsignond_common_la-gsignond-plugin-loader.lo \ + libgsignond_common_la-gsignond-utils.lo \ + libgsignond_common_la-gsignond-pipe-stream.lo \ + libgsignond_common_la-gsignond-disposable.lo $(am__objects_2) \ + $(am__objects_1) +dist_libgsignond_common_la_OBJECTS = $(am__objects_1) +libgsignond_common_la_OBJECTS = $(am_libgsignond_common_la_OBJECTS) \ + $(dist_libgsignond_common_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libgsignond_common_la_SOURCES) \ + $(dist_libgsignond_common_la_SOURCES) +DIST_SOURCES = $(libgsignond_common_la_SOURCES) \ + $(dist_libgsignond_common_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_INTERFACES_DIR = @DBUS_INTERFACES_DIR@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GREP = @GREP@ +GSIGNOND_CFLAGS = @GSIGNOND_CFLAGS@ +GSIGNOND_LIBS = @GSIGNOND_LIBS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTestDBus_CFLAGS = @GTestDBus_CFLAGS@ +GTestDBus_LIBS = @GTestDBus_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBECRYPTFS_CFLAGS = @LIBECRYPTFS_CFLAGS@ +LIBECRYPTFS_LIBS = @LIBECRYPTFS_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSMACK_CFLAGS = @LIBSMACK_CFLAGS@ +LIBSMACK_LIBS = @LIBSMACK_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MESSAGE_BUS_TYPE = @MESSAGE_BUS_TYPE@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +ifGNUmake = @ifGNUmake@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +extensionsdir = $(pkglibdir)/extensions +pluginsdir = $(pkglibdir)/plugins +SUBDIRS = db +NULL = +lib_LTLIBRARIES = libgsignond-common.la +BUILT_SOURCES = \ + gsignond-plugin-enum-types.h \ + gsignond-plugin-enum-types.c \ + $(NULL) + +GSIGNOND_INCLUDE_DIR = $(top_srcdir)/include/gsignond +libgsignond_common_la_CPPFLAGS = \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/include \ + $(GSIGNOND_CFLAGS) \ + -DGSIGNOND_PLUGINS_DIR='"$(pluginsdir)"' \ + -DGSIGNOND_EXTENSIONS_DIR='"$(extensionsdir)"' \ + -DGSIGNOND_BIN_DIR='"$(bindir)"' \ + -DGSIGNOND_SYSCONF_DIR='"$(sysconfdir)"' \ + $(NULL) + +libgsignond_common_la_DEPENDENCIES = \ + $(top_builddir)/src/common/db/libgsignond-common-db.la \ + $(NULL) + +libgsignond_common_la_LIBADD = \ + $(GSIGNOND_LIBS) \ + $(top_builddir)/src/common/db/libgsignond-common-db.la \ + $(NULL) + +libgsignond_common_la_SOURCES = \ + gsignond-security-context.c \ + gsignond-access-control-manager.c \ + gsignond-extension-interface.c \ + gsignond-storage-manager.c \ + gsignond-identity-info-internal.h \ + gsignond-identity-info.c \ + gsignond-credentials.c \ + gsignond-config.c \ + gsignond-error.c \ + gsignond-plugin-interface.c \ + gsignond-dictionary.c \ + gsignond-session-data.c \ + gsignond-signonui-data.c \ + gsignond-plugin-loader.h \ + gsignond-plugin-loader.c \ + gsignond-utils.c \ + gsignond-pipe-stream.h \ + gsignond-pipe-stream.c \ + gsignond-disposable.h \ + gsignond-disposable.c \ + $(BUILT_SOURCES) \ + $(NULL) + +dist_libgsignond_common_la_SOURCES = \ + gsignond-enum.c.template \ + gsignond-enum.h.template \ + $(NULL) + +CLEANFILES = +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/common.mk $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/common/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/common/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; +$(top_srcdir)/common.mk: + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libgsignond-common.la: $(libgsignond_common_la_OBJECTS) $(libgsignond_common_la_DEPENDENCIES) $(EXTRA_libgsignond_common_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) -rpath $(libdir) $(libgsignond_common_la_OBJECTS) $(libgsignond_common_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-access-control-manager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-config.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-credentials.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-dictionary.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-disposable.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-error.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-extension-interface.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-identity-info.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-pipe-stream.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-plugin-enum-types.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-plugin-interface.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-plugin-loader.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-security-context.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-session-data.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-signonui-data.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-storage-manager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_la-gsignond-utils.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libgsignond_common_la-gsignond-security-context.lo: gsignond-security-context.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-security-context.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-security-context.Tpo -c -o libgsignond_common_la-gsignond-security-context.lo `test -f 'gsignond-security-context.c' || echo '$(srcdir)/'`gsignond-security-context.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-security-context.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-security-context.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-security-context.c' object='libgsignond_common_la-gsignond-security-context.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-security-context.lo `test -f 'gsignond-security-context.c' || echo '$(srcdir)/'`gsignond-security-context.c + +libgsignond_common_la-gsignond-access-control-manager.lo: gsignond-access-control-manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-access-control-manager.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-access-control-manager.Tpo -c -o libgsignond_common_la-gsignond-access-control-manager.lo `test -f 'gsignond-access-control-manager.c' || echo '$(srcdir)/'`gsignond-access-control-manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-access-control-manager.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-access-control-manager.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-access-control-manager.c' object='libgsignond_common_la-gsignond-access-control-manager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-access-control-manager.lo `test -f 'gsignond-access-control-manager.c' || echo '$(srcdir)/'`gsignond-access-control-manager.c + +libgsignond_common_la-gsignond-extension-interface.lo: gsignond-extension-interface.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-extension-interface.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-extension-interface.Tpo -c -o libgsignond_common_la-gsignond-extension-interface.lo `test -f 'gsignond-extension-interface.c' || echo '$(srcdir)/'`gsignond-extension-interface.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-extension-interface.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-extension-interface.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-extension-interface.c' object='libgsignond_common_la-gsignond-extension-interface.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-extension-interface.lo `test -f 'gsignond-extension-interface.c' || echo '$(srcdir)/'`gsignond-extension-interface.c + +libgsignond_common_la-gsignond-storage-manager.lo: gsignond-storage-manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-storage-manager.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-storage-manager.Tpo -c -o libgsignond_common_la-gsignond-storage-manager.lo `test -f 'gsignond-storage-manager.c' || echo '$(srcdir)/'`gsignond-storage-manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-storage-manager.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-storage-manager.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-storage-manager.c' object='libgsignond_common_la-gsignond-storage-manager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-storage-manager.lo `test -f 'gsignond-storage-manager.c' || echo '$(srcdir)/'`gsignond-storage-manager.c + +libgsignond_common_la-gsignond-identity-info.lo: gsignond-identity-info.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-identity-info.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-identity-info.Tpo -c -o libgsignond_common_la-gsignond-identity-info.lo `test -f 'gsignond-identity-info.c' || echo '$(srcdir)/'`gsignond-identity-info.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-identity-info.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-identity-info.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-identity-info.c' object='libgsignond_common_la-gsignond-identity-info.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-identity-info.lo `test -f 'gsignond-identity-info.c' || echo '$(srcdir)/'`gsignond-identity-info.c + +libgsignond_common_la-gsignond-credentials.lo: gsignond-credentials.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-credentials.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-credentials.Tpo -c -o libgsignond_common_la-gsignond-credentials.lo `test -f 'gsignond-credentials.c' || echo '$(srcdir)/'`gsignond-credentials.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-credentials.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-credentials.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-credentials.c' object='libgsignond_common_la-gsignond-credentials.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-credentials.lo `test -f 'gsignond-credentials.c' || echo '$(srcdir)/'`gsignond-credentials.c + +libgsignond_common_la-gsignond-config.lo: gsignond-config.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-config.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-config.Tpo -c -o libgsignond_common_la-gsignond-config.lo `test -f 'gsignond-config.c' || echo '$(srcdir)/'`gsignond-config.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-config.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-config.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-config.c' object='libgsignond_common_la-gsignond-config.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-config.lo `test -f 'gsignond-config.c' || echo '$(srcdir)/'`gsignond-config.c + +libgsignond_common_la-gsignond-error.lo: gsignond-error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-error.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-error.Tpo -c -o libgsignond_common_la-gsignond-error.lo `test -f 'gsignond-error.c' || echo '$(srcdir)/'`gsignond-error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-error.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-error.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-error.c' object='libgsignond_common_la-gsignond-error.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-error.lo `test -f 'gsignond-error.c' || echo '$(srcdir)/'`gsignond-error.c + +libgsignond_common_la-gsignond-plugin-interface.lo: gsignond-plugin-interface.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-plugin-interface.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-plugin-interface.Tpo -c -o libgsignond_common_la-gsignond-plugin-interface.lo `test -f 'gsignond-plugin-interface.c' || echo '$(srcdir)/'`gsignond-plugin-interface.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-plugin-interface.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-plugin-interface.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-plugin-interface.c' object='libgsignond_common_la-gsignond-plugin-interface.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-plugin-interface.lo `test -f 'gsignond-plugin-interface.c' || echo '$(srcdir)/'`gsignond-plugin-interface.c + +libgsignond_common_la-gsignond-dictionary.lo: gsignond-dictionary.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-dictionary.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-dictionary.Tpo -c -o libgsignond_common_la-gsignond-dictionary.lo `test -f 'gsignond-dictionary.c' || echo '$(srcdir)/'`gsignond-dictionary.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-dictionary.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-dictionary.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-dictionary.c' object='libgsignond_common_la-gsignond-dictionary.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-dictionary.lo `test -f 'gsignond-dictionary.c' || echo '$(srcdir)/'`gsignond-dictionary.c + +libgsignond_common_la-gsignond-session-data.lo: gsignond-session-data.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-session-data.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-session-data.Tpo -c -o libgsignond_common_la-gsignond-session-data.lo `test -f 'gsignond-session-data.c' || echo '$(srcdir)/'`gsignond-session-data.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-session-data.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-session-data.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-session-data.c' object='libgsignond_common_la-gsignond-session-data.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-session-data.lo `test -f 'gsignond-session-data.c' || echo '$(srcdir)/'`gsignond-session-data.c + +libgsignond_common_la-gsignond-signonui-data.lo: gsignond-signonui-data.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-signonui-data.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-signonui-data.Tpo -c -o libgsignond_common_la-gsignond-signonui-data.lo `test -f 'gsignond-signonui-data.c' || echo '$(srcdir)/'`gsignond-signonui-data.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-signonui-data.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-signonui-data.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-signonui-data.c' object='libgsignond_common_la-gsignond-signonui-data.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-signonui-data.lo `test -f 'gsignond-signonui-data.c' || echo '$(srcdir)/'`gsignond-signonui-data.c + +libgsignond_common_la-gsignond-plugin-loader.lo: gsignond-plugin-loader.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-plugin-loader.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-plugin-loader.Tpo -c -o libgsignond_common_la-gsignond-plugin-loader.lo `test -f 'gsignond-plugin-loader.c' || echo '$(srcdir)/'`gsignond-plugin-loader.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-plugin-loader.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-plugin-loader.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-plugin-loader.c' object='libgsignond_common_la-gsignond-plugin-loader.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-plugin-loader.lo `test -f 'gsignond-plugin-loader.c' || echo '$(srcdir)/'`gsignond-plugin-loader.c + +libgsignond_common_la-gsignond-utils.lo: gsignond-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-utils.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-utils.Tpo -c -o libgsignond_common_la-gsignond-utils.lo `test -f 'gsignond-utils.c' || echo '$(srcdir)/'`gsignond-utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-utils.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-utils.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-utils.c' object='libgsignond_common_la-gsignond-utils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-utils.lo `test -f 'gsignond-utils.c' || echo '$(srcdir)/'`gsignond-utils.c + +libgsignond_common_la-gsignond-pipe-stream.lo: gsignond-pipe-stream.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-pipe-stream.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-pipe-stream.Tpo -c -o libgsignond_common_la-gsignond-pipe-stream.lo `test -f 'gsignond-pipe-stream.c' || echo '$(srcdir)/'`gsignond-pipe-stream.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-pipe-stream.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-pipe-stream.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-pipe-stream.c' object='libgsignond_common_la-gsignond-pipe-stream.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-pipe-stream.lo `test -f 'gsignond-pipe-stream.c' || echo '$(srcdir)/'`gsignond-pipe-stream.c + +libgsignond_common_la-gsignond-disposable.lo: gsignond-disposable.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-disposable.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-disposable.Tpo -c -o libgsignond_common_la-gsignond-disposable.lo `test -f 'gsignond-disposable.c' || echo '$(srcdir)/'`gsignond-disposable.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-disposable.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-disposable.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-disposable.c' object='libgsignond_common_la-gsignond-disposable.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-disposable.lo `test -f 'gsignond-disposable.c' || echo '$(srcdir)/'`gsignond-disposable.c + +libgsignond_common_la-gsignond-plugin-enum-types.lo: gsignond-plugin-enum-types.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_la-gsignond-plugin-enum-types.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_la-gsignond-plugin-enum-types.Tpo -c -o libgsignond_common_la-gsignond-plugin-enum-types.lo `test -f 'gsignond-plugin-enum-types.c' || echo '$(srcdir)/'`gsignond-plugin-enum-types.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_la-gsignond-plugin-enum-types.Tpo $(DEPDIR)/libgsignond_common_la-gsignond-plugin-enum-types.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-plugin-enum-types.c' object='libgsignond_common_la-gsignond-plugin-enum-types.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_la-gsignond-plugin-enum-types.lo `test -f 'gsignond-plugin-enum-types.c' || echo '$(srcdir)/'`gsignond-plugin-enum-types.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive +all-am: Makefile $(LTLIBRARIES) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(libdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-recursive + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ + ctags-recursive install install-am install-strip \ + tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-libLTLIBRARIES + + +gsignond-plugin-enum-types.h: gsignond-enum.h.template $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h + $(GLIB_MKENUMS) --template gsignond-enum.h.template \ + --fhead "#ifndef GSIGNOND_PLUGIN_ENUM_TYPES_H_\n#define GSIGNOND_PLUGIND_ENUM_TYPES_H_\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS" \ + --identifier-prefix gsignond \ + --ftail "\nG_END_DECLS\n\n#endif\n" \ + $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h > $@ + +gsignond-plugin-enum-types.c: gsignond-enum.c.template $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h + $(GLIB_MKENUMS) --template gsignond-enum.c.template \ + --fhead "#include \"gsignond-plugin-enum-types.h\"\n" \ + --identifier-prefix gsignond \ + $(GSIGNOND_INCLUDE_DIR)/gsignond-plugin-interface.h > $@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/common/db/Makefile.am b/src/common/db/Makefile.am new file mode 100644 index 0000000..c132817 --- /dev/null +++ b/src/common/db/Makefile.am @@ -0,0 +1,25 @@ +noinst_LTLIBRARIES = libgsignond-common-db.la +NULL= + +libgsignond_common_db_la_CPPFLAGS = \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/include \ + $(GSIGNOND_CFLAGS) + +libgsignond_common_db_la_LIBS = \ + $(GSIGNOND_LIBS) + +libgsignond_common_db_la_SOURCES = \ + gsignond-db-defines.h \ + gsignond-db-error.h \ + gsignond-db-error.c \ + gsignond-db-sql-database.h \ + gsignond-db-sql-database.c \ + gsignond-db-secret-database.h \ + gsignond-db-secret-database.c \ + gsignond-secret-storage.c \ + gsignond-db-sql-database-private.h \ + $(NULL) + + diff --git a/src/common/db/Makefile.in b/src/common/db/Makefile.in new file mode 100644 index 0000000..fca2c67 --- /dev/null +++ b/src/common/db/Makefile.in @@ -0,0 +1,576 @@ +# Makefile.in generated by automake 1.11.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/common/db +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libgsignond_common_db_la_LIBADD = +am__objects_1 = +am_libgsignond_common_db_la_OBJECTS = \ + libgsignond_common_db_la-gsignond-db-error.lo \ + libgsignond_common_db_la-gsignond-db-sql-database.lo \ + libgsignond_common_db_la-gsignond-db-secret-database.lo \ + libgsignond_common_db_la-gsignond-secret-storage.lo \ + $(am__objects_1) +libgsignond_common_db_la_OBJECTS = \ + $(am_libgsignond_common_db_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libgsignond_common_db_la_SOURCES) +DIST_SOURCES = $(libgsignond_common_db_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_INTERFACES_DIR = @DBUS_INTERFACES_DIR@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GREP = @GREP@ +GSIGNOND_CFLAGS = @GSIGNOND_CFLAGS@ +GSIGNOND_LIBS = @GSIGNOND_LIBS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTestDBus_CFLAGS = @GTestDBus_CFLAGS@ +GTestDBus_LIBS = @GTestDBus_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBECRYPTFS_CFLAGS = @LIBECRYPTFS_CFLAGS@ +LIBECRYPTFS_LIBS = @LIBECRYPTFS_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSMACK_CFLAGS = @LIBSMACK_CFLAGS@ +LIBSMACK_LIBS = @LIBSMACK_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MESSAGE_BUS_TYPE = @MESSAGE_BUS_TYPE@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +ifGNUmake = @ifGNUmake@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LTLIBRARIES = libgsignond-common-db.la +NULL = +libgsignond_common_db_la_CPPFLAGS = \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/include \ + $(GSIGNOND_CFLAGS) + +libgsignond_common_db_la_LIBS = \ + $(GSIGNOND_LIBS) + +libgsignond_common_db_la_SOURCES = \ + gsignond-db-defines.h \ + gsignond-db-error.h \ + gsignond-db-error.c \ + gsignond-db-sql-database.h \ + gsignond-db-sql-database.c \ + gsignond-db-secret-database.h \ + gsignond-db-secret-database.c \ + gsignond-secret-storage.c \ + gsignond-db-sql-database-private.h \ + $(NULL) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/common/db/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/common/db/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libgsignond-common-db.la: $(libgsignond_common_db_la_OBJECTS) $(libgsignond_common_db_la_DEPENDENCIES) $(EXTRA_libgsignond_common_db_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libgsignond_common_db_la_OBJECTS) $(libgsignond_common_db_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_db_la-gsignond-db-error.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_db_la-gsignond-db-secret-database.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_db_la-gsignond-db-sql-database.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsignond_common_db_la-gsignond-secret-storage.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libgsignond_common_db_la-gsignond-db-error.lo: gsignond-db-error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_db_la-gsignond-db-error.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_db_la-gsignond-db-error.Tpo -c -o libgsignond_common_db_la-gsignond-db-error.lo `test -f 'gsignond-db-error.c' || echo '$(srcdir)/'`gsignond-db-error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_db_la-gsignond-db-error.Tpo $(DEPDIR)/libgsignond_common_db_la-gsignond-db-error.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-db-error.c' object='libgsignond_common_db_la-gsignond-db-error.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_db_la-gsignond-db-error.lo `test -f 'gsignond-db-error.c' || echo '$(srcdir)/'`gsignond-db-error.c + +libgsignond_common_db_la-gsignond-db-sql-database.lo: gsignond-db-sql-database.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_db_la-gsignond-db-sql-database.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_db_la-gsignond-db-sql-database.Tpo -c -o libgsignond_common_db_la-gsignond-db-sql-database.lo `test -f 'gsignond-db-sql-database.c' || echo '$(srcdir)/'`gsignond-db-sql-database.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_db_la-gsignond-db-sql-database.Tpo $(DEPDIR)/libgsignond_common_db_la-gsignond-db-sql-database.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-db-sql-database.c' object='libgsignond_common_db_la-gsignond-db-sql-database.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_db_la-gsignond-db-sql-database.lo `test -f 'gsignond-db-sql-database.c' || echo '$(srcdir)/'`gsignond-db-sql-database.c + +libgsignond_common_db_la-gsignond-db-secret-database.lo: gsignond-db-secret-database.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_db_la-gsignond-db-secret-database.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_db_la-gsignond-db-secret-database.Tpo -c -o libgsignond_common_db_la-gsignond-db-secret-database.lo `test -f 'gsignond-db-secret-database.c' || echo '$(srcdir)/'`gsignond-db-secret-database.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_db_la-gsignond-db-secret-database.Tpo $(DEPDIR)/libgsignond_common_db_la-gsignond-db-secret-database.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-db-secret-database.c' object='libgsignond_common_db_la-gsignond-db-secret-database.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_db_la-gsignond-db-secret-database.lo `test -f 'gsignond-db-secret-database.c' || echo '$(srcdir)/'`gsignond-db-secret-database.c + +libgsignond_common_db_la-gsignond-secret-storage.lo: gsignond-secret-storage.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libgsignond_common_db_la-gsignond-secret-storage.lo -MD -MP -MF $(DEPDIR)/libgsignond_common_db_la-gsignond-secret-storage.Tpo -c -o libgsignond_common_db_la-gsignond-secret-storage.lo `test -f 'gsignond-secret-storage.c' || echo '$(srcdir)/'`gsignond-secret-storage.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgsignond_common_db_la-gsignond-secret-storage.Tpo $(DEPDIR)/libgsignond_common_db_la-gsignond-secret-storage.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gsignond-secret-storage.c' object='libgsignond_common_db_la-gsignond-secret-storage.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgsignond_common_db_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libgsignond_common_db_la-gsignond-secret-storage.lo `test -f 'gsignond-secret-storage.c' || echo '$(srcdir)/'`gsignond-secret-storage.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/common/db/gsignond-db-defines.h b/src/common/db/gsignond-db-defines.h new file mode 100644 index 0000000..9403a6d --- /dev/null +++ b/src/common/db/gsignond-db-defines.h @@ -0,0 +1,38 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +/* inclusion guard */ +#ifndef __GSIGNOND_DB_DEFINES_H__ +#define __GSIGNOND_DB_DEFINES_H__ + +#include <glib.h> + +G_BEGIN_DECLS + +#define GSIGNOND_DB_MAX_DATA_STORAGE (4*1024) + +G_END_DECLS + +#endif /* __GSIGNOND_DB_DEFINES_H__ */ diff --git a/src/common/db/gsignond-db-error.c b/src/common/db/gsignond-db-error.c new file mode 100644 index 0000000..20995ed --- /dev/null +++ b/src/common/db/gsignond-db-error.c @@ -0,0 +1,58 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "gsignond-db-error.h" + +#define GSIGNOND_DB_ERROR_DOMAIN_STR "gsignond_db" + +GQuark +gsignond_db_error_quark (void) +{ + static gsize quark = 0; + + if (g_once_init_enter (&quark)) { + GQuark domain = + g_quark_from_static_string (GSIGNOND_DB_ERROR_DOMAIN_STR); + g_assert (sizeof (GQuark) <= sizeof (gsize)); + + g_once_init_leave (&quark, domain); + } + + return (GQuark) quark; +} + +GError * +gsignond_db_create_error ( + GSignondDbError code, + const gchar* msg) +{ + GError *error = NULL; + + error = g_error_new (GSIGNOND_DB_ERROR, + code, + "%s", msg); + return error; +} + diff --git a/src/common/db/gsignond-db-error.h b/src/common/db/gsignond-db-error.h new file mode 100644 index 0000000..13a1b83 --- /dev/null +++ b/src/common/db/gsignond-db-error.h @@ -0,0 +1,59 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +/* inclusion guard */ +#ifndef __GSIGNOND_DB_ERROR_H__ +#define __GSIGNOND_DB_ERROR_H__ + +#include <glib.h> + +G_BEGIN_DECLS + +/** + * GSIGNOND_DB_ERROR: + * + */ +#define GSIGNOND_DB_ERROR (gsignond_db_error_quark()) + +typedef enum { + GSIGNOND_DB_ERROR_NONE, + GSIGNOND_DB_ERROR_NOT_OPEN, /*!< The DB is not open */ + GSIGNOND_DB_ERROR_CONNECTION_FAILURE, /*!< The DB is disconnected */ + GSIGNOND_DB_ERROR_STATEMENT_FAILURE, /*!< The last statement failed */ + GSIGNOND_DB_ERROR_LOCKED, /*!< The DB is busy */ + GSIGNOND_DB_ERROR_UNKNOWN +} GSignondDbError; + +GQuark +gsignond_db_error_quark (void); + +GError * +gsignond_db_create_error ( + GSignondDbError code, + const gchar* msg); + +G_END_DECLS + +#endif /* __GSIGNOND_DB_ERROR_H__ */ diff --git a/src/common/db/gsignond-db-secret-database.c b/src/common/db/gsignond-db-secret-database.c new file mode 100644 index 0000000..51fa0da --- /dev/null +++ b/src/common/db/gsignond-db-secret-database.c @@ -0,0 +1,437 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#include <sqlite3.h> +#include <string.h> + +#include "gsignond/gsignond-log.h" +#include "gsignond-db-error.h" +#include "gsignond-db-defines.h" +#include "gsignond-db-secret-database.h" +#include "gsignond-db-sql-database-private.h" + +#define RETURN_IF_NOT_OPEN(obj, retval) \ + if (gsignond_db_sql_database_is_open ( \ + GSIGNOND_DB_SQL_DATABASE (obj)) == FALSE) { \ + GError* last_error = gsignond_db_create_error( \ + GSIGNOND_DB_ERROR_NOT_OPEN,\ + "DB Not Open"); \ + DBG("SecretDB is not available"); \ + gsignond_db_sql_database_set_last_error( \ + GSIGNOND_DB_SQL_DATABASE (obj), last_error); \ + return retval; \ + } + +#define GSIGNOND_DB_SECRET_DATABASE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ + GSIGNOND_DB_TYPE_SECRET_DATABASE, \ + GSignondDbSecretDatabasePrivate)) + +G_DEFINE_TYPE (GSignondDbSecretDatabase, gsignond_db_secret_database, + GSIGNOND_DB_TYPE_SQL_DATABASE); + +struct _GSignondDbSecretDatabasePrivate +{ +}; + +static gboolean +gsignond_db_secret_database_create (GSignondDbSqlDatabase *obj); + +static gboolean +gsignond_db_secret_database_clear (GSignondDbSqlDatabase *obj); + +static gboolean +_gsignond_db_read_username_password ( + sqlite3_stmt *stmt, + GSignondCredentials *creds) +{ + gsignond_credentials_set_username (creds, + (const gchar *)sqlite3_column_text (stmt, 0)); + + gsignond_credentials_set_password (creds, + (const gchar *)sqlite3_column_text (stmt, 1)); + + return TRUE; +} + +static gboolean +_gsignond_db_read_key_value ( + sqlite3_stmt *stmt, + GSignondDictionary* data) +{ + const gchar *key = NULL; + GVariant *value = NULL; + key = (const gchar *)sqlite3_column_text (stmt, 0); + value = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + (gconstpointer) sqlite3_column_blob(stmt, 1), + (gsize) sqlite3_column_bytes(stmt, 1), sizeof(guchar)); + + gsignond_dictionary_set (data, key, value); + return TRUE; +} + + +static void +_gsignond_db_secret_database_finalize (GObject *gobject) +{ + /* Chain up to the parent class */ + G_OBJECT_CLASS (gsignond_db_secret_database_parent_class)->finalize ( + gobject); +} + +static void +gsignond_db_secret_database_class_init (GSignondDbSecretDatabaseClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->finalize = _gsignond_db_secret_database_finalize; + + GSignondDbSqlDatabaseClass *sql_class = + GSIGNOND_DB_SQL_DATABASE_CLASS (klass); + + sql_class->create = gsignond_db_secret_database_create; + sql_class->clear = gsignond_db_secret_database_clear; + +} + +static void +gsignond_db_secret_database_init (GSignondDbSecretDatabase *self) +{ + /*self->priv = GSIGNOND_DB_SECRET_DATABASE_GET_PRIVATE (self);*/ +} + +/** + * gsignond_db_secret_database_new: + * + * Creates new #GSignondDbSecretDatabase object + * Returns : (transfer full) the #GSignondDbSecretDatabase object + * + */ +GSignondDbSecretDatabase * +gsignond_db_secret_database_new () +{ + return GSIGNOND_DB_SECRET_DATABASE ( + g_object_new (GSIGNOND_DB_TYPE_SECRET_DATABASE, + NULL)); +} + +static gboolean +gsignond_db_secret_database_create (GSignondDbSqlDatabase *obj) +{ + const gchar *queries = NULL; + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (obj), FALSE); + RETURN_IF_NOT_OPEN (GSIGNOND_DB_SECRET_DATABASE (obj), FALSE); + + if (gsignond_db_sql_database_get_db_version(obj, + "PRAGMA user_version;") > 0) { + DBG ("DB is already created"); + return TRUE; + } + + queries = "" + "CREATE TABLE IF NOT EXISTS CREDENTIALS" + "(id INTEGER NOT NULL UNIQUE," + "username TEXT," + "password TEXT," + "PRIMARY KEY (id));" + + "CREATE TABLE IF NOT EXISTS STORE" + "(identity_id INTEGER," + "method_id INTEGER," + "key TEXT," + "value BLOB," + "PRIMARY KEY (identity_id, method_id, key));" + + "CREATE TRIGGER IF NOT EXISTS tg_delete_credentials " + "BEFORE DELETE ON CREDENTIALS " + "FOR EACH ROW BEGIN " + " DELETE FROM STORE WHERE STORE.identity_id = OLD.id; " + "END; " + + "PRAGMA user_version = 1;"; + + return gsignond_db_sql_database_transaction_exec (obj, queries); +} + +static gboolean +gsignond_db_secret_database_clear (GSignondDbSqlDatabase *obj) +{ + const gchar *queries = NULL; + + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (obj), FALSE); + RETURN_IF_NOT_OPEN (GSIGNOND_DB_SECRET_DATABASE (obj), FALSE); + + queries = "" + "DELETE FROM CREDENTIALS;" + "DELETE FROM STORE;"; + + return gsignond_db_sql_database_transaction_exec (obj, queries); +} + +GSignondCredentials* +gsignond_db_secret_database_load_credentials ( + GSignondDbSecretDatabase *self, + const guint32 id) +{ + gchar *query = NULL; + gint rows = 0; + GSignondCredentials *creds = NULL; + + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (self), NULL); + RETURN_IF_NOT_OPEN (self, NULL); + + creds = gsignond_credentials_new (); + query = sqlite3_mprintf ("SELECT username, password FROM credentials " + "WHERE id = %u limit 1", + id); + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback) + _gsignond_db_read_username_password, + creds); + sqlite3_free (query); + + if (G_UNLIKELY (rows <= 0)) { + DBG ("Load credentials from DB failed"); + g_object_unref (creds); + creds = NULL; + } else { + gsignond_credentials_set_id (creds, id); + } + return creds; +} + +gboolean +gsignond_db_secret_database_update_credentials ( + GSignondDbSecretDatabase *self, + GSignondCredentials *creds) +{ + gchar *query = NULL; + gboolean ret = FALSE; + guint32 id = 0; + const gchar *username = NULL; + const gchar *password = NULL; + + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (self), FALSE); + RETURN_IF_NOT_OPEN (self, FALSE); + + id = gsignond_credentials_get_id (creds); + username = gsignond_credentials_get_username (creds); + password = gsignond_credentials_get_password (creds); + query = sqlite3_mprintf ("INSERT OR REPLACE INTO CREDENTIALS " + "(id, username, password) " + "VALUES (%u, %Q, %Q);", + id, username ? username : "", + password ? password : ""); + ret = gsignond_db_sql_database_transaction_exec ( + GSIGNOND_DB_SQL_DATABASE (self), query); + sqlite3_free (query); + + return ret; +} + +gboolean +gsignond_db_secret_database_remove_credentials ( + GSignondDbSecretDatabase *self, + const guint32 id) +{ + gchar *query = NULL; + gboolean ret = FALSE; + + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (self), FALSE); + RETURN_IF_NOT_OPEN (self, FALSE); + + query = sqlite3_mprintf ("DELETE FROM CREDENTIALS WHERE id = %u;" + "DELETE FROM STORE WHERE identity_id = %u;", + id, id); + ret = gsignond_db_sql_database_transaction_exec ( + GSIGNOND_DB_SQL_DATABASE (self), query); + sqlite3_free (query); + return ret; +} + +GSignondDictionary * +gsignond_db_secret_database_load_data ( + GSignondDbSecretDatabase *self, + const guint32 id, + const guint32 method) +{ + gchar *query = NULL; + gint rows = 0; + GSignondDictionary *data = NULL; + + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (self), NULL); + RETURN_IF_NOT_OPEN (self, NULL); + + data = gsignond_dictionary_new (); + + query = sqlite3_mprintf ( + "SELECT key, value " + "FROM STORE WHERE identity_id = %u AND method_id = %u", + id, method); + + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback)_gsignond_db_read_key_value, + data); + + sqlite3_free (query); + + if (G_UNLIKELY (rows <= 0)) { + DBG ("Load data from DB failed"); + gsignond_dictionary_unref (data); + data = NULL; + } + + return data; +} + +gboolean +gsignond_db_secret_database_update_data ( + GSignondDbSecretDatabase *self, + const guint32 id, + const guint32 method, + GSignondDictionary *data) +{ + gchar *query = NULL; + gint ret = 0; + GHashTableIter iter; + gchar *key = NULL; + GVariant *value = NULL; + guint32 data_counter = 0; + GSignondDbSqlDatabase *parent = NULL; + + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (self), FALSE); + RETURN_IF_NOT_OPEN (self, FALSE); + g_return_val_if_fail (data != NULL, FALSE); + + parent = GSIGNOND_DB_SQL_DATABASE (self); + if (!gsignond_db_sql_database_start_transaction (parent)) { + DBG ("Start DB transaction Failed"); + return FALSE; + } + + /* First, remove existing data */ + query = sqlite3_mprintf ( + "DELETE FROM STORE WHERE identity_id = %u ", + "AND method_id = %u;", + id, method); + ret = sqlite3_exec (parent->priv->db, query, NULL, NULL, NULL); + sqlite3_free (query); + if (G_UNLIKELY (ret != SQLITE_OK)) { + DBG ("Delete old data from DB Failed"); + gsignond_db_sql_database_update_error_from_db (parent); + gsignond_db_sql_database_rollback_transaction (parent); + return FALSE; + } + + /* Check if the size requirement is met before running any queries */ + g_hash_table_iter_init (&iter, data); + while (g_hash_table_iter_next (&iter,(gpointer *) &key, + (gpointer *) &value)) { + data_counter = data_counter + strlen (key) + g_variant_get_size(value); + if (data_counter >= GSIGNOND_DB_MAX_DATA_STORAGE) { + gsignond_db_sql_database_rollback_transaction (parent); + DBG ("size limit is exceeded"); + return FALSE; + } + } + + /* Insert data to db */ + const char* statement = "INSERT OR REPLACE INTO STORE " + "(identity_id, method_id, key, value) " + "VALUES(?, ?, ?, ?)"; + g_hash_table_iter_init (&iter, data); + while (g_hash_table_iter_next (&iter, (gpointer *)&key, + (gpointer *) &value )) { + gsize val_size; + gconstpointer value_data; + sqlite3_stmt *sql_stmt; + + ret = sqlite3_prepare_v2 (parent->priv->db, statement, -1, + &sql_stmt, NULL); + if (G_UNLIKELY (ret != SQLITE_OK)) { + DBG ("Data Insertion to DB Failed"); + gsignond_db_sql_database_update_error_from_db (parent); + gsignond_db_sql_database_rollback_transaction (parent); + return FALSE; + } + value_data = g_variant_get_data (value); + val_size = g_variant_get_size (value); + + sqlite3_bind_int(sql_stmt, 1, (int)id); + sqlite3_bind_int(sql_stmt, 2, (int)method); + sqlite3_bind_text(sql_stmt, 3, key, -1, SQLITE_STATIC); + sqlite3_bind_blob(sql_stmt, 4, value_data, (int)val_size, SQLITE_STATIC); + + ret = sqlite3_step (sql_stmt); + if (G_UNLIKELY (ret != SQLITE_DONE)) { + DBG ("Data Insertion to DB Failed"); + gsignond_db_sql_database_update_error_from_db (parent); + gsignond_db_sql_database_rollback_transaction (parent); + return FALSE; + } + + ret = sqlite3_finalize (sql_stmt); + if (G_UNLIKELY (ret != SQLITE_OK)) { + DBG ("Data Insertion to DB Failed"); + gsignond_db_sql_database_update_error_from_db (parent); + gsignond_db_sql_database_rollback_transaction (parent); + return FALSE; + } + } + + return gsignond_db_sql_database_commit_transaction (parent); +} + +gboolean +gsignond_db_secret_database_remove_data ( + GSignondDbSecretDatabase *self, + const guint32 id, + const guint32 method) +{ + gchar *statement = NULL; + gboolean ret = FALSE; + + g_return_val_if_fail (GSIGNOND_DB_IS_SECRET_DATABASE (self), FALSE); + RETURN_IF_NOT_OPEN (self, FALSE); + + if (method == 0) { + DBG ("Delete data from DB based on identity id only as method id is 0"); + statement = sqlite3_mprintf ( + "DELETE FROM STORE WHERE identity_id = %u;", + id); + } else { + statement = sqlite3_mprintf ( + "DELETE FROM STORE WHERE identity_id = %u ", + "AND method_id = %u;", + id, method); + } + ret = gsignond_db_sql_database_transaction_exec ( + GSIGNOND_DB_SQL_DATABASE (self), statement); + sqlite3_free (statement); + + return ret; +} + diff --git a/src/common/db/gsignond-db-secret-database.h b/src/common/db/gsignond-db-secret-database.h new file mode 100644 index 0000000..2c9fdad --- /dev/null +++ b/src/common/db/gsignond-db-secret-database.h @@ -0,0 +1,118 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef __GSIGNOND_DB_SECRET_DATABASE_H__ +#define __GSIGNOND_DB_SECRET_DATABASE_H__ + +#include <glib.h> +#include <glib-object.h> +#include <gsignond/gsignond-credentials.h> +#include <gsignond/gsignond-dictionary.h> + +#include "gsignond-db-sql-database.h" + +G_BEGIN_DECLS + +/* + * Type macros. + */ +#define GSIGNOND_DB_TYPE_SECRET_DATABASE \ + (gsignond_db_secret_database_get_type ()) +#define GSIGNOND_DB_SECRET_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + GSIGNOND_DB_TYPE_SECRET_DATABASE, \ + GSignondDbSecretDatabase)) +#define GSIGNOND_DB_IS_SECRET_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ + GSIGNOND_DB_TYPE_SECRET_DATABASE)) +#define GSIGNOND_DB_SECRET_DATABASE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + GSIGNOND_DB_TYPE_SECRET_DATABASE, \ + GSignondDbSecretDatabaseClass)) +#define GSIGNOND_DB_IS_SECRET_DATABASE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + GSIGNOND_DB_TYPE_SECRET_DATABASE)) +#define GSIGNOND_DB_SECRET_DATABASE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + GSIGNOND_DB_TYPE_SECRET_DATABASE, \ + GSignondDbSecretDatabaseClass)) + +typedef struct _GSignondDbSecretDatabasePrivate GSignondDbSecretDatabasePrivate; + +typedef struct +{ + GSignondDbSqlDatabase parent_instance; + + /*< private >*/ + GSignondDbSecretDatabasePrivate *priv; +} GSignondDbSecretDatabase; + +typedef struct { + GSignondDbSqlDatabaseClass parent_class; + +} GSignondDbSecretDatabaseClass; + +/* used by GSIGNOND_DB_TYPE_SECRET_DATABASE */ +GType +gsignond_db_secret_database_get_type (void); + +GSignondDbSecretDatabase * +gsignond_db_secret_database_new (void); + +GSignondCredentials * +gsignond_db_secret_database_load_credentials ( + GSignondDbSecretDatabase *self, + const guint32 id); + +gboolean +gsignond_db_secret_database_update_credentials ( + GSignondDbSecretDatabase *self, + GSignondCredentials *creds); + +gboolean +gsignond_db_secret_database_remove_credentials ( + GSignondDbSecretDatabase *self, + const guint32 id); + +GSignondDictionary * +gsignond_db_secret_database_load_data ( + GSignondDbSecretDatabase *self, + const guint32 id, + const guint32 method); + +gboolean +gsignond_db_secret_database_update_data ( + GSignondDbSecretDatabase *self, + const guint32 id, + const guint32 method, + GSignondDictionary *data); + +gboolean +gsignond_db_secret_database_remove_data ( + GSignondDbSecretDatabase *self, + const guint32 id, + const guint32 method); + +G_END_DECLS + +#endif /* __GSIGNOND_DB_SECRET_DATABASE_H__ */ diff --git a/src/common/db/gsignond-db-sql-database-private.h b/src/common/db/gsignond-db-sql-database-private.h new file mode 100644 index 0000000..a794c97 --- /dev/null +++ b/src/common/db/gsignond-db-sql-database-private.h @@ -0,0 +1,53 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef __GSIGNOND_DB_SQL_DATABASE_PRIVATE_H__ +#define __GSIGNOND_DB_SQL_DATABASE_PRIVATE_H__ + +#include <glib.h> +#include <sqlite3.h> + +G_BEGIN_DECLS + +struct _GSignondDbSqlDatabasePrivate +{ + sqlite3 *db; + gint db_version; + sqlite3_stmt *begin_statement; + sqlite3_stmt *commit_statement; + sqlite3_stmt *rollback_statement; + GError *last_error; +}; + +void +gsignond_db_sql_database_update_error_from_db (GSignondDbSqlDatabase *self); + +int +gsignond_db_sql_database_prepare_transaction_statements ( + GSignondDbSqlDatabase *self); + +G_END_DECLS + +#endif /* __GSIGNOND_DB_SQL_DATABASE_PRIVATE_H__ */ diff --git a/src/common/db/gsignond-db-sql-database.c b/src/common/db/gsignond-db-sql-database.c new file mode 100644 index 0000000..caddd98 --- /dev/null +++ b/src/common/db/gsignond-db-sql-database.c @@ -0,0 +1,1015 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <sys/stat.h> + +#include <glib/gstdio.h> + +#include "gsignond/gsignond-log.h" +#include "gsignond-db-error.h" +#include "gsignond-db-sql-database.h" +#include "gsignond-db-sql-database-private.h" +#include "config.h" + +#define GSIGNOND_DB_SQL_DATABASE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ + GSIGNOND_DB_TYPE_SQL_DATABASE, \ + GSignondDbSqlDatabasePrivate)) + +G_DEFINE_TYPE (GSignondDbSqlDatabase, gsignond_db_sql_database, G_TYPE_OBJECT); + + +static void +_gsignond_db_sql_database_finalize_db (GSignondDbSqlDatabase *self) +{ + if (self->priv->begin_statement) { + sqlite3_finalize (self->priv->begin_statement); + self->priv->begin_statement = NULL; + } + + if (self->priv->commit_statement) { + sqlite3_finalize (self->priv->commit_statement); + self->priv->commit_statement = NULL; + } + + if (self->priv->rollback_statement) { + sqlite3_finalize (self->priv->rollback_statement); + self->priv->rollback_statement = NULL; + } +} + +gboolean +_gsignond_db_sql_database_is_open (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + return self->priv->db != NULL; +} + +#ifdef ENABLE_SQL_LOG +void trace_callback (void *s, const char *stmt) +{ + if (stmt) { + DBG ("SQLITE TRACE: %s", stmt); + } +} +#endif + +gboolean +_gsignond_db_sql_database_open ( + GSignondDbSqlDatabase *self, + const gchar *filename, + int flags) +{ + int ret; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + + if (_gsignond_db_sql_database_is_open (self)) { + return TRUE; + } + + ret = sqlite3_open_v2 (filename, &self->priv->db, flags, NULL); + if (ret != SQLITE_OK) { + if (self->priv->db) { + DBG ("Cannot open %s DB: %s", filename, + sqlite3_errmsg (self->priv->db)); + } + gsignond_db_sql_database_update_error_from_db(self); + GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->close (self); + return FALSE; + } + if (flags & SQLITE_OPEN_CREATE) { + if (g_chmod (filename, S_IRUSR | S_IWUSR)) + WARN ("setting file permissions on %s failed", filename); + } + +#ifdef ENABLE_SQL_LOG + sqlite3_trace (self->priv->db, trace_callback, NULL); +#endif + + if (!GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->create (self)) { + GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->close (self); + return FALSE; + } + return TRUE; +} + +gboolean +_gsignond_db_sql_database_close (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + g_return_val_if_fail (self->priv->db != NULL, FALSE); + + _gsignond_db_sql_database_finalize_db (self); + + if (sqlite3_close (self->priv->db) != SQLITE_OK) { + DBG ("Unable to close db: %s", sqlite3_errmsg (self->priv->db)); + gsignond_db_sql_database_update_error_from_db(self); + } + self->priv->db = NULL; + self->priv->db_version = 0; + + return TRUE; +} + +static int +_prepare_transaction_statement ( + GSignondDbSqlDatabase *self, + sqlite3_stmt **sql_stmt, + const gchar *statement) +{ + int ret = SQLITE_OK; + + if (G_UNLIKELY (!*sql_stmt)) { + ret = sqlite3_prepare_v2 (self->priv->db, statement, -1, + sql_stmt, NULL); + } else { + sqlite3_reset (*sql_stmt); + } + + return ret; +} + +static void +_gsignond_db_sql_database_finalize (GObject *gobject) +{ + GSignondDbSqlDatabase *self = GSIGNOND_DB_SQL_DATABASE (gobject); + + _gsignond_db_sql_database_finalize_db (self); + + if (self->priv->db) { + sqlite3_close (self->priv->db); + self->priv->db = NULL; + } + + if (self->priv->last_error) { + g_error_free (self->priv->last_error); + self->priv->last_error = NULL; + } + + /* Chain up to the parent class */ + G_OBJECT_CLASS (gsignond_db_sql_database_parent_class)->finalize (gobject); +} + +static void +gsignond_db_sql_database_class_init (GSignondDbSqlDatabaseClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->finalize = _gsignond_db_sql_database_finalize; + + /* pure virtual methods */ + klass->create = NULL; + klass->clear = NULL; + + /* virtual methods */ + klass->open = _gsignond_db_sql_database_open; + klass->close = _gsignond_db_sql_database_close; + klass->is_open = _gsignond_db_sql_database_is_open; + + g_type_class_add_private (klass, sizeof (GSignondDbSqlDatabasePrivate)); +} + +static void +gsignond_db_sql_database_init (GSignondDbSqlDatabase *self) +{ + self->priv = GSIGNOND_DB_SQL_DATABASE_GET_PRIVATE (self); + self->priv->last_error = NULL; + self->priv->db = NULL; + self->priv->db_version = 0; +} + +void +gsignond_db_sql_database_update_error_from_db (GSignondDbSqlDatabase *self) +{ + GSignondDbError code; + GError *error; + int sql_code; + + g_return_if_fail (self->priv != NULL); + + sql_code = sqlite3_errcode (self->priv->db); + + switch (sql_code) + { + case SQLITE_OK: + case SQLITE_DONE: + gsignond_db_sql_database_set_last_error (self, NULL); + return; + case SQLITE_BUSY: + code = GSIGNOND_DB_ERROR_LOCKED; + break; + default: + code = GSIGNOND_DB_ERROR_UNKNOWN; + break; + } + + error = g_error_new (GSIGNOND_DB_ERROR, + code, + "Database (SQLite) error %d: %s", + sqlite3_errcode (self->priv->db), + sqlite3_errmsg (self->priv->db)); + gsignond_db_sql_database_set_last_error (self, error); +} + +int +gsignond_db_sql_database_prepare_transaction_statements ( + GSignondDbSqlDatabase *self) +{ + int ret; + + g_return_val_if_fail (self->priv != NULL, FALSE); + + ret = _prepare_transaction_statement(self, &(self->priv->begin_statement), + "BEGIN EXCLUSIVE;"); + if (ret != SQLITE_OK) return ret; + + ret = _prepare_transaction_statement(self, &(self->priv->commit_statement), + "COMMIT;"); + if (ret != SQLITE_OK) return ret; + + ret = _prepare_transaction_statement(self,&(self->priv->rollback_statement), + "ROLLBACK;"); + + return ret; +} + +/** + * gsignond_db_sql_database_open: + * + * @self: instance of #GSignondDbSqlDatabase + * @filename: db filename + * @flags: sqlite3_open_v2 flags for opening db + * + * Opens a connection to DB. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_open ( + GSignondDbSqlDatabase *self, + const gchar *filename, + int flags) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + + return GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->open ( + self, filename, flags); +} + +/** + * gsignond_db_sql_database_close: + * + * @self: instance of #GSignondDbSqlDatabase + * + * Closes the connection to DB if it is opened already. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_close (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + + return GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->close (self); +} + +/** + * gsignond_db_sql_database_is_open: + * + * @self: instance of #GSignondDbSqlDatabase + * + * Retrieves the connectivity status to database if it is open or not. + * + * Returns: TRUE if there exist a valid connection to database, + * FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_is_open (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + + return GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->is_open (self); +} + +/** + * gsignond_db_sql_database_create: + * + * @self: instance of #GSignondDbSqlDatabase + * + * Creates database structure/tables if does not already exist. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_create (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + + return GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->create (self); +} + +/** + * gsignond_db_sql_database_clear: + * + * @self: instance of #GSignondDbSqlDatabase + * + * Clear database data as per needed. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_clear (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + + return GSIGNOND_DB_SQL_DATABASE_GET_CLASS (self)->clear (self); +} + +/** + * gsignond_db_sql_database_prepare_statement: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be prepared + * + * Prepares the statement from the query. + * + * Returns: (transfer full) NULL if fails, valid sql statement otherwise. + */ +sqlite3_stmt * +gsignond_db_sql_database_prepare_statement ( + GSignondDbSqlDatabase *self, + const gchar *query) +{ + int ret; + sqlite3_stmt *sql_stmt = NULL; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + ret = sqlite3_prepare_v2 (self->priv->db, query, -1, &sql_stmt, NULL); + if (ret != SQLITE_OK) { + DBG ("statement preparation failed for \"%s\": %s", + query, sqlite3_errmsg (self->priv->db)); + return NULL; + } + + return sql_stmt; +} + +/** + * gsignond_db_sql_database_exec: + * @self: instance of #GSignondDbSqlDatabase + * @stmts: sql statements to be executed on the database + * + * Executes SQL statements. transaction begin and commit statements should be + * explicitly called if needed. + * + * Returns: TRUE if the sql statements executes successfully, + * FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_exec ( + GSignondDbSqlDatabase *self, + const gchar *statements) +{ + int ret; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + g_return_val_if_fail (self->priv->db != NULL, FALSE); + g_return_val_if_fail (statements != NULL, FALSE); + + /* exec statements */ + ret = sqlite3_exec (self->priv->db, statements, NULL, NULL, NULL); + if (G_UNLIKELY (ret != SQLITE_OK)) { + gsignond_db_sql_database_update_error_from_db (self); + return FALSE; + } + + return TRUE; +} + +/** + * gsignond_db_sql_database_query_exec: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be executed on the database + * @callback: callback to be invoked if not NULL for the result of each row + * @userdata: user_data to be relayed back through the callback + * + * Executes an SQL statement, and optionally calls + * the callback for every row of the result. + * Returns the number of rows fetched. + * + * Returns: 0 if no row is fetched, number of rows fetched otherwise. + */ +gint +gsignond_db_sql_database_query_exec ( + GSignondDbSqlDatabase *self, + const gchar *query, + GSignondDbSqlDatabaseQueryCallback callback, + gpointer userdata) +{ + sqlite3_stmt *sql_stmt; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + sql_stmt = gsignond_db_sql_database_prepare_statement(self, query); + if (sql_stmt) { + rows = gsignond_db_sql_database_query_exec_stmt(self, sql_stmt, + callback, userdata); + } + + return rows; +} + +static gboolean +_gsignond_db_read_string ( + sqlite3_stmt *stmt, + gchar **string) +{ + *string = g_strdup ((const gchar *)sqlite3_column_text (stmt, 0)); + return TRUE; +} + +/** + * gsignond_db_sql_database_query_exec_string: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be executed on the database + * + * Executes an SQL statement, and returns the fetched integer from the result. + * + * Returns: (transfer full) string if rows fetched are greater than 0, + * NULL otherwise. + */ +gchar * +gsignond_db_sql_database_query_exec_string ( + GSignondDbSqlDatabase *self, + const gchar *query) +{ + gchar *str = NULL; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback) + _gsignond_db_read_string, + &str); + + if (G_UNLIKELY (rows <= 0)) { + g_free (str); + str = NULL; + } + return str; +} + +static gboolean +_gsignond_db_read_strings ( + sqlite3_stmt *stmt, + GList** strings) +{ + *strings = g_list_append (*strings, + g_strdup ((const gchar *)sqlite3_column_text (stmt, 0))); + return TRUE; +} + +/** + * gsignond_db_sql_database_query_exec_string_list: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be executed on the database + * + * Executes an SQL statement, and returns the fetched strings from the results + * in the list. + * + * Returns: (transfer full) list if rows fetched are greater than 0, + * NULL otherwise. When done with list, it must be freed using + * g_list_free_full (list, g_free) + */ +GList * +gsignond_db_sql_database_query_exec_string_list ( + GSignondDbSqlDatabase *self, + const gchar *query) +{ + GList *list = NULL; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback) + _gsignond_db_read_strings, + &list); + + if (G_UNLIKELY (rows <= 0)) { + g_list_free_full (list, g_free); + list = NULL; + } + return list; +} + +static gboolean +_gsignond_db_read_string_tuple ( + sqlite3_stmt *stmt, + GHashTable *tuples) +{ + g_hash_table_insert(tuples, + g_strdup ((const gchar *)sqlite3_column_text (stmt, 0)), + g_strdup ((const gchar *)sqlite3_column_text (stmt, 1))); + return TRUE; +} + +/** + * gsignond_db_sql_database_query_exec_string_tuple: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be executed on the database + * + * Executes an SQL statement, and returns the fetched string tuples from + * the results into the hash table. + * + * Returns: (transfer full) string tuples if rows fetched are greater than 0, + * NULL otherwise. When done with tuples, it must be freed using + * g_hash_table_unref (tuples) + */ +GHashTable * +gsignond_db_sql_database_query_exec_string_tuple ( + GSignondDbSqlDatabase *self, + const gchar *query) +{ + GHashTable *tuples = NULL; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + tuples = g_hash_table_new_full ((GHashFunc)g_str_hash, + (GEqualFunc)g_str_equal, + (GDestroyNotify)g_free, + (GDestroyNotify)g_free); + + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback) + _gsignond_db_read_string_tuple, + tuples); + + if (G_UNLIKELY (rows <= 0)) { + g_hash_table_destroy (tuples); + tuples = NULL; + } + return tuples; +} + +static gboolean +_gsignond_db_read_int_string_tuple ( + sqlite3_stmt *stmt, + GHashTable *tuples) +{ + gint id; + const gchar *method = NULL; + + id = sqlite3_column_int (stmt, 0); + method = (const gchar *)sqlite3_column_text (stmt, 1); + g_hash_table_insert(tuples, GINT_TO_POINTER(id), g_strdup (method)); + return TRUE; +} + +/** + * gsignond_db_sql_database_query_exec_int_string_tuple: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be executed on the database + * + * Executes an SQL statement, and returns the fetched int-string tuples from + * the results into the hash table. + * + * Returns: (transfer full) string tuples if rows fetched are greater than 0, + * NULL otherwise. + */ +GHashTable * +gsignond_db_sql_database_query_exec_int_string_tuple ( + GSignondDbSqlDatabase *self, + const gchar *query) +{ + GHashTable *tuples = NULL; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + tuples = g_hash_table_new_full ((GHashFunc)g_direct_hash, + (GEqualFunc)g_direct_equal, + (GDestroyNotify)NULL, + (GDestroyNotify)g_free); + + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback) + _gsignond_db_read_int_string_tuple, + tuples); + + if (G_UNLIKELY (rows <= 0)) { + g_hash_table_destroy (tuples); + tuples = NULL; + } + return tuples; +} + +static gboolean +_gsignond_db_read_int ( + sqlite3_stmt *stmt, + gint *data) +{ + *data = sqlite3_column_int (stmt, 0); + return TRUE; +} + +/** + * gsignond_db_sql_database_query_exec_int: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be executed on the database + * + * Executes an SQL statement, and returns the fetched integer from the result. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_query_exec_int ( + GSignondDbSqlDatabase *self, + const gchar *query, + gint *result) +{ + gint data; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback) + _gsignond_db_read_int, + &data); + if (G_UNLIKELY (rows <= 0)) { + return FALSE; + } + *result = data; + return TRUE; +} + +static gboolean +_gsignond_db_read_array ( + sqlite3_stmt *stmt, + GArray *array) +{ + int item = 0; + item = sqlite3_column_int (stmt, 0); + g_array_append_val (array, item); + return TRUE; +} + +/** + * gsignond_db_sql_database_query_exec_int_array: + * @self: instance of #GSignondDbSqlDatabase + * @query: query to be executed on the database + * + * Executes an SQL statement, and returns the fetched integers from the results + * in the array. + * + * Returns: (transfer full) list if rows fetched are greater than 0, NULL otherwise. + */ +GArray * +gsignond_db_sql_database_query_exec_int_array ( + GSignondDbSqlDatabase *self, + const gchar *query) +{ + GArray *array = NULL; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + array = g_array_new (FALSE, FALSE, sizeof(gint)); + rows = gsignond_db_sql_database_query_exec (GSIGNOND_DB_SQL_DATABASE (self), + query, + (GSignondDbSqlDatabaseQueryCallback) + _gsignond_db_read_array, + array); + + if (G_UNLIKELY (rows <= 0)) { + g_array_free (array, TRUE); + array = NULL; + } + return array; +} + +/** + * gsignond_db_sql_database_query_exec_stmt: + * @self: instance of #GSignondDbSqlDatabase + * @sql_stmt: (transfer full) sql statement executed on the database + * @callback: callback to be invoked if not NULL for the result of each row + * @userdata: user_data to be relayed back through the callback + * + * Executes an SQL statement, and optionally calls + * the callback for every row of the result. + * Returns the number of rows fetched. + * + * Returns: 0 if no row is fetched, number of rows fetched otherwise. + */ +gint +gsignond_db_sql_database_query_exec_stmt ( + GSignondDbSqlDatabase *self, + sqlite3_stmt *sql_stmt, + GSignondDbSqlDatabaseQueryCallback callback, + gpointer userdata) +{ + int ret; + gint rows = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + do { + ret = sqlite3_step (sql_stmt); + if (ret == SQLITE_ROW) { + if (callback && !callback (sql_stmt, userdata)) { + /* stop if callback return FALSE */ + break; + } + rows++; + } else if (ret != SQLITE_DONE) { + gsignond_db_sql_database_update_error_from_db (self); + DBG ("error executing query : %s", sqlite3_errmsg (self->priv->db)); + break; + } + + } while (ret != SQLITE_DONE); + + sqlite3_finalize (sql_stmt); + + return rows; +} + +/** + * gsignond_db_sql_database_start_transaction: + * @self: instance of #GSignondDbSqlDatabase + * + * Starts a transaction. + * + * Returns: TRUE if the transaction starts successfully, + * FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_start_transaction (GSignondDbSqlDatabase *self) +{ + int ret; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + g_return_val_if_fail (self->priv->db != NULL, FALSE); + + /* prepare transaction begin, commit and rollback statements */ + ret = gsignond_db_sql_database_prepare_transaction_statements (self); + if (G_UNLIKELY (ret != SQLITE_OK)) { + DBG ("Prepare statement failed"); + gsignond_db_sql_database_update_error_from_db (self); + return FALSE; + } + + /* begin statement */ + ret = sqlite3_step (self->priv->begin_statement); + if (G_UNLIKELY (ret != SQLITE_DONE)) { + DBG ("Begin statement failed"); + gsignond_db_sql_database_update_error_from_db (self); + return FALSE; + } + return TRUE; +} + +/** + * gsignond_db_sql_database_commit_transaction: + * @self: instance of #GSignondDbSqlDatabase + * + * Runs commit statement. + * + * Returns: TRUE if the transaction is committed successfully, + * FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_commit_transaction (GSignondDbSqlDatabase *self) +{ + int ret; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + g_return_val_if_fail (self->priv->db != NULL, FALSE); + + ret = sqlite3_step (self->priv->commit_statement); + if (G_UNLIKELY (ret != SQLITE_DONE)) { + DBG ("Commit statement failed"); + gsignond_db_sql_database_update_error_from_db (self); + sqlite3_reset (self->priv->commit_statement); + return FALSE; + } + sqlite3_reset (self->priv->commit_statement); + + return TRUE; +} + +/** + * gsignond_db_sql_database_rollback_transaction: + * @self: instance of #GSignondDbSqlDatabase + * + * Runs rollback statement. + * + * Returns: TRUE if the transaction rolls back successfully, + * FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_rollback_transaction (GSignondDbSqlDatabase *self) +{ + int ret; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + g_return_val_if_fail (self->priv->db != NULL, FALSE); + + ret = sqlite3_step (self->priv->rollback_statement); + if (G_UNLIKELY (ret != SQLITE_DONE)) { + DBG ("Rollback statement failed"); + gsignond_db_sql_database_update_error_from_db (self); + sqlite3_reset (self->priv->rollback_statement); + return FALSE; + } + sqlite3_reset (self->priv->rollback_statement); + return TRUE; +} + +/** + * gsignond_db_sql_database_transaction_exec: + * @self: instance of #GSignondDbSqlDatabase + * @stmts: sql statements to be executed on the database + * + * Executes SQL statements starting with begin statement, and ending with + * commit statement. In case of any failures, statements are rolledback. + * + * Returns: TRUE if the sql statements executes successfully, + * FALSE otherwise. + */ +gboolean +gsignond_db_sql_database_transaction_exec ( + GSignondDbSqlDatabase *self, + const gchar *statements) +{ + int ret; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), FALSE); + g_return_val_if_fail (self->priv->db != NULL, FALSE); + + if (!gsignond_db_sql_database_start_transaction (self)) { + return FALSE; + } + + /* exec statements */ + ret = sqlite3_exec (self->priv->db, statements, NULL, NULL, NULL); + if (G_UNLIKELY (ret != SQLITE_OK)) { + gsignond_db_sql_database_update_error_from_db (self); + gsignond_db_sql_database_rollback_transaction (self); + return FALSE; + } + + return gsignond_db_sql_database_commit_transaction (self); +} + +/** + * gsignond_db_sql_database_get_db_version: + * @self: instance of #GSignondDbDefaultStorage + * @query: query to be executed on db to get version + * e.g. PRAGMA db_version; + * + * reads the database version from db + * + */ +gint +gsignond_db_sql_database_get_db_version ( + GSignondDbSqlDatabase *self, + const gchar *query) +{ + int ret; + sqlite3_stmt *sql_stmt; + gint db_version = 0; + + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), 0); + g_return_val_if_fail (self->priv->db != NULL, 0); + + if (self->priv->db_version > 0) { + return self->priv->db_version; + } + + ret = sqlite3_prepare_v2 (self->priv->db, query, -1, &sql_stmt, NULL); + + if (ret == SQLITE_OK) { + ret = sqlite3_step(sql_stmt); + if (ret == SQLITE_ROW || ret == SQLITE_DONE) { + db_version = sqlite3_column_int(sql_stmt, 0); + DBG ("database version %d", db_version); + self->priv->db_version = db_version; + } + sqlite3_finalize(sql_stmt); + } + + return db_version; +} + +/** + * gsignond_db_sql_database_set_last_error: + * @self: instance of #GSignondDbDefaultStorage + * @error: (transfer full) last occurred #GError + * + * sets the last occurred error + * + */ +void +gsignond_db_sql_database_set_last_error ( + GSignondDbSqlDatabase *self, + GError* error) +{ + g_return_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self)); + gsignond_db_sql_database_clear_last_error(self); + self->priv->last_error = error; +} + +/** + * gsignond_db_sql_database_get_last_error: + * @self: instance of #GSignondDbDefaultStorage + * + * retrieves the last occurred error + * + * Returns: last occurred #GError + * + */ +const GError* +gsignond_db_sql_database_get_last_error (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), NULL); + return self->priv->last_error; +} + +/** + * gsignond_db_sql_database_clear_last_error: + * @self: instance of #GSignondDbDefaultStorage + * + * clears the last occurred error + * + */ +void +gsignond_db_sql_database_clear_last_error (GSignondDbSqlDatabase *self) +{ + g_return_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self)); + if (self->priv->last_error != NULL) { + g_error_free(self->priv->last_error); + self->priv->last_error = NULL; + } +} + +/** + * gsignond_db_sql_database_get_last_insert_rowid: + * @self: instance of #GSignondDbDefaultStorage + * + * the last inserted row id + * + * Returns: last inserted rowid + */ +gint64 +gsignond_db_sql_database_get_last_insert_rowid (GSignondDbSqlDatabase *self) +{ + g_return_val_if_fail (GSIGNOND_DB_IS_SQL_DATABASE (self), -1); + g_return_val_if_fail (self->priv->db != NULL, 0); + + return sqlite3_last_insert_rowid (self->priv->db); +} + + diff --git a/src/common/db/gsignond-db-sql-database.h b/src/common/db/gsignond-db-sql-database.h new file mode 100644 index 0000000..2e92ac1 --- /dev/null +++ b/src/common/db/gsignond-db-sql-database.h @@ -0,0 +1,233 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef __GSIGNOND_DB_SQL_DATABASE_H__ +#define __GSIGNOND_DB_SQL_DATABASE_H__ + +#include <glib.h> +#include <glib-object.h> +#include <sqlite3.h> + +G_BEGIN_DECLS + +/* + * Type macros. + */ +#define GSIGNOND_DB_TYPE_SQL_DATABASE \ + (gsignond_db_sql_database_get_type ()) +#define GSIGNOND_DB_SQL_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + GSIGNOND_DB_TYPE_SQL_DATABASE, \ + GSignondDbSqlDatabase)) +#define GSIGNOND_DB_IS_SQL_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ + GSIGNOND_DB_TYPE_SQL_DATABASE)) +#define GSIGNOND_DB_SQL_DATABASE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + GSIGNOND_DB_TYPE_SQL_DATABASE, \ + GSignondDbSqlDatabaseClass)) +#define GSIGNOND_DB_IS_SQL_DATABASE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + GSIGNOND_DB_TYPE_SQL_DATABASE)) +#define GSIGNOND_DB_SQL_DATABASE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + GSIGNOND_DB_TYPE_SQL_DATABASE, \ + GSignondDbSqlDatabaseClass)) + +typedef struct _GSignondDbSqlDatabasePrivate GSignondDbSqlDatabasePrivate; + +typedef gboolean (*GSignondDbSqlDatabaseQueryCallback) (sqlite3_stmt *statement, + gpointer userdata); + +typedef struct +{ + GObject parent_instance; + + /*< private >*/ + GSignondDbSqlDatabasePrivate *priv; +} GSignondDbSqlDatabase; + +typedef struct { + GObjectClass parent_class; + + /** + * open: + * + * See #gsignond_db_sql_database_open. + */ + gboolean + (*open) ( + GSignondDbSqlDatabase *self, + const gchar *filename, + int flags); + + /** + * close: + * + * See #gsignond_db_sql_database_close. + */ + gboolean + (*close) (GSignondDbSqlDatabase *self); + + /** + * is_open: + * + * See #gsignond_db_sql_database_is_open + */ + gboolean + (*is_open) (GSignondDbSqlDatabase *self); + + /** + * create: + * + * See #gsignond_db_sql_database_create. + */ + gboolean + (*create) (GSignondDbSqlDatabase *self); + + /** + * clear: + * + * See #gsignond_db_sql_database_clear. + */ + gboolean + (*clear) (GSignondDbSqlDatabase *self); + +} GSignondDbSqlDatabaseClass; + +/* used by GSIGNOND_DB_TYPE_SQL_DATABASE */ +GType +gsignond_db_sql_database_get_type (void); + +gboolean +gsignond_db_sql_database_open ( + GSignondDbSqlDatabase *self, + const gchar *filename, + int flags); + +gboolean +gsignond_db_sql_database_close (GSignondDbSqlDatabase *self); + +gboolean +gsignond_db_sql_database_is_open ( + GSignondDbSqlDatabase *self); + +gboolean +gsignond_db_sql_database_create ( + GSignondDbSqlDatabase *self); + +gboolean +gsignond_db_sql_database_clear ( + GSignondDbSqlDatabase *self); + +sqlite3_stmt * +gsignond_db_sql_database_prepare_statement ( + GSignondDbSqlDatabase *self, + const gchar *query); + +gboolean +gsignond_db_sql_database_exec ( + GSignondDbSqlDatabase *self, + const gchar *statements); + +gint +gsignond_db_sql_database_query_exec ( + GSignondDbSqlDatabase *self, + const gchar *query, + GSignondDbSqlDatabaseQueryCallback callback, + gpointer userdata); + +gchar * +gsignond_db_sql_database_query_exec_string ( + GSignondDbSqlDatabase *self, + const gchar *query); + +GList * +gsignond_db_sql_database_query_exec_string_list ( + GSignondDbSqlDatabase *self, + const gchar *query); + +GHashTable * +gsignond_db_sql_database_query_exec_string_tuple ( + GSignondDbSqlDatabase *self, + const gchar *query); + +GHashTable * +gsignond_db_sql_database_query_exec_int_string_tuple ( + GSignondDbSqlDatabase *self, + const gchar *query); + +gboolean +gsignond_db_sql_database_query_exec_int ( + GSignondDbSqlDatabase *self, + const gchar *query, + gint *result); + +GArray * +gsignond_db_sql_database_query_exec_int_array ( + GSignondDbSqlDatabase *self, + const gchar *query); + +gint +gsignond_db_sql_database_query_exec_stmt ( + GSignondDbSqlDatabase *self, + sqlite3_stmt *sql_stmt, + GSignondDbSqlDatabaseQueryCallback callback, + gpointer userdata); + +gboolean +gsignond_db_sql_database_start_transaction (GSignondDbSqlDatabase *self); + +gboolean +gsignond_db_sql_database_commit_transaction (GSignondDbSqlDatabase *self); + +gboolean +gsignond_db_sql_database_rollback_transaction (GSignondDbSqlDatabase *self); + +gboolean +gsignond_db_sql_database_transaction_exec ( + GSignondDbSqlDatabase *self, + const gchar *stmts); + +gint +gsignond_db_sql_database_get_db_version ( + GSignondDbSqlDatabase *self, + const gchar *query); + +void +gsignond_db_sql_database_set_last_error ( + GSignondDbSqlDatabase *self, + GError *error); + +const GError * +gsignond_db_sql_database_get_last_error (GSignondDbSqlDatabase *self); + +void +gsignond_db_sql_database_clear_last_error (GSignondDbSqlDatabase *self); + +gint64 +gsignond_db_sql_database_get_last_insert_rowid (GSignondDbSqlDatabase *self); + +G_END_DECLS + +#endif /* __GSIGNOND_DB_SQL_DATABASE_H__ */ diff --git a/src/common/db/gsignond-secret-storage.c b/src/common/db/gsignond-secret-storage.c new file mode 100644 index 0000000..90209fa --- /dev/null +++ b/src/common/db/gsignond-secret-storage.c @@ -0,0 +1,496 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "gsignond-db-secret-database.h" +#include "gsignond-db-error.h" + +#include "gsignond/gsignond-log.h" +#include "gsignond/gsignond-secret-storage.h" + +#define GSIGNOND_SECRET_STORAGE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ + GSIGNOND_TYPE_SECRET_STORAGE, \ + GSignondSecretStoragePrivate)) + +struct _GSignondSecretStoragePrivate +{ + GSignondDbSecretDatabase *database; +}; + +G_DEFINE_TYPE (GSignondSecretStorage, gsignond_secret_storage, + G_TYPE_OBJECT); + +enum +{ + PROP_0, + PROP_CONFIG, + N_PROPERTIES +}; + +static GParamSpec *properties[N_PROPERTIES] = { NULL, }; + +static void +_set_property (GObject *object, guint prop_id, const GValue *value, + GParamSpec *pspec) +{ + GSignondSecretStorage *self = GSIGNOND_SECRET_STORAGE (object); + + switch (prop_id) { + case PROP_CONFIG: + g_assert (self->config == NULL); + self->config = g_value_dup_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GSignondSecretStorage *self = GSIGNOND_SECRET_STORAGE (object); + + switch (prop_id) { + case PROP_CONFIG: + g_value_set_object (value, self->config); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +_gsignond_secret_storage_dispose (GObject *gobject) +{ + g_return_if_fail (GSIGNOND_IS_SECRET_STORAGE (gobject)); + GSignondSecretStorage *self = GSIGNOND_SECRET_STORAGE (gobject); + + /* dispose might be called multiple times, so we must guard against + * calling g_object_unref() on an invalid GObject. + */ + if (self->priv->database) { + g_object_unref (self->priv->database); + self->priv->database = NULL; + } + + if (self->config) { + g_object_unref (self->config); + self->config = NULL; + } + + /* Chain up to the parent class */ + G_OBJECT_CLASS (gsignond_secret_storage_parent_class)->dispose ( + gobject); +} + +static void +gsignond_secret_storage_class_init (GSignondSecretStorageClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->set_property = _set_property; + gobject_class->get_property = _get_property; + gobject_class->dispose = _gsignond_secret_storage_dispose; + + properties[PROP_CONFIG] = g_param_spec_object ("config", + "config", + "Configuration object", + GSIGNOND_TYPE_CONFIG, + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (gobject_class, N_PROPERTIES, properties); + + /* virtual methods */ + klass->open_db = gsignond_secret_storage_open_db; + klass->close_db = gsignond_secret_storage_close_db; + klass->clear_db = gsignond_secret_storage_clear_db; + klass->is_open_db = gsignond_secret_storage_is_open_db; + klass->load_credentials = + gsignond_secret_storage_load_credentials; + klass->update_credentials = + gsignond_secret_storage_update_credentials; + klass->remove_credentials = + gsignond_secret_storage_remove_credentials; + klass->load_data = gsignond_secret_storage_load_data; + klass->update_data = gsignond_secret_storage_update_data; + klass->remove_data = gsignond_secret_storage_remove_data; + + g_type_class_add_private (klass, sizeof (GSignondSecretStoragePrivate)); +} + +static void +gsignond_secret_storage_init (GSignondSecretStorage *self) +{ + self->priv = GSIGNOND_SECRET_STORAGE_GET_PRIVATE (self); + self->priv->database = gsignond_db_secret_database_new (); + self->config = NULL; +} + +/** + * gsignond_secret_storage_open_db: + * + * @self: instance of #GSignondSecretStorage + * + * Opens (and initializes) DB. The implementation should take + * care of creating the DB, if it doesn't exist. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_open_db (GSignondSecretStorage *self) +{ + const gchar *dir = NULL; + const gchar *filename = NULL; + gchar *db_filename = NULL; + gboolean ret = FALSE; + + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + g_return_val_if_fail (self->config != NULL, FALSE); + + dir = gsignond_config_get_string (self->config, + GSIGNOND_CONFIG_GENERAL_SECURE_DIR); + if (!dir) { + ERR ("No directory specified in config object for secret db..."); + return FALSE; + } + filename = gsignond_config_get_string (self->config, + GSIGNOND_CONFIG_DB_SECRET_DB_FILENAME); + if (!filename) { + ERR ("Database filename not specified"); + return FALSE; + } + db_filename = g_build_filename (dir, filename, NULL); + if (!db_filename) { + ERR ("Invalid db filename..."); + return FALSE; + } + + if (gsignond_secret_storage_is_open_db (self)) { + g_debug("SecretDB is already open. Closing first to start again..."); + gsignond_secret_storage_close_db (self); + } + + if (self->priv->database == NULL) { + self->priv->database = gsignond_db_secret_database_new (); + } + + ret = gsignond_db_sql_database_open ( + GSIGNOND_DB_SQL_DATABASE (self->priv->database), + db_filename, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); + g_free (db_filename); + if (!ret) { + ERR ("Open DB failed"); + g_object_unref (self->priv->database); + self->priv->database = NULL; + return FALSE; + } + return TRUE; +} + +/** + * gsignond_secret_storage_close_db: + * + * @self: instance of #GSignondSecretStorage + * + * Closes the secrets DB. To reopen it, call open_db(). + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_close_db (GSignondSecretStorage *self) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + + if (self->priv->database != NULL) { + gsignond_db_sql_database_close (GSIGNOND_DB_SQL_DATABASE ( + self->priv->database)); + } + return TRUE; +} + +/** + * gsignond_secret_storage_clear_db: + * + * @self: instance of #GSignondSecretStorage + * + * Removes all stored secrets. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_clear_db (GSignondSecretStorage *self) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + return gsignond_db_sql_database_clear (GSIGNOND_DB_SQL_DATABASE ( + self->priv->database)); +} + +/** + * gsignond_secret_storage_is_open_db: + * + * @self: instance of #GSignondSecretStorage + * + * Checks if the db is open or not. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_is_open_db (GSignondSecretStorage *self) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + return ((self->priv->database != NULL) && + gsignond_db_sql_database_is_open (GSIGNOND_DB_SQL_DATABASE ( + self->priv->database))); +} + +/** + * gsignond_secret_storage_load_credentials: + * + * @self: instance of #GSignondSecretStorage + * @id: the identity whose credentials are being loaded. + * + * Loads the credentials. + * + * Returns: (transfer full) #GSignondCredentials if successful, + * NULL otherwise. + */ +GSignondCredentials* +gsignond_secret_storage_load_credentials ( + GSignondSecretStorage *self, + const guint32 id) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + return gsignond_db_secret_database_load_credentials (self->priv->database, + id); +} + +/** + * gsignond_secret_storage_update_credentials: + * + * @self: instance of #GSignondSecretStorage + * @creds: (transfer none) the credentials that are being updated. + * + * Stores/updates the credentials for the given identity. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_update_credentials ( + GSignondSecretStorage *self, + GSignondCredentials *creds) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + return gsignond_db_secret_database_update_credentials (self->priv->database, + creds); +} + +/** + * gsignond_secret_storage_remove_credentials: + * + * @self: instance of #GSignondSecretStorage + * @id: the identity whose credentials are being updated. + * + * Remove the credentials for the given identity. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_remove_credentials ( + GSignondSecretStorage *self, + const guint32 id) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + return gsignond_db_secret_database_remove_credentials (self->priv->database, + id); +} + +/** + * gsignond_secret_storage_check_credentials: + * + * @self: instance of #GSignondSecretStorage + * @creds: (transfer none) the credentials that are being checked. + * + * Checks whether the given credentials are correct for the + * given identity. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_check_credentials ( + GSignondSecretStorage *self, + GSignondCredentials *creds) +{ + gboolean equal = FALSE; + GSignondCredentials *stored_creds = NULL; + + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + g_return_val_if_fail (creds != NULL, FALSE); + + GSignondSecretStorageClass *klass = + GSIGNOND_SECRET_STORAGE_GET_CLASS (self); + + stored_creds = klass->load_credentials (self, + gsignond_credentials_get_id(creds)); + + if (stored_creds) { + DBG ("Credentials from DB found"); + equal = gsignond_credentials_equal(creds, stored_creds); + g_object_unref (stored_creds); + } + + return equal; +} + +/** + * gsignond_secret_storage_load_data: + * + * @self: instance of #GSignondSecretStorage + * @id: the identity whose credentials are being fetched. + * @method: the authentication method the data is used for. + * + * Loads secret data. + * + * Returns: (transfer full) #GHashTable (gchar*, GBytes*) data. When done data + * should be freed with g_hash_table_unref (data) + */ +GHashTable* +gsignond_secret_storage_load_data ( + GSignondSecretStorage *self, + const guint32 id, + const guint32 method) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), NULL); + return gsignond_db_secret_database_load_data (self->priv->database, + id, method); +} + +/** + * gsignond_secret_storage_update_data: + * + * @self: instance of #GSignondSecretStorage + * @id: the identity whose credentials are being fetched. + * @method: the authentication method the data is used for. + * @data: (transfer none) the data as #GHashTable (gchar*, GBytes*) + * + * Stores/replaces secret data. Calling this method replaces any data + * which was previously stored for the given id/method. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_update_data ( + GSignondSecretStorage *self, + const guint32 id, + const guint32 method, + GHashTable *data) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + return gsignond_db_secret_database_update_data (self->priv->database, + id, method, data); +} + +/** + * gsignond_secret_storage_remove_data: + * + * @self: instance of #GSignondSecretStorage + * @id: the identity whose credentials are being checked. + * @method: the authentication method the data is used for. + * + * Removes secret data. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_secret_storage_remove_data ( + GSignondSecretStorage *self, + const guint32 id, + const guint32 method) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), FALSE); + return gsignond_db_secret_database_remove_data (self->priv->database, + id, method); +} + +/** + * gsignond_secret_storage_set_last_error: + * @self: instance of #GSignondDbDefaultStorage + * @error : (transfer full) last occurred #GError + * + * sets the last occurred error + * + */ +void +gsignond_secret_storage_set_last_error ( + GSignondSecretStorage *self, + GError* error) +{ + g_return_if_fail (GSIGNOND_IS_SECRET_STORAGE (self)); + g_return_if_fail (self->priv->database != NULL); + gsignond_db_sql_database_set_last_error ( + GSIGNOND_DB_SQL_DATABASE (self->priv->database), error); +} + +/** + * gsignond_secret_storage_get_last_error: + * + * @self: instance of #GSignondSecretStorage + * + * retrieves the last occurred error + * + * Returns: (transfer none) last occurred #GError + */ +const GError * +gsignond_secret_storage_get_last_error (GSignondSecretStorage *self) +{ + g_return_val_if_fail (GSIGNOND_IS_SECRET_STORAGE (self), NULL); + if (self->priv->database != NULL) { + return gsignond_db_sql_database_get_last_error ( + GSIGNOND_DB_SQL_DATABASE (self->priv->database)); + } + return NULL; +} + +/** + * gsignond_secret_storage_clear_last_error: + * + * @self: instance of #GSignondSecretStorage + * + * clears the last occurred error + */ +void +gsignond_secret_storage_clear_last_error (GSignondSecretStorage *self) +{ + g_return_if_fail (GSIGNOND_IS_SECRET_STORAGE (self)); + if (self->priv->database != NULL) { + gsignond_db_sql_database_clear_last_error ( + GSIGNOND_DB_SQL_DATABASE (self->priv->database)); + } +} + + + + diff --git a/src/common/gsignond-access-control-manager.c b/src/common/gsignond-access-control-manager.c new file mode 100644 index 0000000..438b0f0 --- /dev/null +++ b/src/common/gsignond-access-control-manager.c @@ -0,0 +1,412 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012-2013 Intel Corporation. + * + * Contact: Jussi Laako <jussi.laako@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include <gio/gio.h> + +#include "config.h" + +#include "gsignond/gsignond-log.h" +#include "gsignond/gsignond-access-control-manager.h" + +#define GSIGNOND_ACCESS_CONTROL_MANAGER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + GSIGNOND_TYPE_ACCESS_CONTROL_MANAGER, \ + GSignondAccessControlManagerPrivate)) + +#define DBUS_SERVICE_DBUS "org.freedesktop.DBus" +#define DBUS_PATH_DBUS "/org/freedesktop/DBus" +#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus" +#ifndef GSIGNOND_BUS_TYPE +# define GSIGNOND_BUS_TYPE G_BUS_TYPE_SESSION +#endif + +struct _GSignondAccessControlManagerPrivate +{ +}; + +enum +{ + PROP_0, + PROP_CONFIG, + N_PROPERTIES +}; + +static GParamSpec *properties[N_PROPERTIES] = { NULL, }; + +G_DEFINE_TYPE (GSignondAccessControlManager, gsignond_access_control_manager, + G_TYPE_OBJECT); + +static void +_set_property (GObject *object, guint prop_id, const GValue *value, + GParamSpec *pspec) +{ + GSignondAccessControlManager *self = + GSIGNOND_ACCESS_CONTROL_MANAGER (object); + + switch (prop_id) { + case PROP_CONFIG: + g_assert (self->config == NULL); + self->config = g_value_dup_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GSignondAccessControlManager *self = + GSIGNOND_ACCESS_CONTROL_MANAGER (object); + + switch (prop_id) { + case PROP_CONFIG: + g_value_set_object (value, self->config); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +_dispose (GObject *object) +{ + GSignondAccessControlManager *self = + GSIGNOND_ACCESS_CONTROL_MANAGER (object); + + if (self->config) { + g_object_unref (self->config); + self->config = NULL; + } + + G_OBJECT_CLASS (gsignond_access_control_manager_parent_class)->dispose (object); +} + +static void +_security_context_of_peer (GSignondAccessControlManager *self, + GSignondSecurityContext *peer_ctx, + int peer_fd, const gchar *peer_service, + const gchar *peer_app_ctx) +{ + pid_t remote_pid = 0; + gchar *procfname; + char *peerpath; + ssize_t res; + + (void) self; + + gsignond_security_context_set_system_context (peer_ctx, ""); + gsignond_security_context_set_application_context (peer_ctx, + peer_app_ctx); + + if (peer_fd >= 0) { + struct ucred peer_cred; + socklen_t cred_size = sizeof(peer_cred); + + if (getsockopt (peer_fd, SOL_SOCKET, SO_PEERCRED, + &peer_cred, &cred_size) != 0) { + WARN ("getsockopt() for SO_PEERCRED failed"); + return; + } + DBG ("remote peer pid=%d uid=%d gid=%d", + peer_cred.pid, peer_cred.uid, peer_cred.gid); + remote_pid = peer_cred.pid; + } else if (peer_service) { + GError *error = NULL; + GDBusConnection *connection; + GVariant *response = NULL; + guint32 upid; + + connection = g_bus_get_sync (GSIGNOND_BUS_TYPE, NULL, &error); + if (!connection) { + WARN ("failed to open connection to session bus: %s", + error->message); + g_error_free (error); + return; + } + + error = NULL; + response = g_dbus_connection_call_sync (connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "GetConnectionUnixProcessID", + g_variant_new ("(s)", peer_service), + ((const GVariantType *) "(u)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + + g_object_unref (connection); + + if (!response) { + WARN ("request for peer pid failed: %s", + error->message); + g_error_free (error); + return; + } + + g_variant_get (response, "(u)", &upid); + DBG ("remote peer service=%s pid=%u", peer_service, upid); + remote_pid = (pid_t) upid; + + g_variant_unref (response); + } else return; + + if (!remote_pid) + return; + + procfname = g_strdup_printf ("/proc/%d/exe", remote_pid); + peerpath = g_malloc0 (PATH_MAX + 1); + res = readlink (procfname, peerpath, PATH_MAX); + g_free (procfname); + if (res <= 0) { + WARN ("failed to follow link for pid %d", remote_pid); + g_free (peerpath); + return; + } + + DBG ("identity of pid %d is [%s:%s]", remote_pid, peerpath, peer_app_ctx); + gsignond_security_context_set_system_context (peer_ctx, peerpath); + + g_free (peerpath); +} + +static gboolean +_peer_is_allowed_to_use_identity (GSignondAccessControlManager *self, + const GSignondSecurityContext *peer_ctx, + const GSignondSecurityContext *owner_ctx, + const GSignondSecurityContextList *identity_acl) +{ + GSignondSecurityContext *acl_ctx; + + (void) self; + (void) owner_ctx; + + for ( ; identity_acl != NULL; identity_acl = g_list_next (identity_acl)) { + acl_ctx = (GSignondSecurityContext *) identity_acl->data; + DBG ("ACL check [%p=(%s:%s)] vs [%p=(%s:%s)]", + acl_ctx, + gsignond_security_context_get_system_context (acl_ctx), + gsignond_security_context_get_application_context (acl_ctx), + peer_ctx, + gsignond_security_context_get_system_context (peer_ctx), + gsignond_security_context_get_application_context (peer_ctx)); + if (gsignond_security_context_check (acl_ctx, peer_ctx)) { + DBG (" - ACL check passed"); + return TRUE; + } + } + DBG (" - ACL check failed"); + return FALSE; +} + +static gboolean +_peer_is_owner_of_identity (GSignondAccessControlManager *self, + const GSignondSecurityContext *peer_ctx, + const GSignondSecurityContext *owner_ctx) +{ + (void) self; + + DBG ("Owner check [%p=(%s:%s)] vs [%p=(%s:%s)]", + owner_ctx, + gsignond_security_context_get_system_context (owner_ctx), + gsignond_security_context_get_application_context (owner_ctx), + peer_ctx, + gsignond_security_context_get_system_context (peer_ctx), + gsignond_security_context_get_application_context (peer_ctx)); + return gsignond_security_context_check (owner_ctx, peer_ctx); +} + +static gboolean +_acl_is_valid (GSignondAccessControlManager *self, + const GSignondSecurityContext *peer_ctx, + const GSignondSecurityContextList *identity_acl) +{ + (void) self; + (void) peer_ctx; + (void) identity_acl; + + return TRUE; +} + +GSignondSecurityContext * +_security_context_of_keychain (GSignondAccessControlManager *self) +{ + const gchar *keychain_sysctx = NULL; + + (void) self; + +# ifdef ENABLE_DEBUG + keychain_sysctx = g_getenv ("SSO_KEYCHAIN_SYSCTX"); +# endif + if (!keychain_sysctx) + keychain_sysctx = ""; + return gsignond_security_context_new_from_values (keychain_sysctx, ""); +} + +static void +gsignond_access_control_manager_class_init ( + GSignondAccessControlManagerClass *klass) +{ + GObjectClass *base = G_OBJECT_CLASS (klass); + + base->set_property = _set_property; + base->get_property = _get_property; + base->dispose = _dispose; + properties[PROP_CONFIG] = g_param_spec_object ("config", + "config", + "Configuration object", + GSIGNOND_TYPE_CONFIG, + G_PARAM_CONSTRUCT_ONLY| + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (base, N_PROPERTIES, properties); + + /*g_type_class_add_private (klass, + sizeof(GSignondAccessControlManagerPrivate));*/ + + klass->security_context_of_peer = _security_context_of_peer; + klass->peer_is_allowed_to_use_identity = _peer_is_allowed_to_use_identity; + klass->peer_is_owner_of_identity = _peer_is_owner_of_identity; + klass->acl_is_valid = _acl_is_valid; + klass->security_context_of_keychain = _security_context_of_keychain; +} + +static void +gsignond_access_control_manager_init (GSignondAccessControlManager *self) +{ + /*self->priv = GSIGNOND_ACCESS_CONTROL_MANAGER_GET_PRIVATE (self);*/ + + self->config = NULL; +} + +/** + * gsignond_access_control_manager_security_context_of_peer: + * @self: object instance. + * @peer_ctx: instance of security context to be set. + * @peer_fd: file descriptor of the peer connection. + * @peer_app_ctx: application context of the peer connection. + * + * Retrieves #GSignondSecurityContext of the specified peer. + */ +void +gsignond_access_control_manager_security_context_of_peer ( + GSignondAccessControlManager *self, + GSignondSecurityContext *peer_ctx, + int peer_fd, const gchar *peer_service, + const gchar *peer_app_ctx) +{ + GSIGNOND_ACCESS_CONTROL_MANAGER_GET_CLASS (self)-> + security_context_of_peer (self, peer_ctx, peer_fd, + peer_service, peer_app_ctx); +} + +/** + * gsignond_access_control_manager_peer_is_allowed_to_use_identity: + * @self: object instance. + * @peer_ctx: security context of the peer connection. + * @owner_ctx: security context of the identity owner. + * @identity_acl: access control list for the identity in question. + * + * Checks if specified peer is allowed to access the specified identity. + * + * Returns: access is allowed? + */ +gboolean +gsignond_access_control_manager_peer_is_allowed_to_use_identity ( + GSignondAccessControlManager *self, + const GSignondSecurityContext *peer_ctx, + const GSignondSecurityContext *owner_ctx, + const GSignondSecurityContextList *identity_acl) +{ + return GSIGNOND_ACCESS_CONTROL_MANAGER_GET_CLASS (self)-> + peer_is_allowed_to_use_identity (self, peer_ctx, owner_ctx, identity_acl); +} + +/** + * gsignond_access_control_manager_peer_is_owner_of_identity: + * @self: object instance. + * @peer_ctx: security context of the peer connection. + * @owner_ctx: security context of the identity owner. + * + * Checks if the specified peer is owner of the identity. + * + * Returns: is owner? + */ +gboolean +gsignond_access_control_manager_peer_is_owner_of_identity ( + GSignondAccessControlManager *self, + const GSignondSecurityContext *peer_ctx, + const GSignondSecurityContext *owner_ctx) +{ + return GSIGNOND_ACCESS_CONTROL_MANAGER_GET_CLASS (self)-> + peer_is_owner_of_identity (self, peer_ctx, owner_ctx); +} + +/** + * gsignond_access_control_manager_acl_is_valid: + * @self: object instance. + * @peer_ctx: security context of the peer connection. + * @identity_acl: access control list for the identity. + * + * Checks if the specified peer is allowed to set the specified access + * control list. + * + * Returns: access control list is OK? + */ +gboolean +gsignond_access_control_manager_acl_is_valid ( + GSignondAccessControlManager *self, + const GSignondSecurityContext *peer_ctx, + const GSignondSecurityContextList *identity_acl) +{ + return GSIGNOND_ACCESS_CONTROL_MANAGER_GET_CLASS (self)-> + acl_is_valid (self, peer_ctx, identity_acl); +} + +/** + * gsignond_access_control_manager_security_context_of_keychain: + * @self: object instance. + * + * Retrieves security context of the keychain application. Keychain application + * has a special management access to all stored identities. + * + * Returns: security context of the keychain application. + */ +GSignondSecurityContext * +gsignond_access_control_manager_security_context_of_keychain ( + GSignondAccessControlManager *self) +{ + return GSIGNOND_ACCESS_CONTROL_MANAGER_GET_CLASS (self)-> + security_context_of_keychain (self); +} + diff --git a/src/common/gsignond-config.c b/src/common/gsignond-config.c new file mode 100644 index 0000000..714622d --- /dev/null +++ b/src/common/gsignond-config.c @@ -0,0 +1,384 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Jussi Laako <jussi.laako@linux.intel.com> + * Amarnath Valluri <amarnath.valluri@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <stdlib.h> +#include <unistd.h> +#include <glib/gstdio.h> + +#include "config.h" + +#include "gsignond/gsignond-config.h" +#include "gsignond/gsignond-config-general.h" +#include "gsignond/gsignond-config-db.h" +#include "gsignond/gsignond-config-dbus.h" +#include "gsignond/gsignond-log.h" +#include "gsignond/gsignond-dictionary.h" + +#define GSIGNOND_DB_METADATA_DEFAULT_DB_FILENAME "metadata.db" +#define GSIGNOND_DB_SECRET_DEFAULT_DB_FILENAME "secret.db" + +struct _GSignondConfigPrivate +{ + gchar *config_file_path; + GSignondDictionary *config_table; +}; + +#define GSIGNOND_CONFIG_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_CONFIG, GSignondConfigPrivate) + +G_DEFINE_TYPE (GSignondConfig, gsignond_config, G_TYPE_OBJECT); + + +static void +_set_storage_path (GSignondConfig *self, const gchar *value) +{ + gchar *storage_path = g_build_filename (value, + "gsignond.general", + NULL); + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_STORAGE_PATH, + storage_path); + g_free (storage_path); +} + +static gboolean +_load_config (GSignondConfig *self) +{ + gchar *def_config; + GError *err = NULL; + gchar **groups = NULL; + gsize n_groups = 0; + int i,j; + GKeyFile *settings = g_key_file_new (); + +# ifdef ENABLE_DEBUG + const gchar * const *sysconfdirs; + + if (!self->priv->config_file_path) { + def_config = g_strdup (g_getenv ("GSIGNOND_CONFIG")); + if (!def_config) + def_config = g_build_filename (g_get_user_config_dir(), + "gsignond/gsignond.conf", + NULL); + if (g_access (def_config, R_OK) == 0) { + self->priv->config_file_path = def_config; + } else { + g_free (def_config); + sysconfdirs = g_get_system_config_dirs (); + while (*sysconfdirs != NULL) { + def_config = g_build_filename (*sysconfdirs, + "gsignond/gsignond.conf", + NULL); + if (g_access (def_config, R_OK) == 0) { + self->priv->config_file_path = def_config; + break; + } + g_free (def_config); + sysconfdirs++; + } + } + } +# else /* ENABLE_DEBUG */ +# ifndef GSIGNOND_SYSCONF_DIR +# error "System configuration directory not defined!" +# endif + def_config = g_build_filename (GSIGNOND_SYSCONF_DIR, + "gsignond/gsignond.conf", + NULL); + if (g_access (def_config, R_OK) == 0) { + self->priv->config_file_path = def_config; + } else { + g_free (def_config); + } +# endif /* ENABLE_DEBUG */ + + if (self->priv->config_file_path) { + DBG ("Loading SSO config from %s", self->priv->config_file_path); + if (!g_key_file_load_from_file (settings, + self->priv->config_file_path, + G_KEY_FILE_NONE, &err)) { + WARN ("error reading config file at '%s': %s", + self->priv->config_file_path, err->message); + g_error_free (err); + g_key_file_free (settings); + return FALSE; + } + } + + groups = g_key_file_get_groups (settings, &n_groups); + + for (i = 0; i < n_groups; i++) { + GError *err = NULL; + gsize n_keys =0; + gchar **keys = g_key_file_get_keys (settings, + groups[i], + &n_keys, + &err); + if (err) { + WARN ("fail to read group '%s': %s", groups[i], err->message); + g_error_free (err); + continue; + } + + for (j = 0; j < n_keys; j++) { + gchar *key = g_strdup_printf ("%s/%s", groups[i], keys[j]); + gchar *value = g_key_file_get_value (settings, + groups[i], + keys[j], + &err); + if (err) { + WARN ("fail to read key '%s/%s': %s", groups[i], keys[j], err->message); + g_error_free (err); + continue; + } + + INFO ("found config : '%s/%s' - '%s'", groups[i], keys[j], value); + + /* construct a full storage path for wipe safety */ + if (g_strcmp0 (key, GSIGNOND_CONFIG_GENERAL_STORAGE_PATH) == 0) + _set_storage_path (self, value); + else + gsignond_config_set_string (self, key, value); + + g_free (key); + g_free (value); + } + + g_strfreev (keys); + } + + g_strfreev (groups); + + g_key_file_free (settings); + + return TRUE; +} + +#ifdef ENABLE_DEBUG +static void +_load_environment (GSignondConfig *self) +{ + const gchar *e_val = 0; + guint timeout = 0; + + e_val = g_getenv ("SSO_DAEMON_TIMEOUT"); + if (e_val && (timeout = atoi(e_val))) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_DBUS_DAEMON_TIMEOUT, + e_val); + + e_val = g_getenv ("SSO_IDENTITY_TIMEOUT"); + if (e_val && (timeout = atoi(e_val))) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_DBUS_IDENTITY_TIMEOUT, + e_val); + + e_val = g_getenv ("SSO_AUTHSESSION_TIMEOUT"); + if (e_val && (timeout = atoi(e_val))) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_DBUS_AUTH_SESSION_TIMEOUT, + e_val); + + e_val = g_getenv ("SSO_PLUGIN_TIMEOUT"); + if (e_val && (timeout = atoi(e_val))) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_PLUGIN_TIMEOUT, + e_val); + + e_val = g_getenv ("SSO_PLUGINS_DIR"); + if (e_val) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR, + e_val); + + e_val = g_getenv ("SSO_EXTENSIONS_DIR"); + if (e_val) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR, + e_val); + + e_val = g_getenv ("SSO_BIN_DIR"); + if (e_val) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_BIN_DIR, + e_val); + + e_val = g_getenv ("SSO_EXTENSION"); + if (e_val) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_EXTENSION, + e_val); + + e_val = g_getenv ("SSO_STORAGE_PATH"); + if (e_val) + _set_storage_path (self, e_val); + + e_val = g_getenv ("SSO_SECRET_PATH"); + if (e_val) + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_SECURE_DIR, + e_val); +} +#endif /* ENABLE_DEBUG */ + +gint +gsignond_config_get_integer (GSignondConfig *self, const gchar *key) +{ + const gchar *str_value = gsignond_config_get_string (self, key); + return (gint) (str_value ? atoi (str_value) : 0); +} + +void +gsignond_config_set_integer (GSignondConfig *self, const gchar *key, + gint value) +{ + gchar *s_value = 0; + g_return_if_fail (self && GSIGNOND_IS_CONFIG (self)); + + s_value = g_strdup_printf ("%d", value); + if (!s_value) return; + + gsignond_config_set_string (self, (gpointer) key, s_value); + + g_free (s_value); + +} + +const gchar * +gsignond_config_get_string (GSignondConfig *self, const gchar *key) +{ + g_return_val_if_fail (self && GSIGNOND_IS_CONFIG (self), NULL); + + GVariant* value = gsignond_dictionary_get (self->priv->config_table, + (gpointer) key); + if (!value) return NULL; + + return g_variant_get_string (value, NULL); +} + +void +gsignond_config_set_string (GSignondConfig *self, const gchar *key, + const gchar *value) +{ + g_return_if_fail (self && GSIGNOND_IS_CONFIG (self)); + + gsignond_dictionary_set (self->priv->config_table, + (gpointer) key, + g_variant_new_string (value)); + +} + +static void +gsignond_config_dispose (GObject *object) +{ + GSignondConfig *self = 0; + g_return_if_fail (object && GSIGNOND_IS_CONFIG (object)); + + self = GSIGNOND_CONFIG (object); + + if (self->priv->config_table) { + gsignond_dictionary_unref (self->priv->config_table); + self->priv->config_table = NULL; + } + + G_OBJECT_CLASS (gsignond_config_parent_class)->dispose (object); +} + +static void +gsignond_config_finalize (GObject *object) +{ + GSignondConfig *self = 0; + g_return_if_fail (object && GSIGNOND_IS_CONFIG (object)); + + self = GSIGNOND_CONFIG (object); + + if (self->priv->config_file_path) { + g_free (self->priv->config_file_path); + self->priv->config_file_path = NULL; + } + + G_OBJECT_CLASS (gsignond_config_parent_class)->finalize (object); +} + +static void +gsignond_config_init (GSignondConfig *self) +{ + self->priv = GSIGNOND_CONFIG_PRIV (self); + + self->priv->config_file_path = NULL; + self->priv->config_table = gsignond_dictionary_new(); + + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR, + (GSIGNOND_PLUGINS_DIR)); + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR, + (GSIGNOND_EXTENSIONS_DIR)); + gsignond_config_set_string (self, + (GSIGNOND_CONFIG_GENERAL_BIN_DIR), + (GSIGNOND_BIN_DIR)); + + gchar *default_data_path = + g_build_filename (g_get_user_data_dir (), "gsignond", NULL); + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_STORAGE_PATH, + default_data_path); + gsignond_config_set_string (self, + GSIGNOND_CONFIG_GENERAL_SECURE_DIR, + default_data_path); + g_free (default_data_path); + + gsignond_config_set_string (self, + GSIGNOND_CONFIG_DB_SECRET_DB_FILENAME, + GSIGNOND_DB_SECRET_DEFAULT_DB_FILENAME); + gsignond_config_set_string (self, + GSIGNOND_CONFIG_DB_METADATA_DB_FILENAME, + GSIGNOND_DB_METADATA_DEFAULT_DB_FILENAME); + + if (!_load_config (self)) + WARN ("load configuration failed, using default settings"); +# ifdef ENABLE_DEBUG + _load_environment (self); +# endif +} + +static void +gsignond_config_class_init (GSignondConfigClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (GSignondConfigPrivate)); + + object_class->dispose = gsignond_config_dispose; + object_class->finalize = gsignond_config_finalize; + +} + +GSignondConfig * +gsignond_config_new () +{ + return GSIGNOND_CONFIG (g_object_new (GSIGNOND_TYPE_CONFIG, NULL)); +} + diff --git a/src/common/gsignond-credentials.c b/src/common/gsignond-credentials.c new file mode 100644 index 0000000..397f88e --- /dev/null +++ b/src/common/gsignond-credentials.c @@ -0,0 +1,281 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "gsignond/gsignond-log.h" +#include "gsignond/gsignond-credentials.h" + +#define GSIGNOND_CREDENTIALS_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ + GSIGNOND_TYPE_CREDENTIALS, \ + GSignondCredentialsPrivate)) + +G_DEFINE_TYPE (GSignondCredentials, gsignond_credentials, G_TYPE_OBJECT); + +struct _GSignondCredentialsPrivate { + guint32 id; /*the identity associated with the credentials.*/ + + GString *username; /*username attached to the id*/ + + GString *password; /*password attached to the id*/ +}; + + +static void +_gsignond_credentials_finalize (GObject *gobject) +{ + GSignondCredentials *self = GSIGNOND_CREDENTIALS (gobject); + + if (self->priv->username) { + g_string_free (self->priv->username, TRUE); + self->priv->username = NULL; + } + if (self->priv->password) { + g_string_free (self->priv->password, TRUE); + self->priv->password = NULL; + } + + /* Chain up to the parent class */ + G_OBJECT_CLASS (gsignond_credentials_parent_class)->finalize (gobject); +} + +static void +gsignond_credentials_class_init (GSignondCredentialsClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->finalize = _gsignond_credentials_finalize; + + g_type_class_add_private (klass, sizeof (GSignondCredentialsPrivate)); +} + +static void +gsignond_credentials_init (GSignondCredentials *self) +{ + self->priv = GSIGNOND_CREDENTIALS_GET_PRIVATE (self); + self->priv->id = 0; + self->priv->username = NULL; + self->priv->password = NULL; +} + +/** + * gsignond_credentials_new: + * + * Creates new #GSignondCredentials object + * Returns : (transfer full) the #GSignondCredentials object + * + */ +GSignondCredentials * +gsignond_credentials_new () +{ + return GSIGNOND_CREDENTIALS ( + g_object_new (GSIGNOND_TYPE_CREDENTIALS, NULL)); +} + +/** + * gsignond_credentials_set_data: + * + * @self: the object whose data is to be set. + * @id: the identity associated with the credentials. + * @username: the username. + * @password: the password. + * + * Sets the data of the object. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_credentials_set_data( + GSignondCredentials *self, + const guint32 id, + const gchar* username, + const gchar* password) +{ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (self), FALSE); + + self->priv->id = id; + return gsignond_credentials_set_username (self, username) && + gsignond_credentials_set_password (self, password); +} + +/** + * gsignond_credentials_set_id: + * + * @self: the object whose id is to be set. + * @id: the id. + * + * Sets the id of the GSignondCredentials object + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_credentials_set_id( + GSignondCredentials *self, + const guint32 id) +{ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (self), FALSE); + self->priv->id = id; + return TRUE; +} + +/** + * gsignond_credentials_get_id: + * + * @self: the object whose id is to be set. + * + * Returns the id from the #GSignondCredentials object + * + * Returns: the id if the object is valid, NULL otherwise. + */ +guint32 +gsignond_credentials_get_id(GSignondCredentials *self) +{ + /* TODO: define proper invalid id */ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (self), 0); + return self->priv->id; +} + +/** + * gsignond_credentials_set_username: + * + * @self: the object whose username is to be set. + * @username: the username. + * + * Sets the username of the GSignondCredentials object; old username is + * freed if it exits + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_credentials_set_username( + GSignondCredentials *self, + const gchar* username) +{ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (self), FALSE); + + if (self->priv->username) { + g_string_free (self->priv->username, TRUE); + self->priv->username = NULL; + } + if (username) { + self->priv->username = g_string_new (username); + } + return TRUE; +} + +/** + * gsignond_credentials_get_username: + * + * @self: the object whose username is to be set. + * + * Returns the username from the #GSignondCredentials object + * + * Returns: the username if the object is valid, NULL otherwise. + */ +const gchar* +gsignond_credentials_get_username(GSignondCredentials *self) +{ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (self), NULL); + return self->priv->username ? self->priv->username->str : NULL; +} + +/** + * gsignond_credentials_set_password: + * + * @self: the object whose password is to be set. + * @password: the password. + * + * Sets the password of the GSignondCredentials object; old password is + * freed if it exits + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_credentials_set_password( + GSignondCredentials *self, + const gchar* password) +{ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (self), FALSE); + + if (self->priv->password) { + g_string_free (self->priv->password, TRUE); + self->priv->password = NULL; + } + if (password) { + self->priv->password = g_string_new (password); + } + return TRUE; +} + +/** + * gsignond_credentials_get_password: + * + * @self: the object whose password is to be set. + * + * Returns the password from the #GSignondCredentials object + * + * Returns: the password if the object is valid, NULL otherwise. + */ +const gchar* +gsignond_credentials_get_password(GSignondCredentials *self) +{ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (self), NULL); + return self->priv->password? self->priv->password->str : NULL; +} + +/** + * gsignond_credentials_equal: + * + * @one: the first credential to be compared. + * @two: the second credential to be compared. + * + * Compares elements of two GSignondCredentials object for equality. + * + * Returns: TRUE if id, username and password are same for both credential + * objects, FALSE otherwise. + */ +gboolean +gsignond_credentials_equal ( + GSignondCredentials *one, + GSignondCredentials *two) +{ + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (one), FALSE); + g_return_val_if_fail (GSIGNOND_IS_CREDENTIALS (two), FALSE); + + if (one == two) + return TRUE; + + if (one == NULL || two == NULL) + return FALSE; + + if ( (one->priv->id == two->priv->id) && + (one->priv->username && two->priv->username) && + g_string_equal(one->priv->username, two->priv->username) && + g_string_equal(one->priv->password, two->priv->password) ) { + return TRUE; + } + + return FALSE; +} + diff --git a/src/common/gsignond-dictionary.c b/src/common/gsignond-dictionary.c new file mode 100644 index 0000000..7d2c0c2 --- /dev/null +++ b/src/common/gsignond-dictionary.c @@ -0,0 +1,419 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012-2013 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <gsignond/gsignond-dictionary.h> +#include <gsignond/gsignond-log.h> + +/** + * gsignond_dictionary_new_from_variant: + * @variant: instance of #GVariant + * + * Converts the variant to GSignondDictionary. + * + * Returns: (transfer full) object if successful, NULL otherwise. + */ +GSignondDictionary * +gsignond_dictionary_new_from_variant (GVariant *variant) +{ + GSignondDictionary *dict = NULL; + GVariantIter iter; + gchar *key = NULL; + GVariant *value = NULL; + + g_return_val_if_fail (variant != NULL, NULL); + + dict = gsignond_dictionary_new (); + g_variant_iter_init (&iter, variant); + while (g_variant_iter_next (&iter, "{sv}", &key, &value)) + { + g_hash_table_insert (dict, key, value); + } + + return dict; +} + +/** + * gsignond_dictionary_to_variant: + * @dict: instance of #GSignondDictionary + * + * Converts the GSignondDictionary to variant. + * + * Returns: (transfer full) #GVariant object if successful, NULL otherwise. + */ +GVariant * +gsignond_dictionary_to_variant (GSignondDictionary *dict) +{ + GVariantBuilder builder; + GHashTableIter iter; + GVariant *vdict = NULL; + const gchar *key = NULL; + GVariant *value = NULL; + + g_return_val_if_fail (dict != NULL, NULL); + + g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); + g_hash_table_iter_init (&iter, dict); + while (g_hash_table_iter_next (&iter, + (gpointer)&key, + (gpointer)&value)) + { + g_variant_builder_add (&builder, "{sv}", + key, + value); + } + vdict = g_variant_builder_end (&builder); + return vdict; +} + +/** + * gsignond_dictionary_new: + * + * Creates new instance of GSignondDictionary. + * + * Returns: (transfer full) #GSignondDictionary object if successful, + * NULL otherwise. + */ +GSignondDictionary * +gsignond_dictionary_new (void) +{ + return g_hash_table_new_full ((GHashFunc)g_str_hash, + (GEqualFunc)g_str_equal, + (GDestroyNotify)g_free, + (GDestroyNotify)g_variant_unref); +} + +/** + * gsignond_dictionary_ref: + * @dict: instance of #GSignondDictionary + * + * Increment reference count of the dictionary structure. + */ +void +gsignond_dictionary_ref (GSignondDictionary *dict) +{ + g_return_if_fail (dict != NULL); + + g_hash_table_ref (dict); +} + +/** + * gsignond_dictionary_unref: + * @dict: instance of #GSignondDictionary + * + * Decrement reference count of the dictionary structure. + * + */ +void +gsignond_dictionary_unref (GSignondDictionary *dict) +{ + if (!dict) + return; + + g_hash_table_unref (dict); +} + +/** + * gsignond_dictionary_get: + * @dict: instance of #GSignondDictionary + * + * Retrieves a value from the dictionary. + * + * Returns: (transfer none) the value; NULL is returned in case of failure. + */ +GVariant * +gsignond_dictionary_get (GSignondDictionary *dict, const gchar *key) +{ + g_return_val_if_fail (dict != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + return g_hash_table_lookup (dict, key); +} + +/** + * gsignond_dictionary_set: + * @dict: instance of #GSignondDictionary + * + * @key: key to be set + * @value: value to be set + * + * Adds or replaces key-value pair in the dictionary. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_dictionary_set (GSignondDictionary *dict, + const gchar *key, GVariant *value) +{ + g_return_val_if_fail (dict != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + g_variant_ref_sink(value); + g_hash_table_replace ( + dict, + g_strdup(key), + value); + + return TRUE; +} + +/** + * gsignond_dictionary_get_boolean: + * + * Overload, see #gsignond_dictionary_get for details. + */ +gboolean +gsignond_dictionary_get_boolean (GSignondDictionary *dict, const gchar *key, + gboolean *value) +{ + GVariant *variant = gsignond_dictionary_get (dict, key); + + if (variant == NULL) + return FALSE; + + if (value) + *value = g_variant_get_boolean (variant); + return TRUE; +} + +/** + * gsignon_dictionary_set_boolean: + * + * Overload, see #gsignond_dictionary_set for details. + */ +gboolean +gsignond_dictionary_set_boolean (GSignondDictionary *dict, const gchar *key, + gboolean value) +{ + return gsignond_dictionary_set (dict, key, g_variant_new_boolean (value)); +} + +/** + * gsignond_dictionary_get_int32: + * + * Overload, see #gsignond_dictionary_get for details. + */ +gboolean +gsignond_dictionary_get_int32 (GSignondDictionary *dict, const gchar *key, + gint32 *value) +{ + GVariant *variant = gsignond_dictionary_get (dict, key); + + if (variant == NULL) + return FALSE; + + if (value) + *value = g_variant_get_int32 (variant); + return TRUE; +} + +/** + * gsignon_dictionary_set_int32: + * + * Overload, see #gsignond_dictionary_set for details. + */ +gboolean +gsignond_dictionary_set_int32 (GSignondDictionary *dict, const gchar *key, + gint32 value) +{ + return gsignond_dictionary_set (dict, key, g_variant_new_int32 (value)); +} + +/** + * gsignond_dictionary_get_guint32: + * + * Overload, see #gsignond_dictionary_get for details. + */ +gboolean +gsignond_dictionary_get_uint32 (GSignondDictionary *dict, const gchar *key, + guint32 *value) +{ + GVariant *variant = gsignond_dictionary_get (dict, key); + + if (variant == NULL) + return FALSE; + + if (value) + *value = g_variant_get_uint32 (variant); + return TRUE; +} + +/** + * gsignon_dictionary_set_guint32: + * + * Overload, see #gsignond_dictionary_set for details. + */ +gboolean +gsignond_dictionary_set_uint32 (GSignondDictionary *dict, const gchar *key, + guint32 value) +{ + return gsignond_dictionary_set (dict, key, g_variant_new_uint32 (value)); +} + +/** + * gsignond_dictionary_get_int64: + * + * Overload, see #gsignond_dictionary_get for details. + */ +gboolean +gsignond_dictionary_get_int64 (GSignondDictionary *dict, const gchar *key, + gint64 *value) +{ + GVariant *variant = gsignond_dictionary_get (dict, key); + + if (variant == NULL) + return FALSE; + + if (value) + *value = g_variant_get_int64 (variant); + return TRUE; +} + +/** + * gsignon_dictionary_set_int32: + * + * Overload, see #gsignond_dictionary_set for details. + */ +gboolean +gsignond_dictionary_set_int64 (GSignondDictionary *dict, const gchar *key, + gint64 value) +{ + return gsignond_dictionary_set (dict, key, g_variant_new_int64 (value)); +} + +/** + * gsignond_dictionary_get_guint32: + * + * Overload, see #gsignond_dictionary_get for details. + */ +gboolean +gsignond_dictionary_get_uint64 (GSignondDictionary *dict, const gchar *key, + guint64 *value) +{ + GVariant *variant = gsignond_dictionary_get (dict, key); + + if (variant == NULL) + return FALSE; + + if (value) + *value = g_variant_get_uint64 (variant); + return TRUE; +} + +/** + * gsignon_dictionary_set_guint32: + * + * Overload, see #gsignond_dictionary_set for details. + */ +gboolean +gsignond_dictionary_set_uint64 (GSignondDictionary *dict, const gchar *key, + guint64 value) +{ + return gsignond_dictionary_set (dict, key, g_variant_new_uint64 (value)); +} + + +/** + * gsignond_dictionary_get_string: + * + * Overload, see #gsignond_dictionary_get for details. + */ +const gchar * +gsignond_dictionary_get_string (GSignondDictionary *dict, const gchar *key) +{ + GVariant *variant = gsignond_dictionary_get (dict, key); + + if (variant == NULL) + return NULL; + + return g_variant_get_string (variant, NULL); +} + +/** + * gsignon_dictionary_set_string: + * + * Overload, see #gsignond_dictionary_set for details. + */ +gboolean +gsignond_dictionary_set_string (GSignondDictionary *dict, const gchar *key, + const gchar *value) +{ + return gsignond_dictionary_set (dict, key, g_variant_new_string (value)); +} + +/** + * gsignond_dictionary_remove: + * @dict: instance of #GSignondDictionary + * + * @key: key which needs to be removed from the dictionary + * @value: value to be set + * + * Removes key-value pair in the dictionary as per key. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_dictionary_remove (GSignondDictionary *dict, const gchar *key) +{ + g_return_val_if_fail (dict != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); + + return g_hash_table_remove ( + dict, + key); +} + +/** + * gsignond_dictionary_copy: + * @other: instance of #GSignondDictionary + * + * Creates a copy of the dictionary. + * + * Returns: (transfer full) #GSignondDictionary object if successful, + * NULL otherwise. + */ +GSignondDictionary * +gsignond_dictionary_copy (GSignondDictionary *other) +{ + GSignondDictionary *dict = NULL; + GHashTableIter iter; + gchar *key = NULL; + GVariant *value = NULL; + + g_return_val_if_fail (other != NULL, NULL); + + dict = gsignond_dictionary_new (); + + g_hash_table_iter_init (&iter, other); + while (g_hash_table_iter_next (&iter, + (gpointer)&key, + (gpointer)&value)) + { + gsignond_dictionary_set (dict, key, value); + } + + + return dict; +} diff --git a/src/common/gsignond-disposable.c b/src/common/gsignond-disposable.c new file mode 100644 index 0000000..f5bb9fe --- /dev/null +++ b/src/common/gsignond-disposable.c @@ -0,0 +1,269 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2013 Intel Corporation. + * + * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "gsignond-disposable.h" +#include "gsignond/gsignond-log.h" + +struct _GSignondDisposablePrivate +{ + guint timeout; /* timeout in seconds */ + volatile gint keep_obj_counter; /* keep object request counter */ + guint timer_id; /* timer source id */ +}; + +enum { + PROP_0, + PROP_TIMEOUT, + PROP_AUTO_DISPOSE, + PROP_MAX, +}; + +enum { + SIG_DISPOSING, + SIG_MAX +}; + +static GParamSpec *properties[PROP_MAX]; +static guint signals[SIG_MAX]; + +#define GSIGNOND_DISPOSABLE_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_DISPOSABLE, GSignondDisposablePrivate) + +G_DEFINE_ABSTRACT_TYPE (GSignondDisposable, gsignond_disposable, G_TYPE_OBJECT); + +static void +_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + g_return_if_fail (object && GSIGNOND_IS_DISPOSABLE (object)); + + GSignondDisposable *self = GSIGNOND_DISPOSABLE (object); + + switch (property_id) { + case PROP_TIMEOUT: + gsignond_disposable_set_timeout (self, g_value_get_uint (value)); + break; + case PROP_AUTO_DISPOSE: + gsignond_disposable_set_auto_dispose (self, g_value_get_boolean (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + g_return_if_fail (object && GSIGNOND_IS_DISPOSABLE (object)); + + GSignondDisposable *self = GSIGNOND_DISPOSABLE (object); + + switch (property_id) { + case PROP_TIMEOUT: + g_value_set_int (value, self->priv->timeout); + break; + case PROP_AUTO_DISPOSE: + g_value_set_boolean (value, gsignond_disposable_get_auto_dispose(self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +_dispose (GObject *object) +{ + g_return_if_fail (object && GSIGNOND_IS_DISPOSABLE (object)); + + GSignondDisposable *self = GSIGNOND_DISPOSABLE (object); + + DBG ("%s DISPOSE", G_OBJECT_TYPE_NAME (self)); + if (self->priv->timer_id) { + DBG (" - TIMER CLEAR"); + g_source_remove (self->priv->timer_id); + self->priv->timer_id = 0; + } + + G_OBJECT_CLASS (gsignond_disposable_parent_class)->dispose (object); +} + +static void +_finalize (GObject *object) +{ + g_return_if_fail (object && GSIGNOND_IS_DISPOSABLE (object)); + + DBG ("FINALIZE"); + G_OBJECT_CLASS (gsignond_disposable_parent_class)->finalize (object); +} + +static void +gsignond_disposable_class_init (GSignondDisposableClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (GSignondDisposablePrivate)); + + object_class->set_property = _set_property; + object_class->get_property = _get_property; + object_class->dispose = _dispose; + object_class->finalize = _finalize; + + properties[PROP_TIMEOUT] = + g_param_spec_uint ("timeout", + "Object timeout", + "object timeout", + 0, + G_MAXUINT, + 0, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + properties[PROP_AUTO_DISPOSE] = + g_param_spec_boolean ("auto-dispose", + "Auto dispose", + "auto dispose", + TRUE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, PROP_MAX, properties); + + signals[SIG_DISPOSING] = g_signal_new ("disposing", + GSIGNOND_TYPE_DISPOSABLE, + G_SIGNAL_RUN_FIRST| G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + 0, + NULL, NULL, + NULL, + G_TYPE_NONE, + 0, + G_TYPE_NONE); +} + +static void +gsignond_disposable_init (GSignondDisposable *self) +{ + self->priv = GSIGNOND_DISPOSABLE_PRIV (self); + + self->priv->timer_id = 0; + self->priv->timeout = 0; + g_atomic_int_set(&self->priv->keep_obj_counter, 0); + + DBG ("INIT"); +} + +static gboolean +_auto_dispose (gpointer user_data) +{ + g_return_val_if_fail (user_data && GSIGNOND_IS_DISPOSABLE (user_data), FALSE); + + GSignondDisposable *self = GSIGNOND_DISPOSABLE (user_data); + g_signal_emit (self, signals[SIG_DISPOSING], 0); + /* destroy object */ + DBG ("%s AUTO DISPOSE", G_OBJECT_TYPE_NAME (self)); + g_object_unref (G_OBJECT (self)); + return FALSE; +} + +static gboolean +_timer_dispose (gpointer user_data) +{ + g_return_val_if_fail (user_data && GSIGNOND_IS_DISPOSABLE (user_data), FALSE); + GSignondDisposable *self = GSIGNOND_DISPOSABLE (user_data); + + DBG ("%s TIMER DISPOSE", G_OBJECT_TYPE_NAME (self)); + /* clear out timer since we are already inside timer cb */ + self->priv->timer_id = 0; + + return _auto_dispose (user_data); +} + +static void +_update_timer (GSignondDisposable *self) +{ + DBG("%s (%p): keep_obj_counter : %d, timeout : %d", + G_OBJECT_TYPE_NAME(self), + self, + self->priv->keep_obj_counter, + self->priv->timeout); + if (g_atomic_int_get(&self->priv->keep_obj_counter) == 0) { + if (self->priv->timeout) { + DBG("Setting object timeout to %d", self->priv->timeout); + self->priv->timer_id = g_timeout_add_seconds (self->priv->timeout, + _timer_dispose, + self); + } + } + else if (self->priv->timer_id) { + g_source_remove (self->priv->timer_id); + self->priv->timer_id = 0; + } +} + +void +gsignond_disposable_set_auto_dispose (GSignondDisposable *self, + gboolean dispose) +{ + g_return_if_fail (self && GSIGNOND_IS_DISPOSABLE (self)); + + if (g_atomic_int_get(&self->priv->keep_obj_counter) == 0 && dispose) return; + + g_atomic_int_add (&self->priv->keep_obj_counter, !dispose ? +1 : -1); + + _update_timer (self); +} + +void +gsignond_disposable_set_timeout (GSignondDisposable *self, + guint timeout) +{ + g_return_if_fail (self && GSIGNOND_IS_DISPOSABLE (self)); + + if (self->priv->timeout == timeout) return; + + self->priv->timeout = timeout; + + _update_timer (self); +} + +void +gsignond_disposable_delete_later (GSignondDisposable *self) +{ + if (self->priv->timer_id) + g_source_remove (self->priv->timer_id); + + INFO ("Object '%s' (%p) about to dispose...", + G_OBJECT_TYPE_NAME (self), self); + self->priv->timer_id = g_idle_add (_auto_dispose, self); +} + +gboolean +gsignond_disposable_get_auto_dispose (GSignondDisposable *self) +{ + g_return_val_if_fail (self && GSIGNOND_IS_DISPOSABLE(self), FALSE); + + return g_atomic_int_get(&self->priv->keep_obj_counter) == 0 ; +} diff --git a/src/common/gsignond-disposable.h b/src/common/gsignond-disposable.h new file mode 100644 index 0000000..d831a98 --- /dev/null +++ b/src/common/gsignond-disposable.h @@ -0,0 +1,76 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2013 Intel Corporation. + * + * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef __GSIGNOND_DISPOSABLE_H_ +#define __GSIGNOND_DISPOSABLE_H_ + +#include <glib.h> +#include <glib-object.h> + +G_BEGIN_DECLS + +#define GSIGNOND_TYPE_DISPOSABLE (gsignond_disposable_get_type()) +#define GSIGNOND_DISPOSABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_DISPOSABLE, GSignondDisposable)) +#define GSIGNOND_DISPOSABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_DISPOSABLE, GSignondDisposableClass)) +#define GSIGNOND_IS_DISPOSABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_DISPOSABLE)) +#define GSIGNOND_IS_DISPOSABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_DISPOSABLE)) +#define GSIGNOND_DISPOSABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_DISPOSABLE, GSignondDisposableClass)) + +typedef struct _GSignondDisposable GSignondDisposable; +typedef struct _GSignondDisposableClass GSignondDisposableClass; +typedef struct _GSignondDisposablePrivate GSignondDisposablePrivate; + +struct _GSignondDisposable +{ + GObject parent; + + /* priv */ + GSignondDisposablePrivate *priv; +}; + +struct _GSignondDisposableClass +{ + GObjectClass parent_class; +}; + +GType gsignond_disposable_get_type (void) G_GNUC_CONST; + +void +gsignond_disposable_set_auto_dispose (GSignondDisposable *disposable, + gboolean dispose); + +gboolean +gsignond_disposable_get_auto_dispose (GSignondDisposable *disposable); + +void +gsignond_disposable_set_timeout (GSignondDisposable *self, + guint timeout); + +void +gsignond_disposable_delete_later (GSignondDisposable *self); + +G_END_DECLS + +#endif /* __GSIGNOND_DISPOSABLE_H_ */ diff --git a/src/common/gsignond-enum.c.template b/src/common/gsignond-enum.c.template new file mode 100644 index 0000000..6391b95 --- /dev/null +++ b/src/common/gsignond-enum.c.template @@ -0,0 +1,32 @@ +/*** BEGIN file-header ***/ +/*** END file-header ***/ +/*** BEGIN file-production ***/ +/* enumerations from "@filename@" */ +#include "@filename@" + +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static GType the_type = 0; + + if (the_type == 0) { + static const G@Type@Value values[] = { +/*** END value-header ***/ +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ +/*** BEGIN value-tail ***/ + {0, NULL, NULL} + }; + + the_type = g_@type@_register_static ( + g_intern_static_string ("GSignond@EnumName@"), + values); + } + + return the_type; +} +/*** END value-tail ***/ diff --git a/src/common/gsignond-enum.h.template b/src/common/gsignond-enum.h.template new file mode 100644 index 0000000..5088101 --- /dev/null +++ b/src/common/gsignond-enum.h.template @@ -0,0 +1,16 @@ +/*** BEGIN file-header ***/ +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* Enumeration from "@filename@" */ + +/*** END file-production ***/ + +/*** BEGIN enumeration-production ***/ +#define GSIGNOND_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) +GType @enum_name@_get_type (void) G_GNUC_CONST; + +/*** END enumeration-production ***/ + +/*** BEGIN file-tail ***/ +/*** END file-tail ***/ diff --git a/src/common/gsignond-error.c b/src/common/gsignond-error.c new file mode 100644 index 0000000..462b43c --- /dev/null +++ b/src/common/gsignond-error.c @@ -0,0 +1,158 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "gsignond/gsignond-error.h" +#include <string.h> +#include <gio/gio.h> + +#define _ERROR_PREFIX "com.google.code.AccountsSSO.gSingleSignOn.Error" + +GDBusErrorEntry _gsignond_errors[] = +{ + {GSIGNOND_ERROR_UNKNOWN, _ERROR_PREFIX".Unknown"}, + {GSIGNOND_ERROR_INTERNAL_SERVER, _ERROR_PREFIX".InternalServerError"}, + {GSIGNOND_ERROR_INTERNAL_COMMUNICATION, _ERROR_PREFIX".InternalCommunicationError"}, + {GSIGNOND_ERROR_PERMISSION_DENIED, _ERROR_PREFIX".PermissionDenied"}, + {GSIGNOND_ERROR_ENCRYPTION_FAILURE, _ERROR_PREFIX".EncryptionFailure"}, + + {GSIGNOND_ERROR_METHOD_NOT_KNOWN, _ERROR_PREFIX".MethodNotKnown"}, + {GSIGNOND_ERROR_SERVICE_NOT_AVAILABLE, _ERROR_PREFIX".ServiceNotAvailable"}, + {GSIGNOND_ERROR_INVALID_QUERY, _ERROR_PREFIX".InvalidQuery"}, + + {GSIGNOND_ERROR_METHOD_NOT_AVAILABLE, _ERROR_PREFIX".MethodNotAvailable"}, + {GSIGNOND_ERROR_IDENTITY_NOT_FOUND, _ERROR_PREFIX".IdentityNotFound"}, + {GSIGNOND_ERROR_STORE_FAILED, _ERROR_PREFIX".IdentityStoreFailed"}, + {GSIGNOND_ERROR_REMOVE_FAILED, _ERROR_PREFIX".IdentityRemoveFailed"}, + {GSIGNOND_ERROR_SIGN_OUT_FAILED, _ERROR_PREFIX".SignOutFailed"}, + {GSIGNOND_ERROR_IDENTITY_OPERATION_CANCELED, _ERROR_PREFIX".OperationCancled"}, + {GSIGNOND_ERROR_CREDENTIALS_NOT_AVAILABLE, _ERROR_PREFIX".CredentialsNotAvailable"}, + {GSIGNOND_ERROR_REFERENCE_NOT_FOUND, _ERROR_PREFIX".ReferenceNotFound"}, + + {GSIGNOND_ERROR_MECHANISM_NOT_AVAILABLE, _ERROR_PREFIX".MechanismNotAvailable"}, + {GSIGNOND_ERROR_MISSING_DATA, _ERROR_PREFIX".MissingData"}, + {GSIGNOND_ERROR_INVALID_CREDENTIALS, _ERROR_PREFIX".InvalidCredentials"}, + {GSIGNOND_ERROR_NOT_AUTHORIZED, _ERROR_PREFIX".NotAutherized"}, + {GSIGNOND_ERROR_WRONG_STATE, _ERROR_PREFIX".WrongState"}, + {GSIGNOND_ERROR_OPERATION_NOT_SUPPORTED, _ERROR_PREFIX".OperationNotSupported"}, + {GSIGNOND_ERROR_NO_CONNECTION, _ERROR_PREFIX".NoConnection"}, + {GSIGNOND_ERROR_NETWORK, _ERROR_PREFIX".NoNetwork"}, + {GSIGNOND_ERROR_SSL, _ERROR_PREFIX".SSLError"}, + {GSIGNOND_ERROR_RUNTIME, _ERROR_PREFIX".RuntimeError"}, + {GSIGNOND_ERROR_SESSION_CANCELED, _ERROR_PREFIX".Cancled"}, + {GSIGNOND_ERROR_TIMED_OUT, _ERROR_PREFIX".TimedOut"}, + {GSIGNOND_ERROR_USER_INTERACTION, _ERROR_PREFIX".UserInteractionFailed"}, + {GSIGNOND_ERROR_OPERATION_FAILED, _ERROR_PREFIX".OperationFailed"}, + {GSIGNOND_ERROR_ENCRYPTION_FAILED, _ERROR_PREFIX".EncryptionFailed"}, + {GSIGNOND_ERROR_TOS_NOT_ACCEPTED, _ERROR_PREFIX".TOSNotAccepted"}, + + {GSIGNOND_ERROR_FORGOT_PASSWORD, _ERROR_PREFIX".ForgotPassword"}, + {GSIGNOND_ERROR_METHOD_OR_MECHANISM_NOT_ALLOWED, _ERROR_PREFIX".MethodOrMechanismNotAllowed"}, + {GSIGNOND_ERROR_INCORRECT_DATE, _ERROR_PREFIX".IncorrectDate"}, +} ; + +GQuark +gsignond_error_quark (void) +{ + static volatile gsize quark_volatile = 0; + + g_dbus_error_register_error_domain (GSIGNOND_ERROR_DOMAIN, + &quark_volatile, + _gsignond_errors, + G_N_ELEMENTS (_gsignond_errors)); + + return (GQuark) quark_volatile; +} + +GString* +gsignond_concat_domain_and_error ( + const gchar *str1, + const gchar *str2) +{ + GString *str = NULL; + g_return_val_if_fail (str1 != NULL && str2 != NULL, NULL); + str = g_string_sized_new (strlen(str1)+strlen(str2)-1); + g_string_printf (str,"[%s].%s\n",str1,str2); + return str; +} + +GString* +gsignond_prepend_domain_to_error_msg (const GError *err) +{ + GString *msg = NULL; + const gchar *domain = NULL; + g_return_val_if_fail (err != NULL, NULL); + if (err->message != NULL) { + domain = g_quark_to_string(err->domain); + msg = gsignond_concat_domain_and_error(domain, err->message); + } + return msg; +} + +/** + * gsignond_error_new_from_variant: + * @var: instance of #GVariant + * + * Converts the GVariant to GError. + * + * Returns: (transfer full) #GError object if successful, NULL otherwise. + */ +GError * +gsignond_error_new_from_variant ( + GVariant *var) +{ + GError *error = NULL; + gchar *message; + GQuark domain; + gint code; + + if (!var) { + return NULL; + } + + g_variant_get (var, "(uis)", &domain, &code, &message); + error = g_error_new_literal (domain, code, message); + g_free (message); + return error; +} + +/** + * gsignond_error_to_variant: + * @error: instance of #GError + * + * Converts the GError to GVariant. + * + * Returns: (transfer full) #GVariant object if successful, NULL otherwise. + */ +GVariant * +gsignond_error_to_variant ( + GError *error) +{ + if (!error) { + return NULL; + } + + return g_variant_new ("(uis)", error->domain, error->code, error->message); +} + diff --git a/src/common/gsignond-extension-interface.c b/src/common/gsignond-extension-interface.c new file mode 100644 index 0000000..45362b4 --- /dev/null +++ b/src/common/gsignond-extension-interface.c @@ -0,0 +1,239 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Jussi Laako <jussi.laako@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "gsignond/gsignond-extension-interface.h" + +G_DEFINE_TYPE (GSignondExtension, gsignond_extension, G_TYPE_OBJECT); + +#define GSIGNOND_EXTENSION_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_EXTENSION, GSignondExtensionPrivate) + +struct _GSignondExtensionPrivate +{ + GSignondAccessControlManager *access_control_manager; + GSignondStorageManager *storage_manager; + GSignondSecretStorage *secret_storage; +}; + +static void +_dispose (GObject *object) +{ + GSignondExtensionPrivate *priv = GSIGNOND_EXTENSION (object)->priv; + + g_clear_object (&priv->access_control_manager); + g_clear_object (&priv->secret_storage); + g_clear_object (&priv->storage_manager); + + G_OBJECT_CLASS (gsignond_extension_parent_class)->dispose (object); +} + +static const gchar * +_get_extension_name (GSignondExtension *self) +{ + (void) self; + + return "default"; +} + +static guint32 +_get_extension_version (GSignondExtension *self) +{ + (void) self; + + return 0; +} + +static GSignondStorageManager * +_get_storage_manager (GSignondExtension *self, GSignondConfig *config) +{ + g_return_val_if_fail (self && GSIGNOND_IS_EXTENSION (self), NULL); + + GSignondExtensionPrivate *priv = self->priv; + + if (!priv->storage_manager) { + priv->storage_manager = + g_object_new (GSIGNOND_TYPE_STORAGE_MANAGER, + "config", config, NULL); + } + + return priv->storage_manager; +} + +static GSignondSecretStorage * +_get_secret_storage (GSignondExtension *self, GSignondConfig *config) +{ + g_return_val_if_fail (self && GSIGNOND_IS_EXTENSION (self), NULL); + + GSignondExtensionPrivate *priv = self->priv; + + if (!priv->secret_storage) { + priv->secret_storage = + g_object_new (GSIGNOND_TYPE_SECRET_STORAGE, + "config", config, NULL); + } + + return priv->secret_storage; +} + +static GSignondAccessControlManager * +_get_access_control_manager (GSignondExtension *self, GSignondConfig *config) +{ + g_return_val_if_fail (self && GSIGNOND_IS_EXTENSION (self), NULL); + + GSignondExtensionPrivate *priv = self->priv; + + if (!priv->access_control_manager) { + priv->access_control_manager = + g_object_new (GSIGNOND_TYPE_ACCESS_CONTROL_MANAGER, + "config", config, NULL); + } + + return priv->access_control_manager; +} + +static void +gsignond_extension_class_init (GSignondExtensionClass *klass) +{ + GObjectClass *g_klass = G_OBJECT_CLASS (klass); + + g_type_class_add_private (g_klass, sizeof (GSignondExtensionPrivate)); + + g_klass->dispose = _dispose; + klass->get_extension_name = _get_extension_name; + klass->get_extension_version = _get_extension_version; + klass->get_storage_manager = _get_storage_manager; + klass->get_secret_storage = _get_secret_storage; + klass->get_access_control_manager = _get_access_control_manager; +} + +static void +gsignond_extension_init (GSignondExtension *self) +{ + self->priv = GSIGNOND_EXTENSION_PRIV (self); + + self->priv->access_control_manager = NULL; + self->priv->storage_manager = NULL; + self->priv->secret_storage = NULL; +} + +static void +_on_extension_dispose (gpointer data, GObject *object) +{ + if (data) *(GSignondExtension **)data = NULL; +} + +GSignondExtension * default_extension_init () +{ + static GSignondExtension *default_extension = NULL; + + if (!default_extension) { + default_extension = + g_object_new (GSIGNOND_TYPE_EXTENSION, NULL); + + g_object_weak_ref (G_OBJECT (default_extension), + _on_extension_dispose, + &default_extension); + } + + return default_extension; +} + +/** + * gsignond_extension_get_name: + * @self: object instance. + * + * Get human readable name of the extension. + * + * Returns: (transfer none) name of the extension. + */ +const gchar * +gsignond_extension_get_name (GSignondExtension *self) +{ + return GSIGNOND_EXTENSION_GET_CLASS (self)->get_extension_name (self); +} + +/** + * gsignond_extension_get_version: + * @self: object instance. + * + * Get version of the extension, split into four bytes in order from MSB to LSB; + * major, minor, patchlevel, build. + */ +guint32 +gsignond_extension_get_version (GSignondExtension *self) +{ + return GSIGNOND_EXTENSION_GET_CLASS (self)->get_extension_version (self); +} + +/** + * gsignond_extension_get_storage_manager: + * @self: object instance. + * @config: configuration object instance. + * + * Factory method to get a singleton storage manager object. + * + * Returns: (transfer none) storage manager object instance. + */ +GSignondStorageManager * +gsignond_extension_get_storage_manager (GSignondExtension *self, + GSignondConfig *config) +{ + return GSIGNOND_EXTENSION_GET_CLASS (self)-> + get_storage_manager (self, config); +} + +/** + * gsignond_extension_get_secret_storage: + * @self: object instance. + * @config: configuration object instance. + * + * Factory method to get a singleton secret storage object. + * + * Returns: (transfer none) secret storage object instance. + */ +GSignondSecretStorage * +gsignond_extension_get_secret_storage (GSignondExtension *self, + GSignondConfig *config) +{ + return GSIGNOND_EXTENSION_GET_CLASS (self)-> + get_secret_storage (self, config); +} + +/** + * gsignond_extension_get_access_control_manager: + * @self: object instance. + * @config: configuration object instance. + * + * Factory method to get a singleton access control manager object. + * + * Returns: (transfer none) access control manager object instance. + */ +GSignondAccessControlManager * +gsignond_extension_get_access_control_manager (GSignondExtension *self, + GSignondConfig *config) +{ + return GSIGNOND_EXTENSION_GET_CLASS (self)-> + get_access_control_manager (self, config); +} + diff --git a/src/common/gsignond-identity-info-internal.h b/src/common/gsignond-identity-info-internal.h new file mode 100644 index 0000000..2375cbe --- /dev/null +++ b/src/common/gsignond-identity-info-internal.h @@ -0,0 +1,55 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef __GSIGNOND_IDENTITY_INFO_INTERNAL_H__ +#define __GSIGNOND_IDENTITY_INFO_INTERNAL_H__ + +#include <glib.h> +#include <gsignond/gsignond-identity-info.h> + +G_BEGIN_DECLS + +#define GSIGNOND_IDENTITY_INFO_NEW_IDENTITY 0 + +/* + * Identity info strings + * */ +#define GSIGNOND_IDENTITY_INFO_ID "Id" +#define GSIGNOND_IDENTITY_INFO_USERNAME "UserName" +#define GSIGNOND_IDENTITY_INFO_SECRET "Secret" +#define GSIGNOND_IDENTITY_INFO_STORESECRET "StoreSecret" +#define GSIGNOND_IDENTITY_INFO_CAPTION "Caption" +#define GSIGNOND_IDENTITY_INFO_REALMS "Realms" +#define GSIGNOND_IDENTITY_INFO_AUTHMETHODS "AuthMethods" +#define GSIGNOND_IDENTITY_INFO_OWNER "Owner" +#define GSIGNOND_IDENTITY_INFO_ACL "ACL" +#define GSIGNOND_IDENTITY_INFO_TYPE "Type" +#define GSIGNOND_IDENTITY_INFO_REFCOUNT "RefCount" +#define GSIGNOND_IDENTITY_INFO_VALIDATED "Validated" +#define GSIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET "UserNameSecret" + +G_END_DECLS + +#endif /* __GSIGNOND_IDENTITY_INFO_INTERNAL_H__ */ diff --git a/src/common/gsignond-identity-info.c b/src/common/gsignond-identity-info.c new file mode 100644 index 0000000..9e41a41 --- /dev/null +++ b/src/common/gsignond-identity-info.c @@ -0,0 +1,1132 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012-2013 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <gsignond/gsignond-identity-info.h> +#include "gsignond-identity-info-internal.h" + + +static gboolean +_gsignond_identity_info_seq_cmp ( + GSequence *one, + GSequence *two) +{ + GSequenceIter *iter1 = NULL, *iter2 = NULL; + gboolean equal = TRUE; + + if (one == NULL && two == NULL) + return TRUE; + + if ((one != NULL && two == NULL) || + (one == NULL && two != NULL) || + (g_sequence_get_length (one) != g_sequence_get_length (two))) + return FALSE; + + if (one == two) + return TRUE; + + iter1 = g_sequence_get_begin_iter (one); + while (!g_sequence_iter_is_end (iter1)) { + iter2 = g_sequence_get_iter_at_pos (two, + g_sequence_iter_get_position (iter1)); + if (g_strcmp0 (g_sequence_get (iter1), g_sequence_get (iter2)) != 0) { + equal = FALSE; + break; + } + iter1 = g_sequence_iter_next (iter1); + } + + return equal; +} + +static gint +_compare_strings ( + const gchar* a, + const gchar* b, + gpointer data) +{ + (void)data; + return g_strcmp0 (a,b); +} + +static GVariant * +_gsignond_identity_info_sequence_to_variant (GSequence *seq) + +{ + GSequenceIter * iter = NULL; + GVariant *var = NULL; + GVariantBuilder builder; + + if (!seq) return NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY); + iter = g_sequence_get_begin_iter (seq); + while (!g_sequence_iter_is_end (iter)) { + const gchar * d = g_sequence_get (iter); + g_variant_builder_add (&builder, "s", d); + iter = g_sequence_iter_next (iter); + } + var = g_variant_builder_end (&builder); + return var; +} + +static GSequence * +_gsignond_identity_info_variant_to_sequence (GVariant *var) + +{ + GVariantIter iter; + GSequence *seq = NULL; + gchar *item = NULL; + + if (!var) return NULL; + + seq = g_sequence_new ((GDestroyNotify)g_free); + g_variant_iter_init (&iter, var); + while (g_variant_iter_next (&iter, "s", &item)) { + g_sequence_insert_sorted (seq, + item, + (GCompareDataFunc) _compare_strings, + NULL); + } + return seq; +} + +static gchar ** +_gsignond_identity_info_sequence_to_array (GSequence *seq) +{ + gchar **items, **temp; + GSequenceIter *iter; + + if (!seq) return NULL; + + items = g_malloc0 ((g_sequence_get_length (seq) + 1) * sizeof (gchar *)); + temp = items; + for (iter = g_sequence_get_begin_iter (seq); + iter != g_sequence_get_end_iter (seq); + iter = g_sequence_iter_next (iter)) { + *temp = g_sequence_get (iter); + temp++; + } + return items; +} + +static GSequence * +_gsignond_identity_info_array_to_sequence (gchar **items) + +{ + GSequence *seq = NULL; + + if (!items) return NULL; + + seq = g_sequence_new ((GDestroyNotify) g_free); + while (*items) { + g_sequence_insert_sorted (seq, + *items, + (GCompareDataFunc) _compare_strings, + NULL); + items++; + } + return seq; +} + +static gboolean +_gsignond_identity_info_sec_context_list_cmp ( + GSignondSecurityContextList *one, + GSignondSecurityContextList *two) +{ + GSignondSecurityContextList *list_elem1 = NULL, *list_elem2 = NULL; + gboolean equal = TRUE; + + if (one == NULL && two == NULL) + return TRUE; + + if ((one != NULL && two == NULL) || + (one == NULL && two != NULL) || + (g_list_length (one) != g_list_length (two))) + return FALSE; + + if (one == two) + return TRUE; + + list_elem1 = one; + for ( ; list_elem1 != NULL; list_elem1 = g_list_next (list_elem1)) { + list_elem2 = g_list_nth (two, g_list_position (one, list_elem1)); + if (!gsignond_security_context_match ( + (GSignondSecurityContext *)list_elem1->data, + (GSignondSecurityContext *)list_elem2->data)) { + equal = FALSE; + break; + } + } + + return equal; +} + +static gboolean +_gsignond_identity_info_methods_cmp ( + GHashTable *one, + GHashTable *two) +{ + GHashTableIter iter1; + GSequence *mechs1 = NULL, *mechs2 = NULL; + gchar *key = NULL; + gboolean equal = TRUE; + + if (one == NULL && two == NULL) + return TRUE; + + if ((one != NULL && two == NULL) || + (one == NULL && two != NULL) || + (g_hash_table_size (one) != g_hash_table_size (two))) + return FALSE; + + if (one == two) + return TRUE; + + g_hash_table_iter_init(&iter1, one); + while (g_hash_table_iter_next (&iter1, (gpointer *)&key, + (gpointer *)&mechs1)) { + mechs2 = (GSequence *)g_hash_table_lookup (two, key); + equal = _gsignond_identity_info_seq_cmp (mechs1, mechs2); + if (!equal) { + break; + } + } + + return equal; +} + +/** + * gsignond_identity_info_new: + * + * Creates new instance of GSignondIdentityInfo. + * + * Returns: (transfer full) #GSignondIdentityInfo object if successful, + * NULL otherwise. + */ +GSignondIdentityInfo * +gsignond_identity_info_new (void) +{ + GSignondIdentityInfo *info; + + info = gsignond_dictionary_new (); + gsignond_identity_info_set_id (info, GSIGNOND_IDENTITY_INFO_NEW_IDENTITY); + + return info; +} + +/** + * gsignond_identity_info_copy: + * @info: instance of #GSignondIdentityInfo + * + * Creates a copy of info structure. + * + * Returns: copy of the info. + */ +GSignondIdentityInfo * +gsignond_identity_info_copy (GSignondIdentityInfo *info) +{ + if (!info) + return NULL; + + return gsignond_dictionary_copy (info); +} + +/** + * gsignond_identity_info_ref: + * @info: instance of #GSignondIdentityInfo + * + * Increment reference count of the info structure. + */ +void +gsignond_identity_info_ref (GSignondIdentityInfo *info) +{ + g_return_if_fail (info != NULL); + + gsignond_dictionary_ref (info); +} + +/** + * gsignond_identity_info_unref: + * @info: instance of #GSignondIdentityInfo + * + * Decrement reference count of the info structure. + */ +void +gsignond_identity_info_unref (GSignondIdentityInfo *info) +{ + if (!info) + return; + + gsignond_dictionary_unref (info); +} + +/** + * gsignond_identity_info_get_id: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the id from the info. + * + * Returns: the id; negative id is returned in case of failure. + */ +guint32 +gsignond_identity_info_get_id (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_ID); + + g_return_val_if_fail (var != NULL, -1); + + return g_variant_get_uint32 (var); +} + +/** + * gsignond_identity_info_set_id: + * @info: instance of #GSignondIdentityInfo + * + * @id: id to be set + * + * Sets the id of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_id ( + GSignondIdentityInfo *info, + guint32 id) +{ + g_assert (info != NULL); + + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_ID, + g_variant_new_uint32 (id)); +} + +/** + * gsignond_identity_info_get_is_identity_new: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the info whether the identity is new or not. + * + * Returns: TRUE if new, FALSE otherwise. + */ +gboolean +gsignond_identity_info_get_is_identity_new (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + return GSIGNOND_IDENTITY_INFO_NEW_IDENTITY == + gsignond_identity_info_get_id (info); +} + +/** + * gsignond_identity_info_set_identity_new: + * @info: instance of #GSignondIdentityInfo + * + * Sets the id of the identity info to be new. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_identity_new ( + GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + return gsignond_identity_info_set_id ( + info, + GSIGNOND_IDENTITY_INFO_NEW_IDENTITY); +} + +/** + * gsignond_identity_info_get_username: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the username from the info. + * + * Returns: the username if successful, NULL otherwise. + */ +const gchar * +gsignond_identity_info_get_username (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_USERNAME); + if (var != NULL) { + return g_variant_get_string (var, NULL); + } + return NULL; +} + +/** + * gsignond_identity_info_set_username: + * @info: instance of #GSignondIdentityInfo + * + * @username: username to be set + * + * Sets the username of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_username ( + GSignondIdentityInfo *info, + const gchar *username) +{ + g_assert (info != NULL); + + if (!username) { + return gsignond_dictionary_remove (info, + GSIGNOND_IDENTITY_INFO_USERNAME); + } + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_USERNAME, + g_variant_new_string (username)); +} + +/** + * gsignond_identity_info_remove_username: + * @info: instance of #GSignondIdentityInfo + * + * Removes username from the info. + */ +void +gsignond_identity_info_remove_username (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + gsignond_dictionary_remove (info, GSIGNOND_IDENTITY_INFO_USERNAME); +} + +/** + * gsignond_identity_info_get_is_username_secret: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the is_username_secret flag from the info. + * + * Returns: the is_username_secret flag. + */ +gboolean +gsignond_identity_info_get_is_username_secret (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, + GSIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET); + if (var != NULL) { + return g_variant_get_boolean (var); + } + return FALSE; +} + +/** + * gsignond_identity_info_set_username_secret: + * @info: instance of #GSignondIdentityInfo + * + * @store_secret: store_secret to be set + * + * Sets the store_secret of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_username_secret ( + GSignondIdentityInfo *info, + gboolean username_secret) +{ + g_assert (info != NULL); + + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET, + g_variant_new_boolean(username_secret)); +} + +/** + * gsignond_identity_info_get_secret: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the secret from the info. + * + * Returns: the secret if successful, NULL otherwise. + */ +const gchar * +gsignond_identity_info_get_secret (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_SECRET); + if (var != NULL) { + return g_variant_get_string (var, NULL); + } + return NULL; +} + +/** + * gsignond_identity_info_set_secret: + * @info: instance of #GSignondIdentityInfo + * + * @secret: secret to be set + * + * Sets the secret of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_secret ( + GSignondIdentityInfo *info, + const gchar *secret) +{ + g_assert (info != NULL); + + if (!secret) { + return gsignond_dictionary_remove (info, + GSIGNOND_IDENTITY_INFO_SECRET); + } + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_SECRET, + g_variant_new_string (secret)); +} + +/** + * gsignond_identity_info_remove_secret: + * @info: instance of #GSignondIdentityInfo + * + * Removes secret from the info. + */ +void +gsignond_identity_info_remove_secret (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + gsignond_dictionary_remove (info, GSIGNOND_IDENTITY_INFO_SECRET); +} + +/** + * gsignond_identity_info_get_store_secret: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the store_secret flag from the info. + * + * Returns: the store_secret flag. + */ +gboolean +gsignond_identity_info_get_store_secret (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_STORESECRET); + if (var != NULL) { + return g_variant_get_boolean (var); + } + return FALSE; +} + +/** + * gsignond_identity_info_set_store_secret: + * @info: instance of #GSignondIdentityInfo + * + * @store_secret: store_secret to be set + * + * Sets the store_secret of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_store_secret ( + GSignondIdentityInfo *info, + gboolean store_secret) +{ + g_assert (info != NULL); + + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_STORESECRET, + g_variant_new_boolean(store_secret)); +} + +/** + * gsignond_identity_info_get_caption: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the caption from the info. + * + * Returns: the caption if successful, NULL otherwise. + */ +const gchar * +gsignond_identity_info_get_caption (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_CAPTION); + if (var != NULL) { + return g_variant_get_string (var, NULL); + } + return NULL; +} + +/** + * gsignond_identity_info_set_caption: + * @info: instance of #GSignondIdentityInfo + * + * @caption: caption to be set + * + * Sets the caption of the info. + * + * Returns: TRUE in case of success, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_caption ( + GSignondIdentityInfo *info, + const gchar *caption) +{ + g_assert (info != NULL); + + if (!caption) { + return gsignond_dictionary_remove (info, + GSIGNOND_IDENTITY_INFO_CAPTION); + } + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_CAPTION, + g_variant_new_string (caption)); +} + +/** + * gsignond_identity_info_get_realms: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the realms from the info. + * + * Returns: (transfer full) the realms if successful, NULL Otherwise. + * when done realms should be freed using g_sequence_free. + */ +GSequence * +gsignond_identity_info_get_realms (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_REALMS); + if (var != NULL) { + return _gsignond_identity_info_variant_to_sequence (var); + } + return NULL; +} + +/** + * gsignond_identity_info_set_realms: + * @info: instance of #GSignondIdentityInfo + * + * @realms: (transfer none) realms to be set + * + * Sets the realms of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_realms ( + GSignondIdentityInfo *info, + GSequence *realms) +{ + g_assert (info != NULL); + + g_return_val_if_fail (realms != NULL, FALSE); + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_REALMS, + _gsignond_identity_info_sequence_to_variant (realms)); +} + +/** + * gsignond_identity_info_get_methods: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the methods from the info whereas #GHashTable consists of + * <gchar*,GSequence*> and #GSequence is a sequence of gchar *. + * + * Returns: (transfer full) the methods if successful, NULL otherwise. + * when done, methods should be freed using g_hash_table_unref. + */ +GHashTable * +gsignond_identity_info_get_methods (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + GHashTable *methods = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_AUTHMETHODS); + if (var != NULL) { + GVariantIter iter; + gchar *vmethod; + gchar **vmechanisms = NULL; + GSequence *seq = NULL; + + methods = g_hash_table_new_full ((GHashFunc) g_str_hash, + (GEqualFunc) g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_sequence_free); + + g_variant_iter_init (&iter, var); + while (g_variant_iter_next (&iter, "{s^as}", &vmethod, &vmechanisms)) + { + /* ownership of all content is transferred */ + seq = _gsignond_identity_info_array_to_sequence (vmechanisms); + g_hash_table_insert (methods, vmethod, seq); + g_free (vmechanisms); + } + } + return methods; +} + +/** + * gsignond_identity_info_set_methods: + * @info: instance of #GSignondIdentityInfo + * + * @methods: (transfer none) methods to be set whereas #GHashTable consists of + * <gchar*,#GSequence*> and #GSequence is a sequence of gchar *. + * + * Sets the methods of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_methods ( + GSignondIdentityInfo *info, + GHashTable *methods) +{ + g_assert (info != NULL); + + gchar **items = NULL; + GVariantBuilder builder; + + GHashTableIter iter; + const gchar *method; + GSequence *mechanisms = NULL; + + g_return_val_if_fail (info != NULL, FALSE); + g_return_val_if_fail (methods != NULL, FALSE); + + g_variant_builder_init (&builder, (const GVariantType *)"a{sas}"); + g_hash_table_iter_init (&iter, methods); + while (g_hash_table_iter_next (&iter, + (gpointer)&method, + (gpointer)&mechanisms)) + { + items = _gsignond_identity_info_sequence_to_array (mechanisms); + g_variant_builder_add (&builder, "{s^as}", method, items); + g_free (items); + } + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_AUTHMETHODS, + g_variant_builder_end (&builder)); +} + +/** + * gsignond_identity_info_get_mechanisms: + * @info: instance of #GSignondIdentityInfo + * + * @method: the method for which mechanisms are sought + * + * Retrieves the mechanisms from the info. + * + * Returns: (transfer full) the mechanisms if successful, NULL otherwise. + * when done, mechanisms should be freed using g_sequence_free; #GSequence is a + * sequence of gchar *. + */ +GSequence * +gsignond_identity_info_get_mechanisms ( + GSignondIdentityInfo *info, + const gchar *method) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + GSequence *mechanisms = NULL; + + g_return_val_if_fail (method != NULL, NULL); + + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_AUTHMETHODS); + if (var != NULL) { + GVariantIter iter; + gchar *vmethod; + gchar **vmechanisms; + + g_variant_iter_init (&iter, var); + while (g_variant_iter_next (&iter, "{s^as}", &vmethod, &vmechanisms)) + { + /* ownership of content is transferred */ + if (vmethod != NULL && g_strcmp0 (vmethod, method) == 0) { + mechanisms = _gsignond_identity_info_array_to_sequence ( + vmechanisms); + g_free (vmethod); + g_free (vmechanisms); + break; + } + g_free (vmethod); vmethod = NULL; + g_strfreev (vmechanisms); vmechanisms = NULL; + } + } + return mechanisms; +} + +/** + * gsignond_identity_info_remove_method: + * @info: instance of #GSignondIdentityInfo + * + * Removes the method from the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_remove_method ( + GSignondIdentityInfo *info, + const gchar *method) +{ + g_assert (info != NULL); + + GHashTable *methods = NULL; + gboolean ret = FALSE; + + g_return_val_if_fail (method != NULL, FALSE); + + methods = gsignond_identity_info_get_methods (info); + if (methods && g_hash_table_remove (methods, method)) { + ret = gsignond_identity_info_set_methods (info, methods); + } + if (methods) + g_hash_table_unref (methods); + return ret; +} + +/** + * gsignond_identity_info_get_access_control_list: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the access control list from the info. + * + * Returns: (transfer full) the list if successful, NULL otherwise. + * when done, list should be freed using gsignond_security_context_list_free. + */ +GSignondSecurityContextList * +gsignond_identity_info_get_access_control_list (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_ACL); + if (var != NULL) { + return gsignond_security_context_list_from_variant (var); + } + return NULL; +} + +/** + * gsignond_identity_info_set_access_control_list: + * @info: instance of #GSignondIdentityInfo + * + * @acl: (transfer none) access control list to be set + * + * Sets the access control list of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_access_control_list ( + GSignondIdentityInfo *info, + const GSignondSecurityContextList *acl) +{ + g_assert (info != NULL); + + g_return_val_if_fail (acl != NULL, FALSE); + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_ACL, + gsignond_security_context_list_to_variant (acl)); +} + +/** + * gsignond_identity_info_get_owner: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the id from the info. + * + * Returns: (transfer full) the owner if successful, NULL otherwise. + * when done, owner list should be freed using + * gsignond_security_context_free. + */ +GSignondSecurityContext * +gsignond_identity_info_get_owner (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_OWNER); + if (var != NULL) { + return gsignond_security_context_from_variant (var); + } + return NULL; +} + +/** + * gsignond_identity_info_set_owner: + * @info: instance of #GSignondIdentityInfo + * + * @owners: (transfer none) owner to be set + * + * Sets the owner of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_owner ( + GSignondIdentityInfo *info, + const GSignondSecurityContext *owners) +{ + g_assert (info != NULL); + + g_return_val_if_fail (owners != NULL, FALSE); + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_OWNER, + gsignond_security_context_to_variant (owners)); +} + +/** + * gsignond_identity_info_get_validated: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the validated flag from the info. + * + * Returns: the validated flag. + */ +gboolean +gsignond_identity_info_get_validated (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_VALIDATED); + if (var != NULL) { + return g_variant_get_boolean (var); + } + return FALSE; +} + +/** + * gsignond_identity_info_set_validated: + * @info: instance of #GSignondIdentityInfo + * + * @validated: validated flag to be set + * + * Sets the validated flag of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_validated ( + GSignondIdentityInfo *info, + gboolean validated) +{ + g_assert (info != NULL); + + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_VALIDATED, + g_variant_new_boolean (validated)); +} + +/** + * gsignond_identity_info_get_identity_type: + * @info: instance of #GSignondIdentityInfo + * + * Retrieves the type from the info. + * + * Returns: the type; negative type is returned in case of failure. + */ +guint32 +gsignond_identity_info_get_identity_type (GSignondIdentityInfo *info) +{ + g_assert (info != NULL); + + GVariant *var = NULL; + var = gsignond_dictionary_get (info, GSIGNOND_IDENTITY_INFO_TYPE); + if (var != NULL) { + return g_variant_get_int32 (var); + } + return -1; +} + +/** + * gsignond_identity_info_set_identity_type: + * @info: instance of #GSignondIdentityInfo + * + * @type: type to be set + * + * Sets the type of the info. + * + * Returns: TRUE if successful, FALSE otherwise. + */ +gboolean +gsignond_identity_info_set_identity_type ( + GSignondIdentityInfo *info, + guint32 type) +{ + g_assert (info != NULL); + + return gsignond_dictionary_set ( + info, + GSIGNOND_IDENTITY_INFO_TYPE, + g_variant_new_int32 (type)); +} + +/** + * gsignond_identity_info_compare: + * @info: instance1 of #GSignondIdentityInfo + * + * @other: instance2 of #GSignondIdentityInfo + * + * Compares two instances of #GSignondIdentityInfo for equality. + * + * Returns: TRUE if the two instances are equal, FALSE otherwise. + */ +gboolean +gsignond_identity_info_compare ( + GSignondIdentityInfo *info, + GSignondIdentityInfo *other) +{ + g_assert (info != NULL && other != NULL); + + GSequence *info_realms = NULL, *other_realms = NULL; + GHashTable *info_methods = NULL, *other_methods = NULL; + GSignondSecurityContextList *info_acl = NULL, *other_acl = NULL; + GSignondSecurityContext *info_owner = NULL, *other_owner = NULL; + gboolean equal = FALSE; + + if (info == other) + return TRUE; + + if (info == NULL || other == NULL) + return FALSE; + + if (gsignond_identity_info_get_id (info) != + gsignond_identity_info_get_id (other)) { + return FALSE; + } + + if (g_strcmp0 (gsignond_identity_info_get_username (info), + gsignond_identity_info_get_username (other)) != 0) { + return FALSE; + } + + if (g_strcmp0 (gsignond_identity_info_get_secret (info), + gsignond_identity_info_get_secret (other)) != 0) { + return FALSE; + } + + if (gsignond_identity_info_get_store_secret (info) != + gsignond_identity_info_get_store_secret (other)) { + return FALSE; + } + + if (g_strcmp0 (gsignond_identity_info_get_caption (info), + gsignond_identity_info_get_caption (other)) != 0) { + return FALSE; + } + + info_realms = gsignond_identity_info_get_realms (info); + other_realms = gsignond_identity_info_get_realms (other); + equal = _gsignond_identity_info_seq_cmp (info_realms, other_realms); + if (info_realms) g_sequence_free (info_realms); + if (other_realms) g_sequence_free (other_realms); + if (!equal) { + return FALSE; + } + + info_methods = gsignond_identity_info_get_methods (info); + other_methods = gsignond_identity_info_get_methods (other); + equal = _gsignond_identity_info_methods_cmp (info_methods, other_methods); + if (info_methods) g_hash_table_unref (info_methods); + if (other_methods) g_hash_table_unref (other_methods); + if (!equal) { + return FALSE; + } + + info_acl = gsignond_identity_info_get_access_control_list (info); + if (info_acl) + info_acl = g_list_sort ( + info_acl, + (GCompareFunc)gsignond_security_context_compare); + other_acl = gsignond_identity_info_get_access_control_list (other); + if (other_acl) + other_acl = g_list_sort ( + other_acl, + (GCompareFunc)gsignond_security_context_compare); + equal = _gsignond_identity_info_sec_context_list_cmp (info_acl, other_acl); + if (info_acl) gsignond_security_context_list_free (info_acl); + if (other_acl) gsignond_security_context_list_free (other_acl); + if (!equal) { + return FALSE; + } + + info_owner = gsignond_identity_info_get_owner (info); + other_owner = gsignond_identity_info_get_owner (other); + equal = gsignond_security_context_match (info_owner, other_owner); + if (info_owner) gsignond_security_context_free (info_owner); + if (other_owner) gsignond_security_context_free (other_owner); + if (!equal) { + return FALSE; + } + + if (gsignond_identity_info_get_validated (info) != + gsignond_identity_info_get_validated (other)) { + return FALSE; + } + + if (gsignond_identity_info_get_identity_type (info) != + gsignond_identity_info_get_identity_type (other)) { + return FALSE; + } + + return TRUE; +} + +void +gsignond_identity_info_list_free (GSignondIdentityInfoList *list) +{ + g_return_if_fail (list != NULL); + g_list_free_full (list, (GDestroyNotify)gsignond_identity_info_unref); +} + diff --git a/src/common/gsignond-pipe-stream.c b/src/common/gsignond-pipe-stream.c new file mode 100644 index 0000000..c13d9b1 --- /dev/null +++ b/src/common/gsignond-pipe-stream.c @@ -0,0 +1,126 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2013 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#include <gio/gunixinputstream.h> +#include <gio/gunixoutputstream.h> + +#include "gsignond-pipe-stream.h" + +#define GSIGNOND_PIPE_STREAM_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ + GSIGNOND_TYPE_PIPE_STREAM, \ + GSignondPipeStreamPrivate)) + +struct _GSignondPipeStreamPrivate +{ + GInputStream *input_stream; + GOutputStream *output_stream; +}; + +G_DEFINE_TYPE (GSignondPipeStream, gsignond_pipe_stream, G_TYPE_IO_STREAM); + +static GInputStream * +_gsignond_pipe_stream_get_input_stream (GIOStream *io_stream) +{ + return GSIGNOND_PIPE_STREAM (io_stream)->priv->input_stream; +} + +static GOutputStream * +_gsignond_pipe_stream_get_output_stream (GIOStream *io_stream) +{ + return GSIGNOND_PIPE_STREAM (io_stream)->priv->output_stream; +} + +static void +_gsignond_pipe_stream_dispose (GObject *gobject) +{ + g_return_if_fail (GSIGNOND_IS_PIPE_STREAM (gobject)); + + /* Chain up to the parent class */ + G_OBJECT_CLASS (gsignond_pipe_stream_parent_class)->dispose (gobject); + +} + +static void +_gsignond_pipe_stream_finalize (GObject *gobject) +{ + GSignondPipeStream *stream = GSIGNOND_PIPE_STREAM (gobject); + + /* g_io_stream needs streams to be valid in its dispose still + */ + if (stream->priv->input_stream) { + g_clear_object (&stream->priv->input_stream); + stream->priv->input_stream = NULL; + } + + if (stream->priv->output_stream) { + g_clear_object (&stream->priv->output_stream); + stream->priv->output_stream = NULL; + } + + G_OBJECT_CLASS (gsignond_pipe_stream_parent_class)->finalize (gobject); +} + +static void +gsignond_pipe_stream_class_init (GSignondPipeStreamClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GIOStreamClass *stream_class = G_IO_STREAM_CLASS (klass); + + gobject_class->finalize = _gsignond_pipe_stream_finalize; + gobject_class->dispose = _gsignond_pipe_stream_dispose; + + /* virtual methods */ + stream_class->get_input_stream = _gsignond_pipe_stream_get_input_stream; + stream_class->get_output_stream = _gsignond_pipe_stream_get_output_stream; + + g_type_class_add_private (klass, sizeof (GSignondPipeStreamPrivate)); +} + +static void +gsignond_pipe_stream_init (GSignondPipeStream *self) +{ + self->priv = GSIGNOND_PIPE_STREAM_GET_PRIVATE (self); + self->priv->input_stream = NULL; + self->priv->output_stream = NULL; +} + +GSignondPipeStream * +gsignond_pipe_stream_new ( + gint in_fd, + gint out_fd, + gboolean close_fds) +{ + GSignondPipeStream *stream = GSIGNOND_PIPE_STREAM (g_object_new ( + GSIGNOND_TYPE_PIPE_STREAM, NULL)); + if (stream) { + stream->priv->input_stream = G_INPUT_STREAM ( + g_unix_input_stream_new (in_fd, close_fds)); + stream->priv->output_stream = G_OUTPUT_STREAM ( + g_unix_output_stream_new (out_fd, close_fds)); + } + return stream; +} + + diff --git a/src/common/gsignond-pipe-stream.h b/src/common/gsignond-pipe-stream.h new file mode 100644 index 0000000..6a1882e --- /dev/null +++ b/src/common/gsignond-pipe-stream.h @@ -0,0 +1,79 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2013 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef __GSIGNOND_PIPE_STREAM_H__ +#define __GSIGNOND_PIPE_STREAM_H__ + +#include <glib.h> +#include <glib-object.h> +#include <gio/gio.h> + +G_BEGIN_DECLS + +/* + * Type macros. + */ +#define GSIGNOND_TYPE_PIPE_STREAM (gsignond_pipe_stream_get_type ()) +#define GSIGNOND_PIPE_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + GSIGNOND_TYPE_PIPE_STREAM, \ + GSignondPipeStream)) +#define GSIGNOND_IS_PIPE_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + GSIGNOND_TYPE_PIPE_STREAM)) +#define GSIGNOND_PIPE_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ + GSIGNOND_TYPE_PIPE_STREAM, \ + GSignondPipeStreamClass)) +#define GSIGNOND_IS_PIPE_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ + GSIGNOND_TYPE_PIPE_STREAM)) +#define GSIGNOND_PIPE_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + GSIGNOND_TYPE_PIPE_STREAM, \ + GSignondPipeStreamClass)) + +typedef struct _GSignondPipeStreamPrivate GSignondPipeStreamPrivate; + +typedef struct { + GIOStream parent_instance; + + /*< private >*/ + GSignondPipeStreamPrivate *priv; +} GSignondPipeStream; + +typedef struct { + GIOStreamClass parent_class; + +} GSignondPipeStreamClass; + +/* used by GSIGNOND_TYPE_PIPE_STREAM */ +GType +gsignond_pipe_stream_get_type (void); + +GSignondPipeStream * +gsignond_pipe_stream_new ( + gint in_fd, + gint out_fd, + gboolean close_fds); + +G_END_DECLS + +#endif /* __GSIGNOND_PIPE_STREAM_H__ */ diff --git a/src/common/gsignond-plugin-enum-types.c b/src/common/gsignond-plugin-enum-types.c new file mode 100644 index 0000000..090f1fd --- /dev/null +++ b/src/common/gsignond-plugin-enum-types.c @@ -0,0 +1,39 @@ + +/* Generated data (by glib-mkenums) */ + +#include "gsignond-plugin-enum-types.h" +/* enumerations from "../../include/gsignond/gsignond-plugin-interface.h" */ +#include "../../include/gsignond/gsignond-plugin-interface.h" + +GType +gsignond_plugin_state_get_type (void) +{ + static GType the_type = 0; + + if (the_type == 0) { + static const GEnumValue values[] = { + { GSIGNOND_PLUGIN_STATE_NONE, "GSIGNOND_PLUGIN_STATE_NONE", "none" }, + { GSIGNOND_PLUGIN_STATE_RESOLVING, "GSIGNOND_PLUGIN_STATE_RESOLVING", "resolving" }, + { GSIGNOND_PLUGIN_STATE_CONNECTING, "GSIGNOND_PLUGIN_STATE_CONNECTING", "connecting" }, + { GSIGNOND_PLUGIN_STATE_SENDING_DATA, "GSIGNOND_PLUGIN_STATE_SENDING_DATA", "sending-data" }, + { GSIGNOND_PLUGIN_STATE_WAITING, "GSIGNOND_PLUGIN_STATE_WAITING", "waiting" }, + { GSIGNOND_PLUGIN_STATE_USER_PENDING, "GSIGNOND_PLUGIN_STATE_USER_PENDING", "user-pending" }, + { GSIGNOND_PLUGIN_STATE_REFRESHING, "GSIGNOND_PLUGIN_STATE_REFRESHING", "refreshing" }, + { GSIGNOND_PLUGIN_STATE_PROCESS_PENDING, "GSIGNOND_PLUGIN_STATE_PROCESS_PENDING", "process-pending" }, + { GSIGNOND_PLUGIN_STATE_STARTED, "GSIGNOND_PLUGIN_STATE_STARTED", "started" }, + { GSIGNOND_PLUGIN_STATE_CANCELING, "GSIGNOND_PLUGIN_STATE_CANCELING", "canceling" }, + { GSIGNOND_PLUGIN_STATE_DONE, "GSIGNOND_PLUGIN_STATE_DONE", "done" }, + { GSIGNOND_PLUGIN_STATE_HOLDING, "GSIGNOND_PLUGIN_STATE_HOLDING", "holding" }, + {0, NULL, NULL} + }; + + the_type = g_enum_register_static ( + g_intern_static_string ("GSignondPluginState"), + values); + } + + return the_type; +} + +/* Generated data ends here */ + diff --git a/src/common/gsignond-plugin-enum-types.h b/src/common/gsignond-plugin-enum-types.h new file mode 100644 index 0000000..a301213 --- /dev/null +++ b/src/common/gsignond-plugin-enum-types.h @@ -0,0 +1,21 @@ + +/* Generated data (by glib-mkenums) */ + +#ifndef GSIGNOND_PLUGIN_ENUM_TYPES_H_ +#define GSIGNOND_PLUGIND_ENUM_TYPES_H_ + +#include <glib-object.h> + +G_BEGIN_DECLS +/* Enumeration from "../../include/gsignond/gsignond-plugin-interface.h" */ + +#define GSIGNOND_TYPE_PLUGIN_STATE (gsignond_plugin_state_get_type()) +GType gsignond_plugin_state_get_type (void) G_GNUC_CONST; + + +G_END_DECLS + +#endif + +/* Generated data ends here */ + diff --git a/src/common/gsignond-plugin-interface.c b/src/common/gsignond-plugin-interface.c new file mode 100644 index 0000000..fa9d131 --- /dev/null +++ b/src/common/gsignond-plugin-interface.c @@ -0,0 +1,171 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + + +#include "gsignond/gsignond-plugin-interface.h" +#include "gsignond-plugin-enum-types.h" + +G_DEFINE_INTERFACE (GSignondPlugin, gsignond_plugin, 0) + +/* signals */ +enum +{ + RESPONSE, + RESPONSE_FINAL, + STORE, + ERROR, + USER_ACTION_REQUIRED, + REFRESHED, + STATUS_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +static void gsignond_plugin_default_init (GSignondPluginInterface *g_class) +{ + signals[RESPONSE] = g_signal_new ("response", G_TYPE_FROM_CLASS (g_class), + G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, + 1, GSIGNOND_TYPE_SESSION_DATA); + + signals[RESPONSE_FINAL] = g_signal_new ("response-final", G_TYPE_FROM_CLASS (g_class), + G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, + 1, GSIGNOND_TYPE_SESSION_DATA); + + signals[STORE] = g_signal_new ("store", G_TYPE_FROM_CLASS (g_class), + G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, + 1, GSIGNOND_TYPE_DICTIONARY); + + signals[ERROR] = g_signal_new ("error", G_TYPE_FROM_CLASS (g_class), + G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, + 1, G_TYPE_ERROR); + + signals[USER_ACTION_REQUIRED] = g_signal_new ("user-action-required", + G_TYPE_FROM_CLASS (g_class), + G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, + 1, GSIGNOND_TYPE_SIGNONUI_DATA); + + signals[REFRESHED] = g_signal_new ("refreshed", G_TYPE_FROM_CLASS (g_class), + G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, + 1, GSIGNOND_TYPE_SIGNONUI_DATA); + + signals[STATUS_CHANGED] = g_signal_new ("status-changed", + G_TYPE_FROM_CLASS (g_class), + G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE, + 2, GSIGNOND_TYPE_PLUGIN_STATE, G_TYPE_STRING); + + g_object_interface_install_property (g_class, g_param_spec_string ("type", + "Type", "Plugin type", "none", + G_PARAM_READABLE|G_PARAM_STATIC_STRINGS)); + + g_object_interface_install_property (g_class, g_param_spec_boxed ( + "mechanisms", "Mechanisms", "List of plugin mechanisms", + G_TYPE_STRV, G_PARAM_READABLE|G_PARAM_STATIC_STRINGS)); + +} + +void gsignond_plugin_cancel (GSignondPlugin *self) +{ + g_return_if_fail (GSIGNOND_IS_PLUGIN (self)); + + GSIGNOND_PLUGIN_GET_INTERFACE (self)->cancel (self); +} + +void gsignond_plugin_request_initial (GSignondPlugin *self, + GSignondSessionData *session_data, + const gchar *mechanism) +{ + g_return_if_fail (GSIGNOND_IS_PLUGIN (self)); + + GSIGNOND_PLUGIN_GET_INTERFACE (self)->request_initial (self, session_data, + mechanism); +} + +void gsignond_plugin_request (GSignondPlugin *self, + GSignondSessionData *session_data) +{ + g_return_if_fail (GSIGNOND_IS_PLUGIN (self)); + + GSIGNOND_PLUGIN_GET_INTERFACE (self)->request (self, session_data); +} + +void gsignond_plugin_user_action_finished (GSignondPlugin *self, + GSignondSignonuiData *ui_data) +{ + g_return_if_fail (GSIGNOND_IS_PLUGIN (self)); + + GSIGNOND_PLUGIN_GET_INTERFACE (self)->user_action_finished (self, + ui_data); +} + +void gsignond_plugin_refresh (GSignondPlugin *self, + GSignondSignonuiData *ui_data) +{ + g_return_if_fail (GSIGNOND_IS_PLUGIN (self)); + + GSIGNOND_PLUGIN_GET_INTERFACE (self)->refresh (self, ui_data); +} + +void gsignond_plugin_response (GSignondPlugin *self, + GSignondSessionData *session_data) +{ + g_signal_emit (self, signals[RESPONSE], 0, session_data); +} + +void gsignond_plugin_response_final (GSignondPlugin *self, + GSignondSessionData *session_data) +{ + g_signal_emit (self, signals[RESPONSE_FINAL], 0, session_data); +} + +void gsignond_plugin_store (GSignondPlugin *self, + GSignondDictionary *token_data) +{ + g_signal_emit (self, signals[STORE], 0, token_data); +} + +void gsignond_plugin_error (GSignondPlugin *self, GError *error) +{ + g_signal_emit (self, signals[ERROR], 0, error); +} + +void gsignond_plugin_user_action_required (GSignondPlugin *self, + GSignondSignonuiData *ui_data) +{ + g_signal_emit (self, signals[USER_ACTION_REQUIRED], 0, ui_data); +} + +void gsignond_plugin_refreshed (GSignondPlugin *self, + GSignondSignonuiData *ui_data) +{ + g_signal_emit (self, signals[REFRESHED], 0, ui_data); +} + +void gsignond_plugin_status_changed (GSignondPlugin *self, + GSignondPluginState state, const gchar *message) +{ + g_signal_emit (self, signals[STATUS_CHANGED], 0, state, message); +} + diff --git a/src/common/gsignond-plugin-loader.c b/src/common/gsignond-plugin-loader.c new file mode 100644 index 0000000..99dd5bd --- /dev/null +++ b/src/common/gsignond-plugin-loader.c @@ -0,0 +1,83 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + + +#include <gmodule.h> + +#include "gsignond/gsignond-log.h" +#include "gsignond-plugin-loader.h" + +GSignondPlugin* +gsignond_load_plugin( + GSignondConfig* config, + gchar* plugin_type) +{ + gchar* plugin_filename = g_module_build_path ( + gsignond_config_get_string (config, + GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), plugin_type); + GSignondPlugin *plugin = gsignond_load_plugin_with_filename (plugin_type, + plugin_filename); + g_free(plugin_filename); + return plugin; +} + +GSignondPlugin* +gsignond_load_plugin_with_filename( + gchar *plugin_type, + gchar *plugin_filename) +{ + DBG("Loading plugin %s", plugin_filename); + GModule* plugin_module = g_module_open (plugin_filename, + G_MODULE_BIND_LOCAL); + if (plugin_module == NULL) { + DBG("Plugin couldn't be opened: %s", g_module_error()); + return NULL; + } + + gchar* plugin_get_type = g_strdup_printf("gsignond_%s_plugin_get_type", + plugin_type); + gpointer p; + + DBG("Resolving symbol %s", plugin_get_type); + gboolean symfound = g_module_symbol (plugin_module, + plugin_get_type, &p); + g_free(plugin_get_type); + if (!symfound) { + DBG("Symbol couldn't be resolved"); + g_module_close (plugin_module); + return NULL; + } + + DBG("Creating plugin object"); + GType (*plugin_get_type_f)(void) = p; + GSignondPlugin* plugin = g_object_new(plugin_get_type_f(), NULL); + if (plugin == NULL) { + DBG("Plugin couldn't be created"); + g_module_close (plugin_module); + return NULL; + } + g_module_make_resident (plugin_module); + return plugin; +} diff --git a/src/common/gsignond-plugin-loader.h b/src/common/gsignond-plugin-loader.h new file mode 100644 index 0000000..0c1e727 --- /dev/null +++ b/src/common/gsignond-plugin-loader.h @@ -0,0 +1,47 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef _GSIGNOND_PLUGIN_LOADER_H_ +#define _GSIGNOND_PLUGIN_LOADER_H_ + +#include <gsignond/gsignond-plugin-interface.h> +#include <gsignond/gsignond-config.h> + +G_BEGIN_DECLS + +GSignondPlugin* +gsignond_load_plugin( + GSignondConfig* config, + gchar* plugin_type); + +GSignondPlugin* +gsignond_load_plugin_with_filename( + gchar *plugin_type, + gchar *plugin_filename); + +G_END_DECLS + +#endif /* _GSIGNOND_PLUGIN_LOADER_H_ */ + diff --git a/src/common/gsignond-security-context.c b/src/common/gsignond-security-context.c new file mode 100644 index 0000000..7b1c3f0 --- /dev/null +++ b/src/common/gsignond-security-context.c @@ -0,0 +1,408 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Jussi Laako <jussi.laako@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include "gsignond/gsignond-security-context.h" + +static void +_security_context_free (gpointer ptr) +{ + GSignondSecurityContext *ctx = (GSignondSecurityContext *) ptr; + + gsignond_security_context_free (ctx); +} + +/** + * gsignond_security_context_new: + * + * Allocates a new security context item. + * + * Returns: (transfer full) allocated #GSignondSecurityContext. + */ +GSignondSecurityContext * +gsignond_security_context_new () +{ + GSignondSecurityContext *ctx; + + ctx = g_slice_new0 (GSignondSecurityContext); + ctx->sys_ctx = g_strdup (""); + ctx->app_ctx = g_strdup (""); + + return ctx; +} + +/** + * gsignond_security_context_new_from_vaues: + * @system_context: system security context (such as SMACK/MSSF label/token). + * @application_context: application security context (such as a script name). + * + * Allocates and initializes a new security context item. + * + * Returns: (transfer full) allocated #GSignondSecurityContext. + */ +GSignondSecurityContext * +gsignond_security_context_new_from_values (const gchar *system_context, + const gchar *application_context) +{ + GSignondSecurityContext *ctx; + + g_return_val_if_fail (system_context != NULL, NULL); + + ctx = g_slice_new0 (GSignondSecurityContext); + ctx->sys_ctx = g_strdup (system_context); + if (application_context) + ctx->app_ctx = g_strdup (application_context); + else + ctx->app_ctx = g_strdup (""); + + return ctx; +} + +/** + * gsignond_security_context_copy: + * @src_ctx: source security context to copy. + * + * Copy a security context item. + * + * Returns: (transfer full) a copy of the #GSignondSecurityContext item. + */ +GSignondSecurityContext * +gsignond_security_context_copy (const GSignondSecurityContext *src_ctx) +{ + g_return_val_if_fail (src_ctx != NULL, NULL); + + return gsignond_security_context_new_from_values (src_ctx->sys_ctx, + src_ctx->app_ctx); +} + +/** + * gsignond_security_context_free: + * @ctx: #GSignondSecurityContext to be freed. + * + * Frees a security context item. + */ +void +gsignond_security_context_free (GSignondSecurityContext *ctx) +{ + if (ctx == NULL) return; + + g_free (ctx->sys_ctx); + g_free (ctx->app_ctx); + g_slice_free (GSignondSecurityContext, ctx); +} + +/** + * gsignond_security_context_set_system_context: + * @ctx: #GSignondSecurityContext item. + * @system_context: system security context. + * + * Sets the system context part (such as SMACK label or MSSF token) of the + * #GSignondSecurityContext. + */ +void +gsignond_security_context_set_system_context (GSignondSecurityContext *ctx, + const gchar *system_context) +{ + g_return_if_fail (ctx != NULL); + + g_free (ctx->sys_ctx); + ctx->sys_ctx = (system_context) ? + g_strdup (system_context) : g_strdup (""); +} + +/** + * gsignond_security_context_get_system_context: + * @ctx: #GSignondSecurityContext item. + * + * Get the system context part (such as SMACK label or MSSF token) of the + * #GSignondSecurityContext. + * + * Returns: (transfer none) system context. + */ +const gchar * +gsignond_security_context_get_system_context ( + const GSignondSecurityContext *ctx) +{ + g_return_val_if_fail (ctx != NULL, NULL); + + return ctx->sys_ctx; +} + +/** + * gsignond_security_context_set_application_context: + * @ctx: #GSignondSecurityContext item. + * @application_context: application security context. + * + * Sets the application context part (such as a script name or a web page) of + * the #GSignondSecurityContext. + */ +void +gsignond_security_context_set_application_context ( + GSignondSecurityContext *ctx, + const gchar *application_context) +{ + g_return_if_fail (ctx != NULL); + + g_free (ctx->app_ctx); + ctx->app_ctx = (application_context) ? + g_strdup (application_context) : g_strdup (""); +} + +/** + * gsignond_security_context_get_application_context: + * @ctx: #GSignondSecurityContext item. + * + * Get the application context part (such as script name or a web page) of + * the #GSignondSecurityContext. + * + * Returns: (transfer none) application context. + */ +const gchar * +gsignond_security_context_get_application_context ( + const GSignondSecurityContext *ctx) +{ + g_return_val_if_fail (ctx != NULL, NULL); + + return ctx->app_ctx; +} + +/** + * signon_security_conetxt_to_variant: + * @ctx: #GSignondSecurityContext item. + * + * Build a GVariant of type "(ss)" from a #GSignondSecurityContext item. + * + * Returns: (transfer full) GVariant construct of a #GSignondSecurityContext. + */ +GVariant * +gsignond_security_context_to_variant (const GSignondSecurityContext *ctx) +{ + GVariant *variant; + + g_return_val_if_fail (ctx != NULL, NULL); + + variant = g_variant_new ("(ss)", + ctx->sys_ctx ? ctx->sys_ctx : "", + ctx->app_ctx ? ctx->app_ctx : ""); + + return variant; +} + +/** + * gsignond_security_context_from_variant: + * @variant: GVariant item with a #GSignondSecurityContext construct. + * + * Builds a #GSignondSecurityContext item from a GVariant of type "(ss)". + * + * Returns: (transfer full) #GSignondSecurityContext item. + */ +GSignondSecurityContext * +gsignond_security_context_from_variant (GVariant *variant) +{ + gchar *sys_ctx = NULL; + gchar *app_ctx = NULL; + GSignondSecurityContext *ctx; + + g_return_val_if_fail (variant != NULL, NULL); + + g_variant_get (variant, "(ss)", &sys_ctx, &app_ctx); + ctx = gsignond_security_context_new_from_values (sys_ctx, app_ctx); + g_free (sys_ctx); + g_free (app_ctx); + return ctx; +} + +/** + * gsignond_security_context_compare: + * @ctx1: first item to compare. + * @ctx2: second item to compare. + * + * Compare two #GSignondSecurityContext items similar in a way to strcmp(). + * + * Returns: negative if ctx1 < ctx2, 0 if ctx1 == ctx2 and positive if ctx1 > ctx2. + */ +int +gsignond_security_context_compare (const GSignondSecurityContext *ctx1, + const GSignondSecurityContext *ctx2) +{ + int res; + + if (ctx1 == ctx2) return 0; + + g_return_val_if_fail (ctx1 != NULL, -1); + g_return_val_if_fail (ctx2 != NULL, 1); + + res = g_strcmp0(ctx1->sys_ctx, ctx2->sys_ctx); + if (res == 0) + res = g_strcmp0(ctx1->app_ctx, ctx2->app_ctx); + + return res; +} + +/** + * gsignond_security_context_match: + * @ctx1: first item to compare. + * @ctx2: second item to compare. + * + * Compare two #GSignondSecurityContext items match. + * + * Returns: TRUE if contexts are equal or either side has wildcard match, otherwise FALSE. Two NULL contexts match. + */ +gboolean +gsignond_security_context_match (const GSignondSecurityContext *ctx1, + const GSignondSecurityContext *ctx2) +{ + if (ctx1 == ctx2) return TRUE; + + g_return_val_if_fail (ctx1 != NULL && ctx2 != NULL, FALSE); + + if (g_strcmp0(ctx1->sys_ctx, "*") == 0 || + g_strcmp0(ctx2->sys_ctx, "*") == 0) return TRUE; + + if (g_strcmp0(ctx1->sys_ctx, ctx2->sys_ctx) == 0) { + if (g_strcmp0(ctx1->app_ctx, "*") == 0 || + g_strcmp0(ctx2->app_ctx, "*") == 0) return TRUE; + if (g_strcmp0(ctx1->app_ctx, ctx2->app_ctx) == 0) return TRUE; + } + + return FALSE; +} + +/** + * gsignond_security_context_check: + * @reference: reference security context item to check against. + * @test: security context item to be checked. + * + * Check if item @test is covered by @reference. + * + * Returns: TRUE if contexts are equal or wildcards of the @reference arguments match, otherwise FALSE. If either or both contexts are NULL, FALSE is returned. + */ +gboolean +gsignond_security_context_check (const GSignondSecurityContext *reference, + const GSignondSecurityContext *test) +{ + g_return_val_if_fail (reference != NULL && test != NULL, FALSE); + + if (g_strcmp0(reference->sys_ctx, "*") == 0) return TRUE; + if (g_strcmp0(reference->sys_ctx, test->sys_ctx) == 0) { + if (g_strcmp0(reference->app_ctx, "*") == 0) return TRUE; + if (g_strcmp0(reference->app_ctx, test->app_ctx) == 0) return TRUE; + } + + return FALSE; +} + +/** + * gsignond_security_context_list_to_variant: + * @list: #GSignondSecurityContextList item. + * + * Builds a GVariant of type "a(ss)" from a GList of #GSignondSecurityContext + * items. + * + * Returns: (transfer full) GVariant construct of a #GSignondSecurityContextList. + */ +GVariant * +gsignond_security_context_list_to_variant ( + const GSignondSecurityContextList *list) +{ + GVariantBuilder builder; + GVariant *variant; + GSignondSecurityContext *ctx; + + g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); + for ( ; list != NULL; list = g_list_next (list)) { + ctx = (GSignondSecurityContext *) list->data; + g_variant_builder_add_value ( + &builder, + gsignond_security_context_to_variant (ctx)); + } + variant = g_variant_builder_end (&builder); + + return variant; +} + +/** + * gsignond_security_context_list_from_variant: + * @variant: GVariant item with a list of security context tuples. + * + * Builds a GList of #GSignondSecurityContext items from a GVariant of type + * "a(ss)". + * + * Returns: (transfer full) #GSignondSecurityContextList item. + */ +GSignondSecurityContextList * +gsignond_security_context_list_from_variant (GVariant *variant) +{ + GSignondSecurityContextList *list = NULL; + GVariantIter iter; + GVariant *value; + + g_return_val_if_fail (variant != NULL, NULL); + + g_variant_iter_init (&iter, variant); + while ((value = g_variant_iter_next_value (&iter))) { + list = g_list_append (list, + gsignond_security_context_from_variant (value)); + g_variant_unref (value); + } + + return list; +} + +/** + * gsignond_security_context_list_copy: + * @src_list: source #GSignondSecurityContextList. + * + * Copies a GList of #GSignondSecurityContext items. + * + * Returns: (transfer full) #GSignondSecurityContextList item. + */ +GSignondSecurityContextList * +gsignond_security_context_list_copy ( + const GSignondSecurityContextList *src_list) +{ + GSignondSecurityContext *ctx; + GSignondSecurityContextList *dst_list = NULL; + + for ( ; src_list != NULL; src_list = g_list_next (src_list)) { + ctx = (GSignondSecurityContext *) src_list->data; + dst_list = g_list_append (dst_list, + gsignond_security_context_copy (ctx)); + } + + return dst_list; +} + +/** + * gsignond_security_context_list_free: + * @seclist: (transfer full) #GSignondSecurityContextList item. + * + * Frees all items and the GList of #GSignondSecurityContext. + */ +void +gsignond_security_context_list_free (GSignondSecurityContextList *seclist) +{ + g_list_free_full (seclist, _security_context_free); +} + diff --git a/src/common/gsignond-session-data.c b/src/common/gsignond-session-data.c new file mode 100644 index 0000000..b07f23c --- /dev/null +++ b/src/common/gsignond-session-data.c @@ -0,0 +1,150 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012-2013 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <gsignond/gsignond-session-data.h> + +const gchar * +gsignond_session_data_get_username (GSignondSessionData *data) +{ + return gsignond_dictionary_get_string (data, "UserName"); +} + +void +gsignond_session_data_set_username (GSignondSessionData *data, + const gchar *username) +{ + gsignond_dictionary_set_string (data, "UserName", username); +} + +const gchar * +gsignond_session_data_get_secret (GSignondSessionData *data) +{ + return gsignond_dictionary_get_string (data, "Secret"); +} + +void +gsignond_session_data_set_secret (GSignondSessionData *data, + const gchar *secret) +{ + gsignond_dictionary_set_string (data, "Secret", secret); +} + +const gchar * +gsignond_session_data_get_realm (GSignondSessionData *data) +{ + return gsignond_dictionary_get_string (data, "Realm"); +} + +void +gsignond_session_data_set_realm (GSignondSessionData *data, + const gchar *realm) +{ + gsignond_dictionary_set_string (data, "Realm", realm); +} + +const gchar * +gsignond_session_data_get_caption (GSignondSessionData *data) +{ + return gsignond_dictionary_get_string (data, "Caption"); +} + +void +gsignond_session_data_set_caption (GSignondSessionData *data, + const gchar *caption) +{ + gsignond_dictionary_set_string (data, "Caption", caption); +} + +gboolean +gsignond_session_data_get_renew_token (GSignondSessionData *data, + gboolean *renew_token) +{ + return gsignond_dictionary_get_boolean (data, "RenewToken", renew_token); +} + +void +gsignond_session_data_set_renew_token (GSignondSessionData *data, + gboolean renew_token) +{ + gsignond_dictionary_set_boolean (data, "RenewToken", renew_token); +} + +gboolean +gsignond_session_data_get_ui_policy (GSignondSessionData *data, + guint32 *ui_policy) +{ + return gsignond_dictionary_get_uint32 (data, "UiPolicy", ui_policy); +} + +void +gsignond_session_data_set_ui_policy (GSignondSessionData *data, + guint32 ui_policy) +{ + gsignond_dictionary_set_uint32 (data, "UiPolicy", ui_policy); +} + +const gchar * +gsignond_session_data_get_network_proxy (GSignondSessionData *data) +{ + return gsignond_dictionary_get_string (data, "NetworkProxy"); +} + +void +gsignond_session_data_set_network_proxy (GSignondSessionData *data, + const gchar *network_proxy) +{ + gsignond_dictionary_set_string (data, "NetworkProxy", network_proxy); +} + +gboolean +gsignond_session_data_get_network_timeout (GSignondSessionData *data, + guint32 *network_timeout) +{ + return gsignond_dictionary_get_uint32 (data, "NetworkTimeout", + network_timeout); +} + +void +gsignond_session_data_set_network_timeout (GSignondSessionData *data, + guint32 network_timeout) +{ + gsignond_dictionary_set_uint32 (data, "NetworkTimeout", + network_timeout); +} + +gboolean +gsignond_session_data_get_window_id (GSignondSessionData *data, + guint32 *window_id) +{ + return gsignond_dictionary_get_uint32 (data, "WindowId", window_id); +} + +void +gsignond_session_data_set_window_id (GSignondSessionData *data, + guint32 window_id) +{ + gsignond_dictionary_set_uint32 (data, "WindowId", window_id); +} + diff --git a/src/common/gsignond-signonui-data.c b/src/common/gsignond-signonui-data.c new file mode 100644 index 0000000..c489b9b --- /dev/null +++ b/src/common/gsignond-signonui-data.c @@ -0,0 +1,310 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2013 Intel Corporation. + * + * Contact: Amarnath Valluri<amarnath.valluri@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <gsignond/gsignond-signonui-data.h> + +#define SIGNONUI_KEY_CAPTCHA_RESPONSE "CaptchaResponse" +#define SIGNONUI_KEY_CAPTCHA_URL "CaptchaUrl" +#define SIGNONUI_KEY_CAPTION "Caption" +#define SIGNONUI_KEY_CONFIRM "Confirm" +#define SIGNONUI_KEY_FINAL_URL "FinalUrl" +#define SIGNONUI_KEY_FORGOT_PASSWORD "ForgotPassword" +#define SIGNONUI_KEY_FORGOT_PASSWORD_URL "ForgotPasswordUrl" +#define SIGNONUI_KEY_MESSAGE "Message" +#define SIGNONUI_KEY_OPEN_URL "OpenUrl" +#define SIGNONUI_KEY_PASSWORD "Secret" +#define SIGNONUI_KEY_QUERY_ERROR_CODE "QueryErrorCode" +#define SIGNONUI_KEY_QUERY_PASSWORD "QueryPassword" +#define SIGNONUI_KEY_QUERY_USERNAME "QueryUserName" +#define SIGNONUI_KEY_REMEMBER_PASSWORD "RememberPassword" +#define SIGNONUI_KEY_REQUEST_ID "RequestId" +#define SIGNONUI_KEY_TEST_REPLY_VALUES "TestReplyValues" +#define SIGNONUI_KEY_TITLE "Title" +#define SIGNONUI_KEY_URL_RESPONSE "UrlResponse" +#define SIGNONUI_KEY_USERNAME "UserName" + +const gchar* +gsignond_signonui_data_get_captcha_response (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_CAPTCHA_RESPONSE); +} + +void +gsignond_signonui_data_set_captcha_response (GSignondSignonuiData *data, + const gchar *response) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_CAPTCHA_RESPONSE, response); +} + +const gchar* +gsignond_signonui_data_get_captcha_url (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_CAPTCHA_URL); +} + +void +gsignond_signonui_data_set_captcha_url (GSignondSignonuiData *data, + const gchar *url) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_CAPTCHA_URL, url); +} + +const gchar* +gsignond_signonui_data_get_caption (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_CAPTION); +} + +void +gsignond_signonui_data_set_caption (GSignondSignonuiData *data, + const gchar *caption) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_CAPTION, caption); +} + +gboolean +gsignond_signonui_data_get_confirm (GSignondSignonuiData *data, + gboolean *confirm) +{ + return gsignond_dictionary_get_boolean (data, SIGNONUI_KEY_CONFIRM, confirm); +} + +void +gsignond_signonui_data_set_confirm (GSignondSignonuiData *data, + gboolean confirm) +{ + gsignond_dictionary_set_boolean (data, SIGNONUI_KEY_CONFIRM, confirm); +} + +const gchar* +gsignond_signonui_data_get_final_url (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_FINAL_URL); +} + +void +gsignond_signonui_data_set_final_url (GSignondSignonuiData *data, + const gchar *url) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_FINAL_URL, url); +} + +gboolean +gsignond_signonui_data_get_forgot_password (GSignondSignonuiData *data, + gboolean *forgot_password) +{ + return gsignond_dictionary_get_boolean (data, + SIGNONUI_KEY_FORGOT_PASSWORD, + forgot_password); +} + +void +gsignond_signonui_data_set_forgot_password (GSignondSignonuiData *data, + gboolean forgot) +{ + gsignond_dictionary_set_boolean (data, SIGNONUI_KEY_FORGOT_PASSWORD, forgot); +} + +const gchar* +gsignond_signonui_data_get_forgot_password_url (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_FORGOT_PASSWORD_URL); +} + +void +gsignond_signonui_data_set_forgot_password_url (GSignondSignonuiData *data, + const gchar *url) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_FORGOT_PASSWORD_URL, url); +} + +const gchar* +gsignond_signonui_data_get_message (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_MESSAGE); +} + +void +gsignond_signonui_data_set_message (GSignondSignonuiData *data, + const gchar *message) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_MESSAGE, message); +} + +const gchar* +gsignond_signonui_data_get_open_url (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_OPEN_URL); +} + +void +gsignond_signonui_data_set_open_url (GSignondSignonuiData *data, + const gchar *url) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_OPEN_URL, url); +} + +const gchar* +gsignond_signonui_data_get_password (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_PASSWORD); +} + +void +gsignond_signonui_data_set_password (GSignondSignonuiData *data, + const gchar *password) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_PASSWORD, password); +} + +gboolean +gsignond_signonui_data_get_query_error (GSignondSignonuiData *data, + GSignondSignonuiError *error) +{ + return gsignond_dictionary_get_uint32 (data, + SIGNONUI_KEY_QUERY_ERROR_CODE, + error); +} + +void +gsignond_signonui_data_set_query_error (GSignondSignonuiData *data, + GSignondSignonuiError error) +{ + gsignond_dictionary_set_uint32 (data, SIGNONUI_KEY_QUERY_ERROR_CODE, error); +} + +gboolean +gsignond_signonui_data_get_query_password (GSignondSignonuiData *data, + gboolean *query_password) +{ + return gsignond_dictionary_get_boolean (data, + SIGNONUI_KEY_QUERY_PASSWORD, + query_password); +} + +void +gsignond_signonui_data_set_query_password (GSignondSignonuiData *data, + gboolean query) +{ + gsignond_dictionary_set_boolean (data, SIGNONUI_KEY_QUERY_PASSWORD, query); +} + +gboolean +gsignond_signonui_data_get_query_username (GSignondSignonuiData *data, + gboolean *query_username) +{ + return gsignond_dictionary_get_boolean (data, + SIGNONUI_KEY_QUERY_USERNAME, + query_username); +} + +void +gsignond_signonui_data_set_query_username (GSignondSignonuiData *data, + gboolean query) +{ + gsignond_dictionary_set_boolean (data, SIGNONUI_KEY_QUERY_USERNAME, query); +} + +gboolean +gsignond_signonui_data_get_remember_password (GSignondSignonuiData *data, + gboolean *remember_password) +{ + return gsignond_dictionary_get_boolean (data, + SIGNONUI_KEY_REMEMBER_PASSWORD, + remember_password); +} + +void +gsignond_signonui_data_set_remember_password (GSignondSignonuiData *data, + gboolean remember) +{ + gsignond_dictionary_set_boolean (data, SIGNONUI_KEY_REMEMBER_PASSWORD, remember); +} + +const gchar* +gsignond_signonui_data_get_request_id (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_REQUEST_ID); +} + +void +gsignond_signonui_data_set_request_id (GSignondSignonuiData *data, + const gchar *id) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_REQUEST_ID, id); +} + +const gchar* +gsignond_signonui_data_get_test_reply (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_TEST_REPLY_VALUES); +} + +void +gsignond_signonui_data_set_test_reply (GSignondSignonuiData *data, + const gchar *reply) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_TEST_REPLY_VALUES, reply); +} + +const gchar* +gsignond_signonui_data_get_title (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_TITLE); +} + +void +gsignond_signonui_data_set_title (GSignondSignonuiData *data, + const gchar* title) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_TITLE, title); +} + +const gchar* +gsignond_signonui_data_get_url_response (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_URL_RESPONSE); +} + +void +gsignond_signonui_data_set_url_response (GSignondSignonuiData *data, + const gchar *response) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_URL_RESPONSE, response); +} + +const gchar* +gsignond_signonui_data_get_username (GSignondSignonuiData *data) +{ + return gsignond_dictionary_get_string (data, SIGNONUI_KEY_USERNAME); +} + +void +gsignond_signonui_data_set_username (GSignondSignonuiData *data, + const gchar *username) +{ + gsignond_dictionary_set_string (data, SIGNONUI_KEY_USERNAME, username); +} + diff --git a/src/common/gsignond-storage-manager.c b/src/common/gsignond-storage-manager.c new file mode 100644 index 0000000..64e7d72 --- /dev/null +++ b/src/common/gsignond-storage-manager.c @@ -0,0 +1,322 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Jussi Laako <jussi.laako@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <sys/stat.h> + +#include <glib/gstdio.h> + +#include "gsignond/gsignond-log.h" +#include "gsignond/gsignond-storage-manager.h" +#include "gsignond/gsignond-utils.h" + +#define GSIGNOND_STORAGE_MANAGER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + GSIGNOND_TYPE_STORAGE_MANAGER, \ + GSignondStorageManagerPrivate)) + +struct _GSignondStorageManagerPrivate +{ +}; + +enum +{ + PROP_0, + PROP_CONFIG, + N_PROPERTIES +}; + +static GParamSpec *properties[N_PROPERTIES] = { NULL, }; + +G_DEFINE_TYPE (GSignondStorageManager, gsignond_storage_manager, G_TYPE_OBJECT); + +static void +_set_config (GSignondStorageManager *self, GSignondConfig *config) +{ + g_assert (self->config == NULL); + self->config = config; + + const gchar *secure_dir = gsignond_config_get_string ( + self->config, + GSIGNOND_CONFIG_GENERAL_SECURE_DIR); + if (secure_dir) + self->location = g_build_filename (secure_dir, + "gsignond.secret", + NULL); + else + self->location = g_build_filename (g_get_user_data_dir (), + "gsignond.secret", + NULL); + DBG ("secure dir %s", self->location); +} + +static void +_set_property (GObject *object, guint prop_id, const GValue *value, + GParamSpec *pspec) +{ + GSignondStorageManager *self = + GSIGNOND_STORAGE_MANAGER (object); + + switch (prop_id) { + case PROP_CONFIG: + g_assert (self->config == NULL); + _set_config (self, GSIGNOND_CONFIG (g_value_dup_object (value))); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GSignondStorageManager *self = + GSIGNOND_STORAGE_MANAGER (object); + + switch (prop_id) { + case PROP_CONFIG: + g_value_set_object (value, self->config); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +_dispose (GObject *object) +{ + GSignondStorageManager *self = + GSIGNOND_STORAGE_MANAGER (object); + + /* unmount mounted filesystem */ + if (gsignond_storage_manager_filesystem_is_mounted (self)) { + gsignond_storage_manager_unmount_filesystem (self); + } + + if (self->config) { + g_object_unref (self->config); + self->config = NULL; + } + + G_OBJECT_CLASS (gsignond_storage_manager_parent_class)->dispose (object); +} + +static void +_finalize (GObject *object) +{ + GSignondStorageManager *self = + GSIGNOND_STORAGE_MANAGER (object); + + if (self->location) { + g_free (self->location); + self->location = NULL; + } + + G_OBJECT_CLASS (gsignond_storage_manager_parent_class)->finalize (object); +} + +static gboolean +_initialize_storage (GSignondStorageManager *self) +{ + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (self->location, FALSE); + + if (g_mkdir_with_parents (self->location, S_IRWXU)) + return FALSE; + + return TRUE; +} + +static gboolean +_delete_storage (GSignondStorageManager *self) +{ + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (self->location, FALSE); + + return gsignond_wipe_directory (self->location); +} + +static gboolean +_storage_is_initialized (GSignondStorageManager *self) +{ + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (self->location, FALSE); + + if (g_access (self->location, 0)) /* 0 should equal to F_OK */ + return FALSE; + + return TRUE; +} + +static const gchar * +_mount_filesystem (GSignondStorageManager *self) +{ + g_return_val_if_fail (self != NULL, NULL); + + return self->location; +} + +static gboolean +_unmount_filesystem (GSignondStorageManager *self) +{ + g_return_val_if_fail (self != NULL, FALSE); + + return TRUE; +} + +static gboolean +_filesystem_is_mounted (GSignondStorageManager *self) +{ + return _storage_is_initialized (self); +} + +static void +gsignond_storage_manager_class_init (GSignondStorageManagerClass *klass) +{ + GObjectClass *base = G_OBJECT_CLASS (klass); + + base->set_property = _set_property; + base->get_property = _get_property; + base->dispose = _dispose; + base->finalize = _finalize; + properties[PROP_CONFIG] = g_param_spec_object ("config", + "config", + "Configuration object", + GSIGNOND_TYPE_CONFIG, + G_PARAM_CONSTRUCT_ONLY| + G_PARAM_READWRITE| + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (base, N_PROPERTIES, properties); + + /*g_type_class_add_private (klass, sizeof(GSignondStorageManagerPrivate));*/ + + klass->initialize_storage = _initialize_storage; + klass->delete_storage = _delete_storage; + klass->storage_is_initialized = _storage_is_initialized; + klass->mount_filesystem = _mount_filesystem; + klass->unmount_filesystem = _unmount_filesystem; + klass->filesystem_is_mounted = _filesystem_is_mounted; +} + +static void +gsignond_storage_manager_init (GSignondStorageManager *self) +{ + /*self->priv = GSIGNOND_STORAGE_MANAGER_GET_PRIVATE (self);*/ + + self->location = NULL; + self->config = NULL; +} + +/** + * gsignond_storage_manager_initialize_storage: + * @self: object instance. + * + * Initialize encryption storage. Initiali key should be set using + * #gsignond_storage_manager_set_encryption_key before calling this. + * + * Returns: success? + */ +gboolean +gsignond_storage_manager_initialize_storage (GSignondStorageManager *self) +{ + return GSIGNOND_STORAGE_MANAGER_GET_CLASS (self)-> + initialize_storage (self); +} + +/** + * gsignond_storage_manager_delete_storage: + * @self: object instance. + * + * Destroys all the encryption keys and wipes the storage. + * + * Returns: success? + */ +gboolean +gsignond_storage_manager_delete_storage (GSignondStorageManager *self) +{ + return GSIGNOND_STORAGE_MANAGER_GET_CLASS (self)-> + delete_storage (self); +} + +/** + * gsignond_storage_manager_storage_is_initialized: + * @self: object instance. + * + * Checks if the storage exists, and if possible if it has been initialized. + * + * Returns: storage has been initialized? + */ +gboolean +gsignond_storage_manager_storage_is_initialized (GSignondStorageManager *self) +{ + return GSIGNOND_STORAGE_MANAGER_GET_CLASS (self)-> + storage_is_initialized (self); +} + +/** + * gsignond_storage_manager_mount_filesystem: + * @self: object instance. + * + * Mounts an encrypted storage and returns filesystem path of the storage + * mount point. + * + * Returns: (transfer none) path of the storage mount point. + */ +const gchar * +gsignond_storage_manager_mount_filesystem (GSignondStorageManager *self) +{ + return GSIGNOND_STORAGE_MANAGER_GET_CLASS (self)-> + mount_filesystem (self); +} + +/** + * gsignond_storage_manager_unmount_filesystem: + * @self: object instance. + * + * Unmounts a previously mounted storage filesystem. + * + * Returns: success? + */ +gboolean +gsignond_storage_manager_unmount_filesystem (GSignondStorageManager *self) +{ + return GSIGNOND_STORAGE_MANAGER_GET_CLASS (self)-> + unmount_filesystem (self); +} + +/** + * gsignond_storage_manager_filesystem_is_mounted: + * @self: object instance. + * + * Checks if the filesystem is currently mounted. + * + * Returns: filesystem is currently mounted? + */ +gboolean +gsignond_storage_manager_filesystem_is_mounted (GSignondStorageManager *self) +{ + return GSIGNOND_STORAGE_MANAGER_GET_CLASS (self)-> + filesystem_is_mounted (self); +} + diff --git a/src/common/gsignond-utils.c b/src/common/gsignond-utils.c new file mode 100644 index 0000000..98d4065 --- /dev/null +++ b/src/common/gsignond-utils.c @@ -0,0 +1,163 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2013 Intel Corporation. + * + * Contact: Jussi Laako <jussi.laako@linux.intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/stat.h> + +#include "gsignond/gsignond-utils.h" +#include "gsignond/gsignond-log.h" + + +static size_t pagesize = 0; + + +gboolean +gsignond_wipe_file (const gchar *filename) +{ + gboolean retval = FALSE; + int rngfd; + int wipefd; + size_t sizeleft; + size_t writesize; + ssize_t sizewritten; + struct stat filestat; + guint8 *wipebuf; + + if (!pagesize) { + long confval = sysconf (_SC_PAGE_SIZE); + if (confval <= 0) + return FALSE; + pagesize = (size_t) confval; + } + + rngfd = open ("/dev/urandom", O_RDONLY); + if (rngfd < 0) + return FALSE; + + wipefd = open (filename, O_WRONLY | O_SYNC); + if (wipefd < 0) + goto _rng_exit; + wipebuf = g_malloc (pagesize); + if (fstat (wipefd, &filestat)) + goto _wipe_exit; + + /* write all 1's */ + sizeleft = filestat.st_size; + memset (wipebuf, 0xff, pagesize); + while (sizeleft) { + writesize = (sizeleft < pagesize) ? sizeleft : pagesize; + sizewritten = write (wipefd, wipebuf, writesize); + if (sizewritten != (ssize_t) writesize) + goto _wipe_exit; + sizeleft -= sizewritten; + } + + if (lseek (wipefd, 0, SEEK_SET) == (off_t) -1) + goto _wipe_exit; + + /* write all 0's */ + sizeleft = filestat.st_size; + memset (wipebuf, 0x00, pagesize); + while (sizeleft) { + writesize = (sizeleft < pagesize) ? sizeleft : pagesize; + sizewritten = write (wipefd, wipebuf, writesize); + if (sizewritten != (ssize_t) writesize) + goto _wipe_exit; + sizeleft -= sizewritten; + } + + if (lseek (wipefd, 0, SEEK_SET) == (off_t) -1) + goto _wipe_exit; + + /* write random */ + sizeleft = filestat.st_size; + while (sizeleft) { + writesize = (sizeleft < pagesize) ? sizeleft : pagesize; + if (read (rngfd, wipebuf, writesize) != (ssize_t) writesize) + goto _wipe_exit; + sizewritten = write (wipefd, wipebuf, writesize); + if (sizewritten != (ssize_t) writesize) + goto _wipe_exit; + sizeleft -= sizewritten; + } + + /* don't leave traces of last pattern to the memory */ + memset (wipebuf, 0x00, pagesize); + + /* remove the file and set return value on success */ + if (unlink (filename) == 0) { + retval = TRUE; + DBG ("successfully wiped file %s", filename); + } + +_wipe_exit: + g_free (wipebuf); + close (wipefd); +_rng_exit: + close (rngfd); + return retval; +} + + +gboolean +gsignond_wipe_directory (const gchar *dirname) +{ + gboolean retval = FALSE; + gboolean wiperes; + const gchar *filename; + gchar *filepath; + GDir *dirctx; + struct stat stat_entry; + + DBG ("wipe directory %s", dirname); + dirctx = g_dir_open (dirname, 0, NULL); + if (!dirctx) + return FALSE; + while ((filename = g_dir_read_name (dirctx))) { + filepath = g_build_filename (dirname, filename, NULL); + if (lstat(filepath, &stat_entry)) + goto _dir_exit; + if (S_ISDIR (stat_entry.st_mode) || + S_ISLNK (stat_entry.st_mode)) { + DBG ("remove directory or link %s", filepath); + wiperes = (remove (filepath) == 0); + } else { + DBG ("wipe file %s", filepath); + wiperes = gsignond_wipe_file (filepath); + } + g_free (filepath); + if (!wiperes) + goto _dir_exit; + } + retval = TRUE; + +_dir_exit: + g_dir_close (dirctx); + return retval; +} + |