qubes-core-agent.preinst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. # preinst script for core-agent-linux
  3. #
  4. # see: dh_installdeb(1)
  5. set -e
  6. # The preinst script may be called in the following ways:
  7. # * <new-preinst> 'install'
  8. # * <new-preinst> 'install' <old-version>
  9. # * <new-preinst> 'upgrade' <old-version>
  10. #
  11. # The package will not yet be unpacked, so the preinst script cannot rely
  12. # on any files included in its package. Only essential packages and
  13. # pre-dependencies (Pre-Depends) may be assumed to be available.
  14. # Pre-dependencies will have been configured at least once, but at the time the
  15. # preinst is called they may only be in an "Unpacked" or "Half-Configured" state
  16. # if a previous version of the pre-dependency was completely configured and has
  17. # not been removed since then.
  18. #
  19. #
  20. # * <old-preinst> 'abort-upgrade' <new-version>
  21. #
  22. # Called during error handling of an upgrade that failed after unpacking the
  23. # new package because the postrm upgrade action failed. The unpacked files may
  24. # be partly from the new version or partly missing, so the script cannot rely
  25. # on files included in the package. Package dependencies may not be available.
  26. # Pre-dependencies will be at least "Unpacked" following the same rules as
  27. # above, except they may be only "Half-Installed" if an upgrade of the
  28. # pre-dependency failed.[46]
  29. #
  30. # For details, see http://www.debian.org/doc/debian-policy/ or
  31. # https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or
  32. # the debian-policy package
  33. if [ "$1" = "install" ] ; then
  34. # --------------------------------------------------------------------------
  35. # Required groups
  36. # --------------------------------------------------------------------------
  37. groupadd --force --system qubes
  38. groupadd --force --system sudo
  39. # --------------------------------------------------------------------------
  40. # User add / modifications
  41. # --------------------------------------------------------------------------
  42. id -u 'user' >/dev/null 2>&1 || {
  43. useradd --password "" --user-group --create-home --shell /bin/bash user
  44. }
  45. id -u 'tinyproxy' >/dev/null 2>&1 || {
  46. useradd --user-group --system -M --home /run/tinyproxy --shell /bin/false tinyproxy
  47. }
  48. usermod -p '' root
  49. usermod -L -a --groups qubes,sudo user
  50. # --------------------------------------------------------------------------
  51. # Remove `mesg` from root/.profile?
  52. # --------------------------------------------------------------------------
  53. sed -i -e '/^mesg n/d' /root/.profile
  54. fi
  55. if [ "$1" = "upgrade" ] ; then
  56. ## Fix static gid issue for in place template upgrades.
  57. ## https://github.com/QubesOS/qubes-issues/issues/1105
  58. if grep -q ^qubes:x:98: /etc/group ; then
  59. if ! grep -q :980: /etc/group ; then
  60. if groupmod -g 980 qubes ; then
  61. # make sure that vchan will still work until VM start
  62. chmod 666 /dev/xen/* /proc/xen/privcmd
  63. find / -gid 98 ! -type l -exec chgrp --verbose qubes {} \; 2>/dev/null || true
  64. fi
  65. fi
  66. fi
  67. ## Allow passwordless login for user "user" (when using 'sudo xl console').
  68. ## https://github.com/QubesOS/qubes-issues/issues/1130
  69. if grep -q '^user:\!:' /etc/shadow ; then
  70. passwd user -d >/dev/null || true
  71. fi
  72. fi
  73. # dh_installdeb will replace this with shell code automatically
  74. # generated by other debhelper scripts.
  75. #DEBHELPER#
  76. exit 0
  77. # vim: set ts=4 sw=4 sts=4 et :