9969 svccfg: honour PKG_INSTALL_ROOT when building hash filename

Review Request #1276 — Created Nov. 8, 2018 and submitted

citrus
illumos-gate
master
9969
b7d4489...
general
ptribble
svccfg: honour PKG_INSTALL_ROOT when building hash filename

When seeding an SMF database, the paths to the imported manifests end up stored in two places within the repository database:

  • The manifestfiles property of the imported service;
  • A per-service tree within the smf/manifest service.

For example:

bloody% cp /lib/svc/seed/global.db /tmp
bloody% export SVCCFG_REPOSITORY=/tmp/global.db
bloody% export SVCCFG_CHECKHASH=1
bloody% svccfg import /kayak_image/r151029/lib/svc/manifest/network/ntp.xml

bloody% svccfg -s ntp listprop manifestfiles
manifestfiles                                                       framework
manifestfiles/kayak_image_r151029_lib_svc_manifest_network_ntp_xml  astring  /kayak_image/r151029/lib/svc/manifest/network/ntp.xml

bloody% svccfg -s manifest listprop | grep ntp
kayak_image_r151029_lib_svc_manifest_network_ntp_xml               framework
kayak_image_r151029_lib_svc_manifest_network_ntp_xml/manifestfile  astring  /kayak_image/r151029/lib/svc/manifest/network/ntp.xml
kayak_image_r151029_lib_svc_manifest_network_ntp_xml/md5sum        opaque   afcd99c29f0dedcf40278f1bf0253f6286787107e11c23bcac675faffed78f41

It's possible to set the PKG_INSTALL_ROOT environment variable in order to modify these embedded paths, which fixes the keys and the path stored in the service itself, but not the path in smf/manifest:

bloody% export PKG_INSTALL_ROOT=/kayak_image/r151029
bloody% svccfg import /kayak_image/r151029/lib/svc/manifest/network/ntp.xml

bloody% svccfg -s ntp listprop manifestfiles
manifestfiles                                   framework
manifestfiles/lib_svc_manifest_network_ntp_xml  astring  /lib/svc/manifest/network/ntp.xml

bloody% svccfg -s manifest listprop | grep ntp
lib_svc_manifest_network_ntp_xml               framework
lib_svc_manifest_network_ntp_xml/manifestfile  astring  /kayak_image/r151029/lib/svc/manifest/network/ntp.xml
lib_svc_manifest_network_ntp_xml/md5sum        opaque   afcd99c29f0dedcf40278f1bf0253f6286787107e11c23bcac675faffed78f41

This changes the hashing code so that this path is updated along with the others.

tsoome
  1. Ship It!
  2. 
      
domag02
  1. Ship It!
  2. 
      
citrus
ptribble
  1. I'm wondering whether the behaviour is correct in the following 2 cases:

    1. PKG_INSTALL_ROOT = "/" - it strips the leading / from the file name.

    2. PKG_INSTALL_ROOT ends with a trailing / - likewise

    This would apply to the existing code as well.

    (Being "/" is entirely legitimate, if superfluous, and we have some cases where this is checked for. The simplest catch is probably to verify for length greater than 1. A path ending in / is likely user error, but might happen if people use shell autocompletion.)

    1. The behaviour would be incorrect in those two cases but this appears to be an undocumented option (for svccfg anyway). The way that this variable is set day-to-day is from SVR4 packaging commands such as pkgadd -R which perform the checks that you suggest along with an error if a relative path is provided.

      Setting the environment variable directly and invoking svccfg is likely only useful for distribution builders who want to pre-seed the SMF database (as Tribblix and OmniOS both do).

      I'd rather not add the additional checks as I'd need to modify the other two places in svccfg where path substitution is done - the worst that happens is that the manifest gets removed on the first boot and added back on the second (as can happen now due to this bug).

    2. That's fine; I just wanted to make sure it had been considered.

  2. 
      
ptribble
  1. Ship It!
  2. 
      
citrus
Review request changed

Status: Closed (submitted)

Loading...