[haiku-bugs] Re: [Haiku] #14382: Package kit boot activation doesn't create users

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Tue, 05 Nov 2019 08:26:47 -0000

#14382: Package kit boot activation doesn't create users
--------------------------------+----------------------------
   Reporter:  kallisti5         |      Owner:  nobody
       Type:  bug               |     Status:  new
   Priority:  high              |  Milestone:  R1/beta2
  Component:  Kits/Package Kit  |    Version:  R1/Development
 Resolution:                    |   Keywords:
 Blocked By:                    |   Blocking:
Has a Patch:  0                 |   Platform:  All
--------------------------------+----------------------------
Comment (by ambroff):

 I started looking into this. I'm still learning how the package system
 works, but I think I see a few problems right off the bat.

 Problem #1: The package daemon tries to load the activated-packages file
 from the incorrect location when initializing a new volume in
 
[https://github.com/haiku/haiku/blob/f6f19105dccc07fcf567d1b6b243ffdb54eb2058/src/servers/package/Volume.cpp#L990
 Volume::_InitLatestStateFromActivatedPackages()]. It tries to read
 /boot/system/packages/activated-packages instead of
 /boot/system/packages/administrative/activated-packages.

 This should probably be something more like this (although I'm not totally
 sure I'm using the StorageKit API properly):


 {{{
 status_t
 Volume::_InitLatestStateFromActivatedPackages()
 {
         BDirectory adminDirectory;
         status_t error = _OpenPackagesSubDirectory(
                 RelativePath(kAdminDirectoryName),
                 false,
                 adminDirectory);
         if (error != B_OK)
                 return error;

         BPath activationFilePath(&adminDirectory, kActivationFileName);
         activationFilePath.Append(kActivationFileName);

         BFile file;
         error = file.SetTo(activationFilePath.Path(), B_READ_ONLY);
         ...
 }}}


 Problem #2: Packages are marked as activated
 
[https://github.com/haiku/haiku/blob/f6f19105dccc07fcf567d1b6b243ffdb54eb2058/src/servers/package/Volume.cpp#L975
 if the activated-packages file is not found]. In the case of first boot
 after running the installer, there is no activated-packages file, so all
 packages are marked as activated even if the activation logic has not been
 performed.

 Problem #3: Nothing performs activation on boot. Even if activated-
 packages does exist, and a new package has been added to the packages dir
 to be activated at boot, the activation will not happen until the user
 
[https://github.com/haiku/haiku/blob/f6f19105dccc07fcf567d1b6b243ffdb54eb2058/src/servers/package/CommitTransactionHandler.cpp#L614
 initiates a new transaction], since that is the only place where
 activation logic is performed.

 The only place where activation will happen automatically is
 
[https://github.com/haiku/haiku/blob/f6f19105dccc07fcf567d1b6b243ffdb54eb2058/src/servers/package/Root.cpp#L441
 in response to a filesystem notification] that a package has been copied
 into the packages directory. Booting up after a fresh install and moving
 the openssh package out of /boot/system/packages and then moving it back
 at least gets it far enough to create users.

 I'm still trying to understand the code so I may be missing something.
 Assuming my conclusion above is correct, I think the right thing to do is
 to 1.) assume no packages are activated if activated-packages is missing
 and 2.) on boot, for each package not yet active trigger the same code
 that is executed in
 
[https://github.com/haiku/haiku/blob/f6f19105dccc07fcf567d1b6b243ffdb54eb2058/src/servers/package/Root.cpp#L441
 src/servers/package/Root.cpp] in response to filesystem events.
-- 
Ticket URL: <https://dev.haiku-os.org/ticket/14382#comment:5>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: