Gentoo Archives: gentoo-dev

From: Ian Stakenvicius <axs@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] RFC: enewuser should force updates to shell and home
Date: Wed, 13 Jun 2012 16:02:05
Message-Id: 4FD8B910.3090606@gentoo.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hey all - I'd like to propose that enewuser forces updates to a user's
home dir and shell whenever it is called, so that if this changes with
new versions of an ebuild it is dealt with automatically rather than
having to modify them in pkg_postinst/pkg_setup directly.

Here's my proposed patch to user.eclass -- please note that I can't
conform the syntax for the darwin ('dscl') calls as I don't have
access and my googling did not provide an exact-match in terms of
usage.  The rest i'm highly confident will work based on the manpages
I was able to find.  If anyone has these platforms and can test/update
the calls, I would appreciate it.


- --- user.eclass 2011-12-19 14:38:34.000000000 -0500
+++ user.eclass.forcehomedir    2012-06-13 11:54:26.000000000 -0400
@@ -230,24 +230,39 @@
                for g in "${egroups_arr[@]}" ; do
                        dscl . merge "/groups/${g}" users "${euser}"
                done
+               ### force updates of some user properties
+               dscl . change "/users/${euser}" home "${ehome}"
+               dscl . change "/users/${euser}" shell "${eshell}"
                ;;

        *-freebsd*|*-dragonfly*)
                pw useradd "${euser}" "${opts[@]}" || die
+               ### force updates of some user properties
+               pw usermod "${euser}" -d "${ehome}" || die
+               pw usermod "${euser}" -s "${eshell}" || die
                ;;

        *-netbsd*)
                useradd "${opts[@]}" "${euser}" || die
+               ### force updates of some user properties
+               usermod -d "${ehome}" "${euser}" || die
+               usermod -s "${eshell}" "${euser}" || die
                ;;

        *-openbsd*)
                # all ops the same, except the -g vs -g/-G ...
                useradd -u ${euid} -s "${eshell}" \
                        -d "${ehome}" -g "${egroups}" "${euser}" || die
+               ### force updates of some user properties
+               usermod -d "${ehome}" "${euser}" || die
+               usermod -s "${eshell}" "${euser}" || die
                ;;

        *)
                useradd -r "${opts[@]}" "${euser}" || die
+               ### force updates of some user properties
+               usermod -d "${ehome}" "${euser}" || die
+               usermod -s "${eshell}" "${euser}" || die
                ;;
        esac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iF4EAREIAAYFAk/YuRAACgkQ2ugaI38ACPCCxgD/TUhHRThNOHOGoR04CwRwx+Nt
oEJy0MdknD0KDm/uT5oA/AiYZ9fDthJEmPyOgFra+BnWqLCkexvqz+K5SaoS1Pyw
=+xJb
-----END PGP SIGNATURE-----

Replies