2 # SPDX-License-Identifier: LGPL-2.1-or-later
6 # Check if homectl is installed, and if it isn't bail out early instead of failing
7 if ! test -x /usr
/bin
/homectl
; then
8 echo "no homed" >/skipped
13 # As updating disk-size-related attributes can take some time on some
14 # filesystems, let's drop these fields before comparing the outputs to
15 # avoid unexpected fails. To see the full outputs of both homectl &
16 # userdbctl (for debugging purposes) drop the fields just before the
18 local USERNAME
="${1:?}"
19 homectl inspect
"$USERNAME" |
tee /tmp
/a
20 userdbctl user
"$USERNAME" |
tee /tmp
/b
22 # diff uses the grep BREs for pattern matching
23 diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\|Usage\):' /tmp
/{a
,b
}
26 homectl inspect
--json=pretty
"$USERNAME"
31 (( i
> 1 )) && sleep 0.5
32 homectl inspect
"$1" |
grep -qF "State: $2" && break
36 FSTYPE
="$(stat --file-system --format "%T
" /)"
38 systemctl start systemd-homed.service systemd-userdbd.socket
40 systemd-analyze log-level debug
41 systemctl service-log-level systemd-homed debug
43 # Create a tmpfs to use as backing store for the home dir. That way we can enforce a size limit nicely.
45 mount
-t tmpfs tmpfs
/home
-o size
=290M
48 echo hogehoge
>"$TMP_SKEL"/hoge
50 # we enable --luks-discard= since we run our tests in a tight VM, hence don't
51 # needlessly pressure for storage. We also set the cheapest KDF, since we don't
52 # want to waste CI CPU cycles on it. We also effectively disable rate-limiting on
53 # the user by allowing 1000 logins per second
54 NEWPASSWORD
=xEhErW0ndafV4s homectl create test-user \
57 --image-path=/home
/test-user.home \
58 --luks-pbkdf-type=pbkdf2 \
59 --luks-pbkdf-time-cost=1ms \
60 --rate-limit-interval=1s \
61 --rate-limit-burst=1000 \
65 PASSWORD
=xEhErW0ndafV4s homectl authenticate test-user
67 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
70 PASSWORD
=xEhErW0ndafV4s homectl update test-user
--real-name="Inline test"
73 homectl deactivate test-user
76 PASSWORD
=xEhErW0ndafV4s NEWPASSWORD
=yPN4N0fYNKUkOq homectl passwd test-user
79 PASSWORD
=yPN4N0fYNKUkOq homectl activate test-user
82 SYSTEMD_LOG_LEVEL
=debug PASSWORD
=yPN4N0fYNKUkOq NEWPASSWORD
=xEhErW0ndafV4s homectl passwd test-user
85 homectl deactivate test-user
88 homectl update test-user
--real-name "Offline test" --offline
91 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
94 # Ensure that the offline changes were propagated in
95 grep "Offline test" /home
/test-user
/.identity
97 homectl deactivate test-user
100 PASSWORD
=xEhErW0ndafV4s homectl update test-user
--real-name="Inactive test"
103 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
106 homectl deactivate test-user
109 # Do some keyring tests, but only on real kernels, since keyring access inside of containers will fail
110 # (See: https://github.com/systemd/systemd/issues/17606)
111 if ! systemd-detect-virt
-cq ; then
112 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
115 # Key should now be in the keyring
116 homectl update test-user
--real-name "Keyring Test"
119 # These commands shouldn't use the keyring
120 (! timeout
5s homectl authenticate test-user
)
121 (! NEWPASSWORD
="foobar" timeout
5s homectl passwd test-user
)
123 homectl lock test-user
126 # Key should be gone from keyring
127 (! timeout
5s homectl update test-user
--real-name "Keyring Test 2" )
129 PASSWORD
=xEhErW0ndafV4s homectl unlock test-user
132 # Key should have been re-instantiated into the keyring
133 homectl update test-user
--real-name "Keyring Test 3"
136 homectl deactivate test-user
140 # Do some resize tests, but only if we run on real kernels and are on btrfs, as quota inside of containers
141 # will fail and minimizing while active only works on btrfs.
142 if ! systemd-detect-virt
-cq && [[ "$FSTYPE" == "btrfs" ]]; then
143 # grow while inactive
144 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
300M
147 # minimize while inactive
148 PASSWORD
=xEhErW0ndafV4s homectl resize test-user min
151 PASSWORD
=xEhErW0ndafV4s homectl activate test-user
155 PASSWORD
=xEhErW0ndafV4s homectl resize test-user max
158 # minimize while active
159 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
0
163 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
300M
166 # shrink to original size while active
167 PASSWORD
=xEhErW0ndafV4s homectl resize test-user
256M
171 PASSWORD
=xEhErW0ndafV4s homectl resize test-user min
174 # Increase space, so that we can reasonably rebalance free space between to home dirs
175 mount
/home
-o remount
,size
=800M
178 NEWPASSWORD
=uuXoo8ei homectl create test-user2 \
181 --image-path=/home
/test-user2.home \
182 --luks-pbkdf-type=pbkdf2 \
183 --luks-pbkdf-time-cost=1ms \
184 --rate-limit-interval=1s \
185 --rate-limit-burst=1000
188 # activate second user
189 PASSWORD
=uuXoo8ei homectl activate test-user2
192 # set second user's rebalance weight to 100
193 PASSWORD
=uuXoo8ei homectl update test-user2
--rebalance-weight=100
196 # set first user's rebalance weight to quarter of that of the second
197 PASSWORD
=xEhErW0ndafV4s homectl update test-user
--rebalance-weight=25
200 # synchronously rebalance
205 wait_for_state test-user2 active
206 homectl deactivate test-user2
207 wait_for_state test-user2 inactive
208 homectl remove test-user2
211 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test ! -f /home
/test-user
/xyz
212 (! PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test -f /home
/test-user
/xyz
)
213 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- touch /home
/test-user
/xyz
214 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test -f /home
/test-user
/xyz
215 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- rm /home
/test-user
/xyz
216 PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test ! -f /home
/test-user
/xyz
217 (! PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- test -f /home
/test-user
/xyz
)
218 [[ $
(PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- stat
-c %U
/home
/test-user
/hoge
) == "test-user" ]]
219 [[ $
(PASSWORD
=xEhErW0ndafV4s homectl with test-user
-- cat /home
/test-user
/hoge
) == "$(cat "$TMP_SKEL"/hoge)" ]]
222 wait_for_state test-user inactive
223 /usr
/lib
/systemd
/tests
/unit-tests
/manual
/test-homed-regression-31896 test-user
225 wait_for_state test-user inactive
226 homectl remove test-user
228 # blob directory tests
229 # See docs/USER_RECORD_BLOB_DIRS.md
231 test -f "/var/cache/systemd/home/blob-user/$1"
232 stat
-c "%u %#a" "/var/cache/systemd/home/blob-user/$1" |
grep "^0 0644"
233 test -f "/home/blob-user/.identity-blob/$1"
234 stat
-c "%u %#a" "/home/blob-user/.identity-blob/$1" |
grep "^12345 0644"
236 diff "/var/cache/systemd/home/blob-user/$1" "$2"
237 diff "/var/cache/systemd/home/blob-user/$1" "/home/blob-user/.identity-blob/$1"
240 mkdir
/tmp
/blob1
/tmp
/blob2
241 echo data1 blob1
>/tmp
/blob
1/test1
242 echo data1 blob2
>/tmp
/blob
2/test1
243 echo data2 blob1
>/tmp
/blob
1/test2
244 echo data2 blob2
>/tmp
/blob
2/test2
245 echo invalid filename
>/tmp
/blob
1/файл
246 echo data3
>/tmp
/external-test3
247 echo avatardata
>/tmp
/external-avatar
248 ln -s /tmp
/external-avatar
/tmp
/external-avatar-lnk
249 dd if=/dev
/urandom of
=/tmp
/external-barely-fits bs
=1M count
=64
250 dd if=/dev
/urandom of
=/tmp
/external-toobig bs
=1M count
=65
252 # create w/ prepopulated blob dir
253 NEWPASSWORD
=EMJuc3zQaMibJo homectl create blob-user \
254 --disk-size=min
--luks-discard=yes \
255 --luks-pbkdf-type=pbkdf2
--luks-pbkdf-time-cost=1ms \
256 --rate-limit-interval=1s
--rate-limit-burst=1000 \
260 PASSWORD
=EMJuc3zQaMibJo homectl activate blob-user
263 test -d /var
/cache
/systemd
/home
/blob-user
264 stat
-c "%u %#a" /var
/cache
/systemd
/home
/blob-user |
grep "^0 0755"
265 test -d /home
/blob-user
/.identity-blob
266 stat
-c "%u %#a" /home
/blob-user
/.identity-blob |
grep "^12345 0700"
268 checkblob test1
/tmp
/blob
1/test1
269 (! checkblob test1
/tmp
/blob
2/test1
)
270 checkblob test2
/tmp
/blob
1/test2
271 (! checkblob test2
/tmp
/blob
2/test2
)
272 (! checkblob фаил
/tmp
/blob
1/фаил
)
273 (! checkblob test3
/tmp
/external-test3
)
274 (! checkblob avatar
/tmp
/external-avatar
)
276 # append files to existing blob, both well-known and other
277 PASSWORD
=EMJuc3zQaMibJo homectl update blob-user \
278 -b test3
=/tmp
/external-test3
--avatar=/tmp
/external-avatar
280 checkblob test1
/tmp
/blob
1/test1
281 (! checkblob test1
/tmp
/blob
2/test1
)
282 checkblob test2
/tmp
/blob
1/test2
283 (! checkblob test2
/tmp
/blob
2/test2
)
284 (! checkblob фаил
/tmp
/blob
1/фаил
)
285 checkblob test3
/tmp
/external-test3
286 checkblob avatar
/tmp
/external-avatar
288 # delete files from existing blob, both well-known and other
289 PASSWORD
=EMJuc3zQaMibJo homectl update blob-user \
292 checkblob test1
/tmp
/blob
1/test1
293 (! checkblob test1
/tmp
/blob
2/test1
)
294 checkblob test2
/tmp
/blob
1/test2
295 (! checkblob test2
/tmp
/blob
2/test2
)
296 (! checkblob фаил
/tmp
/blob
1/фаил
)
297 (! checkblob test3
/tmp
/external-test3
)
298 (! checkblob avatar
/tmp
/external-avatar
)
300 # swap entire blob directory
301 PASSWORD
=EMJuc3zQaMibJo homectl update blob-user \
304 (! checkblob test1
/tmp
/blob
1/test1
)
305 checkblob test1
/tmp
/blob
2/test1
306 (! checkblob test2
/tmp
/blob
1/test2
)
307 checkblob test2
/tmp
/blob
2/test2
308 (! checkblob фаил
/tmp
/blob
1/фаил
)
309 (! checkblob test3
/tmp
/external-test3
)
310 (! checkblob avatar
/tmp
/external-avatar
)
312 # create and delete files while swapping blob directory. Also symlinks.
313 PASSWORD
=EMJuc3zQaMibJo homectl update blob-user \
314 -b /tmp
/blob1
-b test2
= -b test3
=/tmp
/external-test3
--avatar=/tmp
/external-avatar-lnk
316 checkblob test1
/tmp
/blob
1/test1
317 (! checkblob test1
/tmp
/blob
2/test1
)
318 (! checkblob test2
/tmp
/blob
1/test2
)
319 (! checkblob test2
/tmp
/blob
2/test2
)
320 (! checkblob фаил
/tmp
/blob
1/фаил
)
321 checkblob test3
/tmp
/external-test3
322 checkblob avatar
/tmp
/external-avatar
# target of the link
324 # clear the blob directory
325 PASSWORD
=EMJuc3zQaMibJo homectl update blob-user \
326 -b /tmp
/blob2
-b test3
=/tmp
/external-test3
--blob=
328 (! checkblob test1
/tmp
/blob
1/test1
)
329 (! checkblob test1
/tmp
/blob
2/test1
)
330 (! checkblob test2
/tmp
/blob
1/test2
)
331 (! checkblob test2
/tmp
/blob
2/test2
)
332 (! checkblob фаил
/tmp
/blob
1/фаил
)
333 (! checkblob test3
/tmp
/external-test3
)
334 (! checkblob avatar
/tmp
/external-avatar
)
336 # file that's exactly 64M still fits
337 # FIXME: Figure out why this fails on ext4.
338 if [[ "$FSTYPE" != "ext2/ext3" ]]; then
339 PASSWORD
=EMJuc3zQaMibJo homectl update blob-user \
340 -b barely-fits
=/tmp
/external-barely-fits
341 (! checkblob test1
/tmp
/blob
1/test1
)
342 (! checkblob test1
/tmp
/blob
2/test1
)
343 (! checkblob test2
/tmp
/blob
1/test2
)
344 (! checkblob test2
/tmp
/blob
2/test2
)
345 (! checkblob фаил
/tmp
/blob
1/фаил
)
346 (! checkblob test3
/tmp
/external-test3
)
347 (! checkblob avatar
/tmp
/external-avatar
)
348 checkblob barely-fits
/tmp
/external-barely-fits
351 # error out if the file is too big
352 (! PASSWORD
=EMJuc3zQaMibJo homectl update blob-user
-b huge
=/tmp
/external-toobig
)
354 # error out if filenames are invalid
355 (! PASSWORD
=EMJuc3zQaMibJo homectl update blob-user
-b .hidden
=/tmp
/external-test3
)
356 (! PASSWORD
=EMJuc3zQaMibJo homectl update blob-user
-b "with spaces=/tmp/external-test3" )
357 (! PASSWORD
=EMJuc3zQaMibJo homectl update blob-user
-b with
=equals
=/tmp
/external-test3
)
358 (! PASSWORD
=EMJuc3zQaMibJo homectl update blob-user
-b файл
=/tmp
/external-test3
)
359 (! PASSWORD
=EMJuc3zQaMibJo homectl update blob-user
-b special@chars
=/tmp
/external-test3
)
361 # Make sure offline updates to blobs get propagated in
362 homectl deactivate blob-user
364 homectl update blob-user
--offline -b barely-fits
= -b propagated
=/tmp
/external-test3
366 PASSWORD
=EMJuc3zQaMibJo homectl activate blob-user
368 (! checkblob barely-fits
/tmp
/external-barely-fits
)
369 checkblob propagated
/tmp
/external-test3
371 homectl deactivate blob-user
372 wait_for_state blob-user inactive
373 homectl remove blob-user
378 # Create a couple of user/group records to test io.systemd.DropIn
379 # See docs/USER_RECORD.md and docs/GROUP_RECORD.md
380 mkdir
-p /run
/userdb
/
381 cat >"/run/userdb/dropingroup.group" <<\EOF
383 "groupName" : "dropingroup",
387 cat >"/run/userdb/dropinuser.user" <<\EOF
389 "userName" : "dropinuser",
397 cat >"/run/userdb/dropinuser.user-privileged" <<\EOF
401 "$6$WHBKvAFFT9jKPA4k$OPY4D4TczKN/jOnJzy54DDuOOagCcvxxybrwMbe1SVdm.Bbr.zOmBdATp.QrwZmvqyr8/SafbbQu.QZ2rRvDs/"
403 "sshAuthorizedKeys" : [
404 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA//dxI2xLg4MgxIKKZv1nqwTEIlE/fdakii2Fb75pG+ foo@bar.tld",
405 "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMlaqG2rTMje5CQnfjXJKmoSpEVJ2gWtx4jBvsQbmee2XbU/Qdq5+SRisssR9zVuxgg5NA5fv08MgjwJQMm+csc= hello@world.tld"
410 # Set permissions and create necessary symlinks as described in nss-systemd(8)
411 chmod 0600 "/run/userdb/dropinuser.user-privileged"
412 ln -svrf "/run/userdb/dropingroup.group" "/run/userdb/1000000.group"
413 ln -svrf "/run/userdb/dropinuser.user" "/run/userdb/2000000.user"
414 ln -svrf "/run/userdb/dropinuser.user-privileged" "/run/userdb/2000000.user-privileged"
418 userdbctl
--help --no-pager
419 userdbctl
--no-legend
420 userdbctl
--output=classic
421 userdbctl
--output=friendly
422 userdbctl
--output=table
423 userdbctl
--output=json | jq
424 userdbctl
-j --json=pretty | jq
425 userdbctl
-j --json=short | jq
426 userdbctl
--with-varlink=no
432 userdbctl user
--disposition=regular
--disposition=intrinsic
433 userdbctl user kkkk
-z
434 userdbctl user
--uid-min=100 --uid-max=100
436 userdbctl user testuser
438 userdbctl user testuser root
439 userdbctl user
-j testuser root | jq
440 # Check only UID for the nobody user, since the name is build-configurable
441 userdbctl user
--with-nss=no
--synthesize=yes
442 userdbctl user
--with-nss=no
--synthesize=yes 0 root
65534
443 userdbctl user dropinuser
444 userdbctl user
2000000
445 userdbctl user
--with-nss=no
--with-varlink=no
--synthesize=no
--multiplexer=no dropinuser
446 userdbctl user
--with-nss=no
2000000
447 (! userdbctl user
'')
449 (! userdbctl user 🐱
'' bar
)
450 (! userdbctl user i-do-not-exist
)
451 (! userdbctl user root i-do-not-exist testuser
)
452 (! userdbctl user
--with-nss=no
--synthesize=no
0 root
65534)
453 (! userdbctl user
-N root nobody
)
454 (! userdbctl user
--with-dropin=no dropinuser
)
455 (! userdbctl user
--with-dropin=no
2000000)
461 userdbctl group
--disposition=regular
--disposition=intrinsic
462 userdbctl group kkkk
-z
463 userdbctl group
--uid-min=100 --uid-max=100
465 userdbctl group testuser
467 userdbctl group testuser root
468 userdbctl group
-j testuser root | jq
469 # Check only GID for the nobody group, since the name is build-configurable
470 userdbctl group
--with-nss=no
--synthesize=yes
471 userdbctl group
--with-nss=no
--synthesize=yes 0 root
65534
472 userdbctl group dropingroup
473 userdbctl group
1000000
474 userdbctl group
--with-nss=no
--with-varlink=no
--synthesize=no
--multiplexer=no dropingroup
475 userdbctl group
--with-nss=no
1000000
476 (! userdbctl group
'')
477 (! userdbctl group 🐱
)
478 (! userdbctl group 🐱
'' bar
)
479 (! userdbctl group i-do-not-exist
)
480 (! userdbctl group root i-do-not-exist testuser
)
481 (! userdbctl group
--with-nss=no
--synthesize=no
0 root
65534)
482 (! userdbctl group
--with-dropin=no dropingroup
)
483 (! userdbctl group
--with-dropin=no
1000000)
485 userdbctl users-in-group
486 userdbctl users-in-group testuser
487 userdbctl users-in-group testuser root
488 userdbctl users-in-group
-j testuser root | jq
489 userdbctl users-in-group 🐱
490 (! userdbctl users-in-group
'')
491 (! userdbctl users-in-group foo
'' bar
)
493 userdbctl groups-of-user
494 userdbctl groups-of-user testuser
495 userdbctl groups-of-user testuser root
496 userdbctl groups-of-user
-j testuser root | jq
497 userdbctl groups-of-user 🐱
498 (! userdbctl groups-of-user
'')
499 (! userdbctl groups-of-user foo
'' bar
)
502 userdbctl services
-j | jq
504 varlinkctl call
/run
/systemd
/userdb
/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord
'{"userName":"testuser","service":"io.systemd.Multiplexer"}'
505 varlinkctl call
/run
/systemd
/userdb
/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord
'{"userName":"root","service":"io.systemd.Multiplexer"}'
506 varlinkctl call
/run
/systemd
/userdb
/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord
'{"userName":"dropinuser","service":"io.systemd.Multiplexer"}'
507 varlinkctl call
/run
/systemd
/userdb
/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord
'{"uid":2000000,"service":"io.systemd.Multiplexer"}'
508 (! varlinkctl call
/run
/systemd
/userdb
/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord
'{"userName":"","service":"io.systemd.Multiplexer"}')
509 (! varlinkctl call
/run
/systemd
/userdb
/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord
'{"userName":"🐱","service":"io.systemd.Multiplexer"}')
510 (! varlinkctl call
/run
/systemd
/userdb
/io.systemd.Multiplexer io.systemd.UserDatabase.GetUserRecord
'{"userName":"i-do-not-exist","service":"io.systemd.Multiplexer"}')
512 userdbctl ssh-authorized-keys dropinuser |
tee /tmp
/authorized-keys
513 grep "ssh-ed25519" /tmp
/authorized-keys
514 grep "ecdsa-sha2-nistp256" /tmp
/authorized-keys
515 echo "my-top-secret-key 🐱" >/tmp
/my-top-secret-key
516 userdbctl ssh-authorized-keys dropinuser
--chain /bin
/cat /tmp
/my-top-secret-key |
tee /tmp
/authorized-keys
517 grep "ssh-ed25519" /tmp
/authorized-keys
518 grep "ecdsa-sha2-nistp256" /tmp
/authorized-keys
519 grep "my-top-secret-key 🐱" /tmp
/authorized-keys
520 (! userdbctl ssh-authorized-keys 🐱
)
521 (! userdbctl ssh-authorized-keys dropin-user
--chain)
522 (! userdbctl ssh-authorized-keys dropin-user
--chain '')
523 (! SYSTEMD_LOG_LEVEL
=debug userdbctl ssh-authorized-keys dropin-user
--chain /bin
/false
)
526 for opt
in json multiplexer output synthesize with-dropin with-nss with-varlink
; do
527 (! userdbctl
"--$opt=''")
528 (! userdbctl
"--$opt='🐱'")
529 (! userdbctl
"--$opt=foo")
530 (! userdbctl
"--$opt=foo" "--$opt=''" "--$opt=🐱")
533 # FIXME: sshd seems to crash inside asan currently, skip the actual ssh test hence
534 if command -v ssh &>/dev
/null
&& command -v sshd
&>/dev
/null
&& ! [[ -v ASAN_OPTIONS
]]; then
538 systemctl is-active
-q mysshserver.socket
&& systemctl stop mysshserver.socket
539 rm -f /tmp
/homed.id_ecdsa
/run
/systemd
/system
/mysshserver
{@.service
,.socket
}
540 systemctl daemon-reload
541 homectl remove homedsshtest
542 for dir
in /etc
/usr
/lib
; do
543 if [[ -f "$dir/pam.d/sshd.bak" ]]; then
544 mv "$dir/pam.d/sshd.bak" "$dir/pam.d/sshd"
551 # Test that SSH logins work with delayed unlocking
552 ssh-keygen
-N '' -C '' -t ecdsa
-f /tmp
/homed.id_ecdsa
553 NEWPASSWORD
=hunter4711 homectl create \
556 --luks-pbkdf-type=pbkdf2 \
557 --luks-pbkdf-time-cost=1ms \
558 --rate-limit-interval=1s \
559 --rate-limit-burst=1000 \
560 --enforce-password-policy=no \
561 --ssh-authorized-keys=@
/tmp
/homed.id_ecdsa.pub \
564 homectl inspect homedsshtest
567 test -f /etc
/ssh
/ssh_host_ecdsa_key || ssh-keygen
-t ecdsa
-C '' -N '' -f /etc
/ssh
/ssh_host_ecdsa_key
569 # ssh wants this dir around, but distros cannot agree on a common name for it, let's just create all that
570 # are aware of distros use
571 mkdir
-p /usr
/share
/empty.sshd
/var
/empty
/var
/empty
/sshd
/run
/sshd
573 for dir
in /etc
/usr
/lib
; do
574 if [[ -f "$dir/pam.d/sshd" ]]; then
575 mv "$dir/pam.d/sshd" "$dir/pam.d/sshd.bak"
576 cat >"$dir/pam.d/sshd" <<EOF
577 auth sufficient pam_unix.so nullok
578 auth sufficient pam_systemd_home.so debug
579 auth required pam_deny.so
580 account sufficient pam_systemd_home.so debug
581 account sufficient pam_unix.so
582 account required pam_permit.so
583 session optional pam_systemd_home.so debug
584 session optional pam_systemd.so
585 session required pam_unix.so
592 cat >/etc
/ssh
/sshd_config
<<EOF
593 AuthorizedKeysCommand /usr/bin/userdbctl ssh-authorized-keys %u
594 AuthorizedKeysCommandUser root
600 cat >/run
/systemd
/system
/mysshserver.socket
<<EOF
606 cat >/run
/systemd
/system
/mysshserver@.service
<<EOF
608 ExecStart=-/usr/sbin/sshd -i -d -e
610 StandardOutput=socket
611 StandardError=journal
614 systemctl daemon-reload
615 systemctl start mysshserver.socket
617 userdbctl user
-j homedsshtest
619 ssh -t -t -4 -p 4711 -i /tmp
/homed.id_ecdsa \
620 -o "SetEnv PASSWORD=hunter4711" -o "StrictHostKeyChecking no" \
621 homedsshtest@localhost
echo zzz |
tr -d '\r' |
tee /tmp
/homedsshtest.out
622 grep -E "^zzz$" /tmp
/homedsshtest.out
623 rm /tmp
/homedsshtest.out
625 ssh -t -t -4 -p 4711 -i /tmp
/homed.id_ecdsa \
626 -o "SetEnv PASSWORD=hunter4711" -o "StrictHostKeyChecking no" \
627 homedsshtest@localhost env
629 wait_for_state homedsshtest inactive
632 NEWPASSWORD
=hunter4711 homectl create aliastest
--storage=directory
--alias=aliastest2
--alias=aliastest3
--realm=myrealm
634 homectl inspect aliastest
635 homectl inspect aliastest2
636 homectl inspect aliastest3
637 homectl inspect aliastest@myrealm
638 homectl inspect aliastest2@myrealm
639 homectl inspect aliastest3@myrealm
641 userdbctl user aliastest
642 userdbctl user aliastest2
643 userdbctl user aliastest3
644 userdbctl user aliastest@myrealm
645 userdbctl user aliastest2@myrealm
646 userdbctl user aliastest3@myrealm
648 getent passwd aliastest
649 getent passwd aliastest2
650 getent passwd aliastest3
651 getent passwd aliastest@myrealm
652 getent passwd aliastest2@myrealm
653 getent passwd aliastest3@myrealm
655 if findmnt
-n -o options
/tmp |
grep -q usrquota
; then
657 NEWPASSWORD
=quux homectl create tmpfsquota
--storage=subvolume
--dev-shm-limit=50K
-P
659 run0
--property=SetCredential
=pam.authtok.systemd-run0
:quux
-u tmpfsquota
dd if=/dev
/urandom of
=/dev
/shm
/quotatestfile1 bs
=1024 count
=30
660 (! run0
--property=SetCredential
=pam.authtok.systemd-run0
:quux
-u tmpfsquota
dd if=/dev
/urandom of
=/dev
/shm
/quotatestfile2 bs
=1024 count
=30)
661 run0
--property=SetCredential
=pam.authtok.systemd-run0
:quux
-u tmpfsquota
rm /dev
/shm
/quotatestfile1
/dev
/shm
/quotatestfile2
662 run0
--property=SetCredential
=pam.authtok.systemd-run0
:quux
-u tmpfsquota
dd if=/dev
/urandom of
=/dev
/shm
/quotatestfile1 bs
=1024 count
=30
663 run0
--property=SetCredential
=pam.authtok.systemd-run0
:quux
-u tmpfsquota
rm /dev
/shm
/quotatestfile1
665 systemctl stop user@
"$(id -u tmpfsquota)".service
667 wait_for_state tmpfsquota inactive
668 homectl remove tmpfsquota
671 systemd-analyze log-level info