pam_env: Handling XDG_DATA_DIRS

Tinu Weber takeya at bluewin.ch
Tue Jun 13 12:53:00 UTC 2017


Hello

In my ~/.pam_environment, I would like to prepend a path to the
XDG_DATA_DIRS variable. As defined in the XDG base directory
specification [1] (XBDS), XDG_DATA_DIRS should be treated as
`/usr/local/share:/usr/share` if not set or empty.

In shell, I would do something like this:

	XDG_DATA_DIRS="/foo/bar:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"

Playing around with the DEFAULT and OVERRIDE directives as noted in the
pam_env.conf(5) man page, I tried this:

	MY_DATA_DIRS  DEFAULT="/usr/local/share:/usr/share" OVERRIDE="${XDG_DATA_DIRS}"
	XDG_DATA_DIRS  DEFAULT="/foo/bar:${MY_DATA_DIRS}"

However, it turns out that assigning a value to XDG_DATA_DIRS causes the
first line to be evaluated again (probably because MY_DATA_DIRS
"depends" on XDG_DATA_DIRS in its OVERRIDE). Next, this causes the
*second* line to evaluated again, and so on...

I guess that PAM stops at the third iteration of this, to avoid an
endless loop, and the resulting XDG_DATA_DIRS looks like this (notice
`/foo/bar` being in there three times):

	/foo/bar:/foo/bar:/foo/bar:/usr/local/share:/usr/share

Did I miss something in the documentation? Or is it not possible to have
"Expand a variable that may be empty (in which case it should initially
default to some value)" work in ~/.pam_environment?

Thank you in advance!

Best,
Tinu


[1] https://specifications.freedesktop.org/basedir-spec/latest/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/pam-list/attachments/20170613/1ae6d176/attachment.sig>


More information about the Pam-list mailing list