From 04ab5b682ae4cbd9c30b302c769d699d669e889e Mon Sep 17 00:00:00 2001 From: Omega Weapon Date: Sun, 10 Nov 2013 19:55:33 +0000 Subject: [PATCH] Communicate SYSCONFDIR to udevil and have it look up the config there, along with referencing the correct path in text --- src/Makefile.am | 3 ++- src/Makefile.in | 4 +++- src/udevil.c | 13 ++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index d9074f7..cd5871e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,5 @@ -INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" +INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + -DSYSCONFDIR=\""$(sysconfdir)"\" noinst_PROGRAMS = udevil diff --git a/src/Makefile.in b/src/Makefile.in index 4ed3537..df57b37 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -346,7 +346,9 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" +INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + -DSYSCONFDIR=\""$(sysconfdir)"\" + udevil_SOURCES = udevil.c device-info.c canonicalize.c bin_SCRIPTS = devmon INSTALL_DIR = $(DESTDIR)/$(prefix)/bin diff --git a/src/udevil.c b/src/udevil.c index f96a254..76a77a6 100644 --- a/src/udevil.c +++ b/src/udevil.c @@ -784,12 +784,12 @@ static char* parse_config() char* str; char* msg = NULL; - conf_path = g_strdup_printf( "/etc/udevil/udevil-user-%s.conf", g_get_user_name() ); + conf_path = g_strdup_printf( "%s/udevil/udevil-user-%s.conf", SYSCONFDIR, g_get_user_name() ); file = fopen( conf_path, "r" ); if ( !file ) { g_free( conf_path ); - conf_path = g_strdup_printf( "/etc/udevil/udevil.conf" ); + conf_path = g_strdup_printf( SYSCONFDIR "/udevil/udevil.conf" ); file = fopen( conf_path, "r" ); } drop_privileges( 0 ); // file is open now so drop priv @@ -900,7 +900,7 @@ static char* parse_config() } else { - msg = g_strdup_printf( _("udevil: warning 7: /etc/udevil/udevil.conf could not be read\n") ); + msg = g_strdup_printf( _("udevil: warning 7: %s/udevil/udevil.conf could not be read\n"), SYSCONFDIR ); g_free( conf_path ); conf_path = NULL; } @@ -4900,7 +4900,8 @@ static void show_help() printf( _("HELP - Show this help\n") ); printf( " udevil help|--help|-h\n" ); printf( "\n" ); - printf( "http://ignorantguru.github.com/udevil/ %s\n", _("See /etc/udevil/udevil.conf for config.") ); + printf( "http://ignorantguru.github.com/udevil/ " ); + printf( _("See %s/udevil/udevil.conf for config.\n"), SYSCONFDIR ); printf( _("For automounting with udevil run 'devmon --help'\n") ); printf( "\n" ); @@ -4997,8 +4998,10 @@ printf("\n-----------------------\n"); wlog( str, NULL, 0 ); g_free( str ); } + + // Configuration file path left out as it is dependent on SYSCONFDIR if ( config_msg && strcmp( config_msg, - _("udevil: read config /etc/udevil/udevil.conf\n") ) ) + _("udevil: read config ") ) ) // this only works for english wlog( config_msg, NULL, strstr( config_msg, "warning:" ) ? 1 : 0 ); g_free( config_msg );