Bug 108514 - [feature request] Automatic registering of UID and GID (bsd.port.mk)
Summary: [feature request] Automatic registering of UID and GID (bsd.port.mk)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-29 13:50 UTC by Martin Matuska
Modified: 2009-09-06 22:20 UTC (History)
0 users

See Also:


Attachments
file.diff (8.09 KB, patch)
2007-01-29 13:50 UTC, Martin Matuska
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Matuska 2007-01-29 13:50:14 UTC
The FreeBSD Project ideas list looks for a framework for adding users/groups
to the system automatically. 

See the following URL:
http://www.freebsd.org/projects/ideas/#p-ports-uid

The patch included contains a working proposal how this framework might look like.

The main problem is to make this work with the package system -
a pre-install (or post-install) script has to be included when
creating a package with pkg_create. But the port maintainer still needs the ability
to supply his own pkg-install and pkg-deinstall scripts. 

This proposal uses the POST-INSTALL (-I) and POST-DEINSTALL (-K) features 
of pkg_create, so that two scripts can be included. This solution makes the POST_INSTALL
and POST_DEINSTALL parts of the existing pkg-install scripts not work (this does always 
apply only if ADDUSER and ADDGROUP is defined)

The question is if it is desired to have users and groups created before or after install.

There are two more approaches I considered:

1. Merging scripts
PROBLEM: impossible if /bin/sh is not used as interpreter for pkg-install or pkg-deinstall

2. Separate includable script by pkg_create
PROBLEM: no backwards compatibility with earlier freebsd versions, 
	 requires a major change to the pkg_install system
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2007-01-29 13:50:27 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

bsd.port.mk is port manager territory
Comment 2 Florent Thoumie 2007-02-02 14:54:08 UTC
@portmgr: please don't include this patch in the next exp-build as I'd
like to propose another candidate for this feature.

@submitter: I have another version of the feature you're talking about
which I think is a bit more elegant (but then again it's my patch
so...). It currently does the same thing but I'd like to include one or
two features before submitting it.

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2007-02-02 18:08:59 UTC
State Changed
From-To: open->suspended

flz has stated that he is working on a patch that has similar functionality. 
We'll wait to take a look at both of them together.
Comment 4 Gabor Kovesdan freebsd_committer freebsd_triage 2007-03-02 07:55:50 UTC
I also thought of how this could be implemented but I had no time to 
work on it. (I have to finish DESTDIR first.) I thought of the following 
knobs in port Makefiles:

USE_UID=   6667:irc 6668:ircbot

This example uses the uid 6667 with username irc and uid 6668 with 
username ircbot.

USE_UID=   auto:foobar

This example uses the first available uid with username foobar.
And I mean the same for groups with USE_GID Imho, this would be cleaner 
and more convenient in the port Makefiles and we could use the 
ADDGROUP_[group]_gid or such internally in bsd.port.mk for the actual 
implementation. What do you think?

Regards,
Gabor
Comment 5 Pav Lucistnik freebsd_committer freebsd_triage 2007-03-02 09:31:57 UTC
How do you specify homedir, shell, fullname with your USE_UID, gabor?

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

I cannot be responsible for future messages as apparently my cats have
learned to type.
Comment 6 Gabor Kovesdan freebsd_committer freebsd_triage 2007-03-02 11:18:51 UTC
Pav Lucistnik escribió:
> How do you specify homedir, shell, fullname with your USE_UID, gabor?
>
>   
Ah yes, what about 6667:irc:/nonexistent:/usr/sbin/nologin ? And auto 
would be nice here, too. As for fullname, I don't think it makes too 
much sense.

Gabor
Comment 7 Florent Thoumie 2007-04-10 15:47:32 UTC
Here's my version of the patch:

http://people.freebsd.org/~flz/local/ports/users-groups-bpm-v2.diff

Use it like this:

USERS= foo bar
GROUPS= blah

You can override the UIDs/GIDs files on a per-port basis by setting
USERSFILE/GROUPSFILE. You can add usernames in the fourth field of
GROUPSFILE to automatically put a user in a given group when it's
created. It seemed like a useful feature to me, if it's not then I'll
just remove it.

I said something about an offset feature (ie. PORTS_OFFSET_UID set to
1000 will created users with uid=1000+<value_in_UIDs_file>, same for
GIDs) but it hasn't been implemented yet. Same here, if you think it's
useful, give me a shout. It won't be long to add support for those.

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 8 Florent Thoumie freebsd_committer freebsd_triage 2007-04-11 14:30:28 UTC
Florent Thoumie wrote:
> Here's my version of the patch:
> 
> http://people.freebsd.org/~flz/local/ports/users-groups-bpm-v2.diff


Updated version:

http://people.freebsd.org/~flz/local/ports/users-groups-bpm-v3.diff

USERSFILE/GROUPSFILE have been renamed to UID_FILES/GID_FILES as
proposed by simon@. You can specify a list of files to be searched for
users/groups. Common use will be to create a new file somewhere (say
/etc/UIDs), put some values there to override /usr/ports/UIDs and set
UID_FILES="/etc/UIDs ${PORTSDIR}/UIDs" in /etc/make.conf.

I've added the offset feature, which is not documented, I hope nobody
will use it that way :-) If you know what you're doing, set UID_OFFSET
and/or GID_OFFSET and hope for the best (I've made minimal testing and
it seems to work just fine).

This new patch also fixes install from packages (few 'if's instead of
'done's).

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 9 Mark Linimon freebsd_committer freebsd_triage 2007-05-25 04:55:13 UTC
State Changed
From-To: suspended->feedback

This seems fairly complicated.  Perhaps there is a way to revisit this 
and still refactor code out of the various ports?
Comment 10 Mark Linimon freebsd_committer freebsd_triage 2008-03-02 06:35:58 UTC
State Changed
From-To: feedback->suspended

Mark suspended awaiting patches.
Comment 11 Florent Thoumie 2008-03-07 20:55:58 UTC
Discussed on IRC with Pav a couple days ago and he'd like to get a
patch with some ports converted to use these new variables.

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 12 Florent Thoumie 2008-05-19 16:20:47 UTC
Here's an updated diff with a few ports converted to USERS/GROUPS:

http://people.freebsd.org/~flz/local/ports/users-groups-bpm-v4.diff

Note that users/groups are removed at deinstall time.

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 13 Florent Thoumie 2008-05-20 13:53:16 UTC
Updated diff after the ports/UIDs format change:

http://people.freebsd.org/~flz/local/ports/users-groups-bpm-v5.diff

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 14 Florent Thoumie 2008-05-22 14:15:53 UTC
With the current patch, users and groups are unconditionally removed
at deinstall time, which is problem when more than one port require a
certain user/group. The solution would be to have a refcount for
users/groups.

This can be implemented by:

- adding a new @comment entry in the packing list and testing with
wc(1) at deinstall time.
- adding a new @user/@group entry (support needed in pkg_install), but
this means it can't be used before we de-support all FreeBSD versions
shipping pkg_install without support for those two new keywords.
- adding a new file (+UGIDS, or something else), but the remark from
the point above still applies.

This first solution is easy but pretty slow (will block on wc(1) for a
few seconds for each user/group to be removed).
The second solution is annoying (because it needs code and won't be
usable for the next two years) and slow (cause it needs to parse
+CONTENTS for all packages as well).
The third solution is a bit less annoying (cause it still needs code),
but much faster (cause +UGIDS won't exist for most packages or will be
very small).

The even easier solution, would be not to remove those users/groups.

Comments?

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 15 Dorian Büttner 2008-09-21 21:25:03 UTC
Hi folks,

just was sitting here browsing open PRs, and I was wondering what you 
would think of this one:
http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/125330
To cut a long story short, if you delete a user from the passwd-backend 
it remains in the nscd-cache for a while. This is not so good for 
automated updates of ports.
Is it something your new automatism could take care of?

Thanks,
Dorian
Comment 16 Florent Thoumie 2008-09-22 10:22:44 UTC
On Mon, Sep 22, 2008 at 12:00 AM, Dorian B=FCttner <dorian.buettner@gmx.de>=
 wrote:

>  Hi folks,
>
>  just was sitting here browsing open PRs, and I was wondering what you
>  would think of this one:
>  http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/125330
>  To cut a long story short, if you delete a user from the passwd-backend
>  it remains in the nscd-cache for a while. This is not so good for
>  automated updates of ports.
>  Is it something your new automatism could take care of?

No it's not something I've taken into account, but it's definitely a
good idea to flush the cache.

I still haven't decided what way to solve the issue I'm facing, should
really get this done soon but I'm busy with something else these days.

--=20
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 17 dfilter service freebsd_committer freebsd_triage 2009-09-06 22:18:58 UTC
flz         2009-09-06 21:18:50 UTC

  FreeBSD ports repository

  Modified files:
    Mk                   bsd.port.mk 
    audio/pulseaudio     Makefile 
    devel/dbus           Makefile pkg-install 
    sysutils/hal         Makefile 
    sysutils/hal/files   pkg-install.in 
    sysutils/policykit   Makefile pkg-install 
    x11/gdm              Makefile pkg-install 
  Removed files:
    audio/pulseaudio     pkg-install 
  Log:
  Add support to create users and groups from information stored in UIDs/GIDs
  files. Users and groups won't be deleted at deinstall time as we're lacking
  a refcount to know if any port is using them.
  
  Also convert a few ports while I'm here.
  
  PR:             ports/108514
  Submitted by:   mm, self
  
  Revision  Changes    Path
  1.627     +89 -3     ports/Mk/bsd.port.mk
  1.48      +4 -4      ports/audio/pulseaudio/Makefile
  1.6       +0 -63     ports/audio/pulseaudio/pkg-install (dead)
  1.76      +4 -1      ports/devel/dbus/Makefile
  1.6       +0 -27     ports/devel/dbus/pkg-install
  1.58      +4 -1      ports/sysutils/hal/Makefile
  1.5       +0 -27     ports/sysutils/hal/files/pkg-install.in
  1.20      +4 -1      ports/sysutils/policykit/Makefile
  1.6       +0 -27     ports/sysutils/policykit/pkg-install
  1.124     +4 -1      ports/x11/gdm/Makefile
  1.15      +0 -30     ports/x11/gdm/pkg-install
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 18 Florent Thoumie freebsd_committer freebsd_triage 2009-09-06 22:19:34 UTC
State Changed
From-To: suspended->closed

Committed. Thanks!