Page MenuHomeFreeBSD

bsd.init.mk: always define _gid when MK_INSTALL_AS_USER is set
ClosedPublic

Authored by fuz on Mon, Aug 24, 6:17 PM.
Tags
None
Referenced Files
F170940506: D59150.id184918.diff
Mon, Sep 7, 6:13 PM
F170935607: D59150.id184943.diff
Mon, Sep 7, 5:26 PM
F170885221: D59150.id.diff
Mon, Sep 7, 7:36 AM
F170843390: D59150.diff
Sun, Sep 6, 11:58 PM
F170841080: D59150.id184918.diff
Sun, Sep 6, 11:34 PM
F170840694: D59150.id184943.diff
Sun, Sep 6, 11:31 PM
Unknown Object (File)
Sun, Sep 6, 11:13 AM
Unknown Object (File)
Sun, Sep 6, 10:24 AM
Subscribers

Details

Summary

A recent commit started to use _uid and _gid in <bsd.dirs.mk> to
mangle the user and group for newly installed directories when
MK_INSTALL_AS_USER is set. However, _gid was previously only set
when _uid was not 0, causing the group to be set to the empty
string.

Set _uid and _gid together to avoid this problem.

Fixes: 541e6e2d516b6c9d3681b24464e9ef53c1f2579a
PR: 297841
Reported by: Ralph Zitz <ralph@zitz.dk>
MFC after: 1 week

Test Plan

port security/unix-selfauth-helper builds fine as root following this change.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

fuz requested review of this revision.Mon, Aug 24, 6:17 PM

Looks fine, but shouldn't this and bsd.dirs.mk have the same (${_uid} != 0) logic?

@emaste Sounds like a reasonable idea. I'll wait for @imp to decide as he came up with the logic in the first place.

I have this in my tree too, but I've not had time to test it out. If you do, then I think it's the right thing :)

This revision is now accepted and ready to land.Mon, Aug 24, 10:26 PM

Any comment on the other question @imp? I.e., why don't we use .if ${_uid} != 0 in bsd.dirs.mk also?

Any comment on the other question @imp? I.e., why don't we use .if ${_uid} != 0 in bsd.dirs.mk also?

Both should always be defined. I didn't see that one had better behavior (or different) than the other.

In D59150#1356946, @imp wrote:

Any comment on the other question @imp? I.e., why don't we use .if ${_uid} != 0 in bsd.dirs.mk also?

Both should always be defined. I didn't see that one had better behavior (or different) than the other.

I think @emaste's question is more about whether bsd.dirs.mk should also special case ${_uid} == 0 and then not change the uid and gid of installed directories when you are root but supply MK_INSTALL_AS_USER as we do in bsd.init.mk.

In D59150#1357225, @fuz wrote:
In D59150#1356946, @imp wrote:

Any comment on the other question @imp? I.e., why don't we use .if ${_uid} != 0 in bsd.dirs.mk also?

Both should always be defined. I didn't see that one had better behavior (or different) than the other.

I think @emaste's question is more about whether bsd.dirs.mk should also special case ${_uid} == 0 and then not change the uid and gid of installed directories when you are root but supply MK_INSTALL_AS_USER as we do in bsd.init.mk.

It's a more orthogonal design, but I do see the point, despite it not being name MK_INSTALL_AS_USER_UNLESS_ROOT... I'm honestly not sure why we have this check here, honestly, and don't think it should be both places.