[systemd-devel] correct usage for file-only & (sub)dir-only shell globs in unit tmpfiles?

PGNet Dev pgnet.dev at gmail.com
Mon Sep 21 22:05:57 UTC 2020


 I want to chmod all files and dirs/subdirs in a tree using tmpfiles.

Starting with an example tree

	tree -pF /home/test/TEST
		/home/test/TEST
		└── [dr--------]  topdir/
			├── [-r--------]  A.txt
			└── [dr--------]  subdir1/
				├── [-r--------]  B.txt
				└── [dr--------]  subdir2/
					└── [-r--------]  C.txt


I want to chmod

	all files -> 0640
	all dirs  -> 0750

i.e., ending up with

		/home/test/TEST
		└── [drwxr-x---]  topdir/
			├── [-rw-r-----]  A.txt
			└── [drwxr-x---]  subdir1/
				├── [-rw-r-----]  B.txt
				└── [drwxr-x---]  subdir2/
					└── [-rw-r-----]  C.txt

for this, it seems shell globs are appropriate.

but, with

	/etc/tmpfiles.d/test.conf
(1)     Z /home/test/TEST/{.,**/}          0750 nobody nobody -
(2A)    Z /home/test/TEST/**               0640 nobody nobody -

or

(2B)    Z /home/test/TEST/{**,!.,!**/}     0640 nobody nobody -

, where the intention was that shell glob (1) matches only dirs/subdirs, and glob (2A) or (2B) matches files,


after exec of

	systemd-tmpfiles --create /etc/tmpfiles.d/dovecot.conf

I end up, instead, with

	tree -pF /home/test/TEST
		/home/test/TEST
		└── [drw-r-----]  topdir/
			├── [-rw-r-----]  A.txt
			└── [drw-r-----]  subdir1/
				├── [-rw-r-----]  B.txt
				└── [drw-r-----]  subdir2/
					└── [-rw-r-----]  C.txt


... with all my intended 0750 exec'able dir modes are overwritten with intended-for-files modes.

either my globs are wrong &/or I'm bumping into recursion conflicts with "Z" in tmpfiles.

What's the right usage/syntax in a tmpfile to efficiently/correctly get that^ done?



More information about the systemd-devel mailing list