Description: Allow luserconf outside home directory
 When mounting the home directory via pam_mount, it is better to keep
 the user's pam_mount.conf.xml elsewhere. It is particularly
 helpful if the home directory is encrypted.
 .
 This patch recognizes an absolute path in 'luserconf' and, if so,
 does not prepend the home directory.
 .
 It also replaces the various placeholders, such as %(USER) and '~'
 in 'luserconfig'. It allows all users to keep personal config files
 in similar locations.
Author: Felix Lechner <felix.lechner@lease-up.com>
Forwarded: no
Last-Update: 2017-03-06
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: libpam-mount-2.16/src/rdconf1.c
===================================================================
--- libpam-mount-2.16.orig/src/rdconf1.c
+++ libpam-mount-2.16/src/rdconf1.c
@@ -139,7 +139,7 @@ static bool expand_user(const char *user
  * Like, turning <volume server="w2k3" path="%(USER)"
  * mountpoint="~" /> into path="joe" mountpoint="/home/joe".
  */
-bool expandconfig(const struct config *config)
+bool expandconfig(struct config *config)
 {
 	const char *u = config->user;
 	struct HXformat_map *vinfo;
@@ -171,6 +171,18 @@ bool expandconfig(const struct config *c
 	format_add(vinfo, "GROUP", (ge != NULL) ? ge->gr_name : "");
 	misc_add_ntdom(vinfo, u);
 
+	if (config->luserconf != NULL) {
+		char *tmp = NULL;
+		tmp = xstrdup(config->luserconf);
+		if (!expand_home(u, &tmp) || !expand_user(u, &tmp, vinfo)) {
+			free(tmp);
+			goto rfalse;
+		}
+		HXmc_free(config->luserconf);
+		config->luserconf = HXmc_strinit(tmp);
+		free(tmp);
+	}
+
 	HXlist_for_each_entry(vpt, &config->volume_list, list) {
 		if (vpt->is_expanded)
 			continue;
@@ -750,8 +762,11 @@ static const char *rc_luserconf(xmlNode
 	if ((s = xml_getprop(node, "name")) == NULL)
 		return "<luserconf> is missing name= attribute";
 	HXmc_free(config->luserconf);
-	config->luserconf = HXmc_strinit(pent->pw_dir);
-	HXmc_strcat(&config->luserconf, "/");
+	config->luserconf = HXmc_strinit("");
+	if(strlen(s) < 1 || s[0] != '/') {
+		HXmc_strcat(&config->luserconf, pent->pw_dir);
+		HXmc_strcat(&config->luserconf, "/");
+	}
 	HXmc_strcat(&config->luserconf, s);
 	w4rn("path to luserconf set to %s\n", config->luserconf);
 	free(s);
Index: libpam-mount-2.16/src/pam_mount.h
===================================================================
--- libpam-mount-2.16.orig/src/pam_mount.h
+++ libpam-mount-2.16/src/pam_mount.h
@@ -230,7 +230,7 @@ extern struct config Config;
 /*
  *	RDCONF1.C
  */
-extern bool expandconfig(const struct config *);
+extern bool expandconfig(struct config *);
 extern void initconfig(struct config *);
 extern bool readconfig(const char *, bool, struct config *);
 extern void freeconfig(struct config *);
