* [PATCH V2 0/1] image.bbclass: add a method for image level user/group configuration @ 2013-07-10 6:28 Qi.Chen 2013-07-10 6:28 ` [PATCH V2 1/1] image.bbclass: add a method to add/delete/modify user/group settings Qi.Chen 0 siblings, 1 reply; 4+ messages in thread From: Qi.Chen @ 2013-07-10 6:28 UTC (permalink / raw) To: openembedded-core; +Cc: qingtao.cao From: Chen Qi <Qi.Chen@windriver.com> The following changes since commit 80b263430453896189b704d0997943642eec6fef: classes/insane: remove la2 check which no longer exists from ERROR_QA (2013-06-28 16:33:08 +0100) are available in the git repository at: git://git.pokylinux.org/poky-contrib ChenQi/user_group_settings http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/user_group_settings Chen Qi (1): image.bbclass: add a method to add/delete/modify user/group settings meta/classes/image.bbclass | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) -- 1.7.9.5 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH V2 1/1] image.bbclass: add a method to add/delete/modify user/group settings 2013-07-10 6:28 [PATCH V2 0/1] image.bbclass: add a method for image level user/group configuration Qi.Chen @ 2013-07-10 6:28 ` Qi.Chen 2013-07-10 20:02 ` Saul Wold 0 siblings, 1 reply; 4+ messages in thread From: Qi.Chen @ 2013-07-10 6:28 UTC (permalink / raw) To: openembedded-core; +Cc: qingtao.cao From: Chen Qi <Qi.Chen@windriver.com> We may want to add a user or group which does not logically belong to any specific package. For example, we may want to add a user with the name 'tester' to our image. Besides, we may want to delete or modify user/group in our image. This patch adds a variable, USER_GROUP_SETTINGS, which is dedicated to these tasks. The configuration format is detailed in the local.conf. sample.extended file. This patch also adds a function, set_user_group, which happens at the end of the ROOTFS_POSTPROCESS_COMMAND. It handles the settings in the USER_GROUP_SETTINGS variable. This logic here is quite similar to that of useradd.bbclass. If we need to add or modify user/group settings, base-passwd and shadow are pulled into the RDEPENDS and thus installed on target. [YOCTO #4074] Signed-off-by: Chen Qi <Qi.Chen@windriver.com> --- meta/classes/image.bbclass | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 380ed8e..a76289c 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -12,6 +12,8 @@ LICENSE = "MIT" PACKAGES = "" DEPENDS += "${MLPREFIX}qemuwrapper-cross ${MLPREFIX}depmodwrapper-cross" RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}" +# Add to IMAGE_INSTALL base-passwd and shadow if USER_GROUP_SETTINGS is set +IMAGE_INSTALL_append += "${@['', 'base-passwd shadow'][bool(d.getVar('USER_GROUP_SETTINGS', True))]}" RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}" INHIBIT_DEFAULT_DEPS = "1" @@ -179,6 +181,8 @@ ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks" ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "postinst_enable_logging; ", "",d)}' # Set default postinst log file POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log" +# Image level user / group settings +ROOTFS_POSTPROCESS_COMMAND_append = " set_user_group;" # some default locales IMAGE_LINGUAS ?= "de-de fr-fr en-gb" @@ -528,6 +532,44 @@ postinst_enable_logging () { echo "LOGFILE=${POSTINST_LOGFILE}" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst } +# Image level user / group settings +set_user_group () { + user_group_settings="${USER_GROUP_SETTINGS}" + export PSEUDO="${FAKEROOTENV} ${STAGING_DIR_NATIVE}${bindir}/pseudo" + setting=`echo $user_group_settings | cut -d ';' -f1` + remaining=`echo $user_group_settings | cut -d ';' -f2-` + while test "x$setting" != "x"; do + user_group=`echo $setting | cut -d ',' -f1` + action=`echo $setting | cut -d ',' -f2` + opts=`echo $setting | cut -d ',' -f3` + # determine the command according to user_group and action + if [ "$user_group" = "USER" ]; then + cmd_prefix="user" + elif [ "$user_group" = "GROUP" ]; then + cmd_prefix="group" + else + echo "Error: invalid setting of $user_group in the USER_GROUP_SETTINGS" + exit 1 + fi + if [ "$action" = "ADD" ]; then + cmd_suffix="add" + elif [ "$action" = "DEL" ]; then + cmd_suffix="del" + elif [ "$action" = "MOD" ]; then + cmd_suffix="mod" + else + echo "Error: invalid setting of $user_group in the USER_GROUP_SETTINGS" + exit 1 + fi + cmd=$cmd_prefix$cmd_suffix + echo "using commond <$cmd> for setting <$setting> ..." + eval $PSEUDO $cmd -R ${IMAGE_ROOTFS} $opts + # iterate to the next setting + setting=`echo $remaining | cut -d ';' -f1` + remaining=`echo $remaining | cut -d ';' -f2-` + done +} + # Turn any symbolic /sbin/init link into a file remove_init_link () { if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2 1/1] image.bbclass: add a method to add/delete/modify user/group settings 2013-07-10 6:28 ` [PATCH V2 1/1] image.bbclass: add a method to add/delete/modify user/group settings Qi.Chen @ 2013-07-10 20:02 ` Saul Wold 2013-07-11 2:56 ` ChenQi 0 siblings, 1 reply; 4+ messages in thread From: Saul Wold @ 2013-07-10 20:02 UTC (permalink / raw) To: Qi.Chen; +Cc: qingtao.cao, openembedded-core On 07/09/2013 11:28 PM, Qi.Chen@windriver.com wrote: > From: Chen Qi <Qi.Chen@windriver.com> > > We may want to add a user or group which does not logically belong to > any specific package. For example, we may want to add a user with the > name 'tester' to our image. Besides, we may want to delete or modify > user/group in our image. > > This patch adds a variable, USER_GROUP_SETTINGS, which is dedicated > to these tasks. The configuration format is detailed in the local.conf. > sample.extended file. > > This patch also adds a function, set_user_group, which happens at > the end of the ROOTFS_POSTPROCESS_COMMAND. It handles the settings > in the USER_GROUP_SETTINGS variable. > After seeing the poky-tiny changes, which I will NAK, I am going to recommend that we need to share a common base between this and the existing useradd bbclass since you are both doing the same work. Also, I think what ever the top level looks like, it should be in a class of it's own that can be inherited, such that it won't affect other images, like a tiny or other distros that don't include login support. I understand the difference and usage of useradd is targeting packages and feeds, while this work is targeted towards customizing a final image that is not truly part of the package feed. Sau! > This logic here is quite similar to that of useradd.bbclass. If we > need to add or modify user/group settings, base-passwd and shadow > are pulled into the RDEPENDS and thus installed on target. > > [YOCTO #4074] > > Signed-off-by: Chen Qi <Qi.Chen@windriver.com> > --- > meta/classes/image.bbclass | 42 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 380ed8e..a76289c 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -12,6 +12,8 @@ LICENSE = "MIT" > PACKAGES = "" > DEPENDS += "${MLPREFIX}qemuwrapper-cross ${MLPREFIX}depmodwrapper-cross" > RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}" > +# Add to IMAGE_INSTALL base-passwd and shadow if USER_GROUP_SETTINGS is set > +IMAGE_INSTALL_append += "${@['', 'base-passwd shadow'][bool(d.getVar('USER_GROUP_SETTINGS', True))]}" > RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}" > > INHIBIT_DEFAULT_DEPS = "1" > @@ -179,6 +181,8 @@ ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks" > ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "postinst_enable_logging; ", "",d)}' > # Set default postinst log file > POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log" > +# Image level user / group settings > +ROOTFS_POSTPROCESS_COMMAND_append = " set_user_group;" > > # some default locales > IMAGE_LINGUAS ?= "de-de fr-fr en-gb" > @@ -528,6 +532,44 @@ postinst_enable_logging () { > echo "LOGFILE=${POSTINST_LOGFILE}" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst > } > > +# Image level user / group settings > +set_user_group () { > + user_group_settings="${USER_GROUP_SETTINGS}" > + export PSEUDO="${FAKEROOTENV} ${STAGING_DIR_NATIVE}${bindir}/pseudo" > + setting=`echo $user_group_settings | cut -d ';' -f1` > + remaining=`echo $user_group_settings | cut -d ';' -f2-` > + while test "x$setting" != "x"; do > + user_group=`echo $setting | cut -d ',' -f1` > + action=`echo $setting | cut -d ',' -f2` > + opts=`echo $setting | cut -d ',' -f3` > + # determine the command according to user_group and action > + if [ "$user_group" = "USER" ]; then > + cmd_prefix="user" > + elif [ "$user_group" = "GROUP" ]; then > + cmd_prefix="group" > + else > + echo "Error: invalid setting of $user_group in the USER_GROUP_SETTINGS" > + exit 1 > + fi > + if [ "$action" = "ADD" ]; then > + cmd_suffix="add" > + elif [ "$action" = "DEL" ]; then > + cmd_suffix="del" > + elif [ "$action" = "MOD" ]; then > + cmd_suffix="mod" > + else > + echo "Error: invalid setting of $user_group in the USER_GROUP_SETTINGS" > + exit 1 > + fi > + cmd=$cmd_prefix$cmd_suffix > + echo "using commond <$cmd> for setting <$setting> ..." > + eval $PSEUDO $cmd -R ${IMAGE_ROOTFS} $opts > + # iterate to the next setting > + setting=`echo $remaining | cut -d ';' -f1` > + remaining=`echo $remaining | cut -d ';' -f2-` > + done > +} > + > # Turn any symbolic /sbin/init link into a file > remove_init_link () { > if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2 1/1] image.bbclass: add a method to add/delete/modify user/group settings 2013-07-10 20:02 ` Saul Wold @ 2013-07-11 2:56 ` ChenQi 0 siblings, 0 replies; 4+ messages in thread From: ChenQi @ 2013-07-11 2:56 UTC (permalink / raw) To: Saul Wold; +Cc: qingtao.cao, openembedded-core On 07/11/2013 04:02 AM, Saul Wold wrote: > On 07/09/2013 11:28 PM, Qi.Chen@windriver.com wrote: >> From: Chen Qi <Qi.Chen@windriver.com> >> >> We may want to add a user or group which does not logically belong to >> any specific package. For example, we may want to add a user with the >> name 'tester' to our image. Besides, we may want to delete or modify >> user/group in our image. >> >> This patch adds a variable, USER_GROUP_SETTINGS, which is dedicated >> to these tasks. The configuration format is detailed in the local.conf. >> sample.extended file. >> >> This patch also adds a function, set_user_group, which happens at >> the end of the ROOTFS_POSTPROCESS_COMMAND. It handles the settings >> in the USER_GROUP_SETTINGS variable. >> > After seeing the poky-tiny changes, which I will NAK, I am going to > recommend that we need to share a common base between this and the > existing useradd bbclass since you are both doing the same work. > > Also, I think what ever the top level looks like, it should be in a > class of it's own that can be inherited, such that it won't affect > other images, like a tiny or other distros that don't include login > support. > > I understand the difference and usage of useradd is targeting packages > and feeds, while this work is targeted towards customizing a final > image that is not truly part of the package feed. > > Sau! > Thanks for your suggestion. That's definitely a better approach. I'll rework on this feature. Best Regards, Chen Qi >> This logic here is quite similar to that of useradd.bbclass. If we >> need to add or modify user/group settings, base-passwd and shadow >> are pulled into the RDEPENDS and thus installed on target. >> > > >> [YOCTO #4074] >> >> Signed-off-by: Chen Qi <Qi.Chen@windriver.com> >> --- >> meta/classes/image.bbclass | 42 >> ++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 42 insertions(+) >> >> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass >> index 380ed8e..a76289c 100644 >> --- a/meta/classes/image.bbclass >> +++ b/meta/classes/image.bbclass >> @@ -12,6 +12,8 @@ LICENSE = "MIT" >> PACKAGES = "" >> DEPENDS += "${MLPREFIX}qemuwrapper-cross >> ${MLPREFIX}depmodwrapper-cross" >> RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} >> ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}" >> +# Add to IMAGE_INSTALL base-passwd and shadow if USER_GROUP_SETTINGS >> is set >> +IMAGE_INSTALL_append += "${@['', 'base-passwd >> shadow'][bool(d.getVar('USER_GROUP_SETTINGS', True))]}" >> RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}" >> >> INHIBIT_DEFAULT_DEPS = "1" >> @@ -179,6 +181,8 @@ ROOTFS_POSTPROCESS_COMMAND += >> '${@base_contains("IMAGE_FEATURES", "debug-tweaks" >> ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", >> "debug-tweaks", "postinst_enable_logging; ", "",d)}' >> # Set default postinst log file >> POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log" >> +# Image level user / group settings >> +ROOTFS_POSTPROCESS_COMMAND_append = " set_user_group;" >> >> # some default locales >> IMAGE_LINGUAS ?= "de-de fr-fr en-gb" >> @@ -528,6 +532,44 @@ postinst_enable_logging () { >> echo "LOGFILE=${POSTINST_LOGFILE}" >> >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst >> } >> >> +# Image level user / group settings >> +set_user_group () { >> + user_group_settings="${USER_GROUP_SETTINGS}" >> + export PSEUDO="${FAKEROOTENV} >> ${STAGING_DIR_NATIVE}${bindir}/pseudo" >> + setting=`echo $user_group_settings | cut -d ';' -f1` >> + remaining=`echo $user_group_settings | cut -d ';' -f2-` >> + while test "x$setting" != "x"; do >> + user_group=`echo $setting | cut -d ',' -f1` >> + action=`echo $setting | cut -d ',' -f2` >> + opts=`echo $setting | cut -d ',' -f3` >> + # determine the command according to user_group and action >> + if [ "$user_group" = "USER" ]; then >> + cmd_prefix="user" >> + elif [ "$user_group" = "GROUP" ]; then >> + cmd_prefix="group" >> + else >> + echo "Error: invalid setting of $user_group in the >> USER_GROUP_SETTINGS" >> + exit 1 >> + fi >> + if [ "$action" = "ADD" ]; then >> + cmd_suffix="add" >> + elif [ "$action" = "DEL" ]; then >> + cmd_suffix="del" >> + elif [ "$action" = "MOD" ]; then >> + cmd_suffix="mod" >> + else >> + echo "Error: invalid setting of $user_group in the >> USER_GROUP_SETTINGS" >> + exit 1 >> + fi >> + cmd=$cmd_prefix$cmd_suffix >> + echo "using commond <$cmd> for setting <$setting> ..." >> + eval $PSEUDO $cmd -R ${IMAGE_ROOTFS} $opts >> + # iterate to the next setting >> + setting=`echo $remaining | cut -d ';' -f1` >> + remaining=`echo $remaining | cut -d ';' -f2-` >> + done >> +} >> + >> # Turn any symbolic /sbin/init link into a file >> remove_init_link () { >> if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then >> > > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-11 2:56 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-07-10 6:28 [PATCH V2 0/1] image.bbclass: add a method for image level user/group configuration Qi.Chen 2013-07-10 6:28 ` [PATCH V2 1/1] image.bbclass: add a method to add/delete/modify user/group settings Qi.Chen 2013-07-10 20:02 ` Saul Wold 2013-07-11 2:56 ` ChenQi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox