diff --git a/configure.ac b/configure.ac index f2aee20..c77ca7b 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,14 @@ if test x"$debug" = xyes; then AC_DEFINE([DEBUG], [1], [Debug Flag]) fi +if test "x$sysconfdir" = 'x${prefix}/etc'; then + if test "x$prefix" = 'xNONE'; then + sysconfdir=$ac_default_prefix/etc + else + sysconfdir=$prefix/etc + fi +fi +AC_DEFINE_UNQUOTED([SYSCONFDIR], ["$sysconfdir"], [System Configuration Directory]) # Checks for programs. AC_PROG_CC @@ -150,7 +158,7 @@ for TMPVAR in creat creat64 fopen fopen64 freopen freopen64 open open64 rename u do VERSIONVAR=$(grep -m1 $TMPVAR@ glibc_symbols | cut -d@ -f2) FUNCVAR=$(echo $TMPVAR | tr a-z A-Z)_VERSION - + if test "x$VERSIONVAR" != "x" ; then AC_DEFINE_UNQUOTED([$FUNCVAR],"$VERSIONVAR",[$TMPVAR Define for dlvsym call]) else @@ -163,7 +171,7 @@ for TMPVAR in openat openat64 renameat unlinkat do VERSIONVAR=$(grep -m1 $TMPVAR@ glibc_symbols | cut -d@ -f2) FUNCVAR=$(echo $TMPVAR | tr a-z A-Z)_VERSION - + if test "x$VERSIONVAR" != "x" ; then AC_DEFINE_UNQUOTED([$FUNCVAR],"$VERSIONVAR",[$TMPVAR Define for dlvsym call]) else diff --git a/src/helpers.c b/src/helpers.c index 74da8db..1d094f1 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "trash.h" @@ -1437,12 +1438,41 @@ void get_config_from_file(config *cfg) "IGNORE_RE", "PRESERVE_FILES_LARGER_THAN"); - /* Did read_config_from_file() fail? If it did, we quit and leave the compile-time defaults unchanged: */ + if (!config_values) { + char sysconf_path[PATH_MAX]; + snprintf(sysconf_path, sizeof(sysconf_path), "%s/libtrash.conf", SYSCONFDIR); + config_values = read_config_from_file(sysconf_path, NUMBER_OF_CONFIG_OPTIONS, cfg, + "TRASH_CAN", + "IN_CASE_OF_FAILURE", + "SHOULD_WARN", + "IGNORE_HIDDEN", + "IGNORE_EDITOR_BACKUP", + "PROTECT_TRASH", + "GLOBAL_PROTECTION", + "TRASH_SYSTEM_ROOT", + "TEMPORARY_DIRS", + "USER_TEMPORARY_DIRS", + "UNREMOVABLE_DIRS", + "IGNORE_EXTENSIONS", + "INTERCEPT_UNLINK", + "INTERCEPT_RENAME", + "INTERCEPT_FOPEN", + "INTERCEPT_FREOPEN", + "INTERCEPT_OPEN", + "LIBTRASH_CONFIG_FILE_UNREMOVABLE", + "REMOVABLE_MEDIA_MOUNT_POINTS", + "IGNORE_EDITOR_TEMPORARY", + "EXCEPTIONS", + "IGNORE_RE", + "PRESERVE_FILES_LARGER_THAN"); + + /* Did read_config_from_file() fail? If it did, we quit and leave the compile-time defaults unchanged: */ - if (!config_values) - return; + if (!config_values) + return; + } - /* If we managed to read the configuration file in the user's home directory, + /* If we managed to read the configuration file in the user's home directory, * we now proceed to set the configuration variables to the values read_config_from_file() returned to us: */ /* Configuration variables which are integers used as "flags" are set by the