Opened 16 months ago

Last modified 5 weeks ago

#14382 new bug

Package kit boot activation doesn't create users

Reported by: kallisti5 Owned by: nobody
Priority: high Milestone: R1/beta2
Component: Kits/Package Kit Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All


If a package is activated at boot, any required users are not created. If package is activated post-boot... users are created.

~> id alex
id: ‘alex’: no such user
~> id sshd
id: ‘sshd’: no such user
~> mv /boot/system/packages/usertest-1.0-1-x86_64.hpkg ~/
~> id alex
id: ‘alex’: no such user
~> mv ~/usertest-1.0-1-x86_64.hpkg /boot/system/packages/
~> id alex
id: ‘alex’: no such user
~> id alex
id: ‘alex’: no such user
~> id alex
id: ‘alex’: no such user
~> id alex
id: ‘alex’: no such user
~> id alex
uid=1000(alex) gid=100(users) groups=100(users)
~> id sshd
id: ‘sshd’: no such user

This explains why the sshd user isn't created at first (or any) boot, and must be created manually.

Change History (5)

comment:1 by kallisti5, 16 months ago

~> package list /boot/system/packages/usertest-1.0-1-x86_64.hpkg
        name: usertest
        summary: Testing the creation of alex
        description: Alex is love, alex is life
        vendor: Haiku Project
        packager: Alexander von Gluck IV <>
        architecture: x86_64
        version: 1.0-1
        copyright: 1985-2018 Alexander von Gluck IV
        license: MIT
        source URL:
        source URL:
        provides: usertest = 1.0 (compatible >= 1)
        requires: haiku>=r1~alpha4_pm_hrev52254-1
        user: alex
                real name: alex user
                home:      /packages/usertest-1.0-1/.self/data/openssh/empty
                shell:     /bin/true
        group: alexgroup
.PackageInfo                           779  2018-08-21 19:34:37  -rw-r--r--
~> cat /Data/haikuports/net-misc/usertest/usertest-1.0.recipe 
SUMMARY="Testing the creation of alex"
DESCRIPTION="Alex is love, alex is life"
COPYRIGHT="1985-2018 Alexander von Gluck IV"
ARCHITECTURES="x86_gcc2 x86 x86_64"

        usertest = $portVersion compat >= 1


        alex real-name \"alex user\" home \"$sshdUserHomeDir\" shell \"/bin/true\"




Haiku shredder 1 hrev52254 Aug 20 2018 15:59:03 x86_64 x86_64 Haiku

comment:2 by kallisti5, 16 months ago

Blocking: 14086 added

comment:3 by waddlesplash, 16 months ago

Blocking: 14086 removed

comment:4 by pulkomandy, 9 months ago

Milestone: UnscheduledR1/beta2
Priority: normalhigh

This prevents ssh from working out of the box in Haiku installs, would be nice to fix...

Tentative scheduling for beta2 hoping someone takes care of it :)

comment:5 by ambroff, 5 weeks ago

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 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):

	BDirectory adminDirectory;
	status_t error = _OpenPackagesSubDirectory(
	if (error != B_OK)
		return error;

	BPath activationFilePath(&adminDirectory, kActivationFileName);

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

Problem 2: Packages are marked as activated 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 initiates a new transaction, since that is the only place where activation logic is performed.

The only place where activation will happen automatically is 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 src/servers/package/Root.cpp in response to filesystem events.

Last edited 5 weeks ago by ambroff (previous) (diff)
Note: See TracTickets for help on using tickets.