All of lore.kernel.org
 help / color / mirror / Atom feed
* Post USERADD_PARAM action
@ 2015-05-22 11:37 Laszlo Papp
  2015-05-25 21:32 ` adduser: add -k [was: Re: Post USERADD_PARAM action] Bernhard Reutner-Fischer
  2015-05-28  1:23 ` Post USERADD_PARAM action Khem Raj
  0 siblings, 2 replies; 4+ messages in thread
From: Laszlo Papp @ 2015-05-22 11:37 UTC (permalink / raw)
  To: openembedded-core

Hi,

is it possible to do some post action after useradd_param is executed?

I would like to modify the created user's home directory, in this
special case the profile. I see that the useradd util has this on
desktop, but busybox does not have it, and very likely will not have
it, at least not in the near future anyway:

       -k, --skel SKEL_DIR
           The skeleton directory, which contains files and
directories to be copied in the user's home directory, when the home
directory is created by useradd.

           This option is only valid if the -m (or --create-home)
option is specified.

           If this option is not set, the skeleton directory is
defined by the SKEL variable in /etc/default/useradd or, by default,
/etc/skel.

           If possible, the ACLs and extended attributes are copied.

I would like to do something like this with the created user's home directory:

echo PATH=/sbin:$PATH > /home/foo/.profile
chmod foo:foo /home/foo/.profile

But then again, for this, I need to make sure that the user is already created.

Ys, L.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* adduser: add -k [was: Re: Post USERADD_PARAM action]
  2015-05-22 11:37 Post USERADD_PARAM action Laszlo Papp
@ 2015-05-25 21:32 ` Bernhard Reutner-Fischer
  2015-05-26  9:08   ` Laszlo Papp
  2015-05-28  1:23 ` Post USERADD_PARAM action Khem Raj
  1 sibling, 1 reply; 4+ messages in thread
From: Bernhard Reutner-Fischer @ 2015-05-25 21:32 UTC (permalink / raw)
  To: Laszlo Papp; +Cc: busybox, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]

On Fri, May 22, 2015 at 12:37:13PM +0100, Laszlo Papp wrote:
> Hi,
> 
> is it possible to do some post action after useradd_param is executed?
> 
> I would like to modify the created user's home directory, in this
> special case the profile. I see that the useradd util has this on
> desktop, but busybox does not have it, and very likely will not have
> it, at least not in the near future anyway:

mhm, why so?

The attached compiles for me.

cheers,

> 
>        -k, --skel SKEL_DIR
>            The skeleton directory, which contains files and
> directories to be copied in the user's home directory, when the home
> directory is created by useradd.
> 
>            This option is only valid if the -m (or --create-home)
> option is specified.
> 
>            If this option is not set, the skeleton directory is
> defined by the SKEL variable in /etc/default/useradd or, by default,
> /etc/skel.
> 
>            If possible, the ACLs and extended attributes are copied.
> 
> I would like to do something like this with the created user's home directory:
> 
> echo PATH=/sbin:$PATH > /home/foo/.profile
> chmod foo:foo /home/foo/.profile
> 
> But then again, for this, I need to make sure that the user is already created.
> 
> Ys, L.
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core

[-- Attachment #2: 0001-adduser-Add-k-path-to-skel.patch --]
[-- Type: text/x-diff, Size: 2993 bytes --]

From 7b7a7422c1937bcb967d1e6b184d04b1cdc63d88 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Mon, 25 May 2015 23:25:19 +0200
Subject: [PATCH] adduser: Add -k /path/to/skel

function                                             old     new   delta
.rodata                                           157069  157133     +64
adduser_main                                         921     936     +15
adduser_longopts                                     103     110      +7
packed_usage                                       30230   30236      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 92/0)               Total: 92 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 loginutils/adduser.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 568a301..077e6e9 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -20,6 +20,7 @@
 //usage:     "\n	-D		Don't assign a password"
 //usage:     "\n	-H		Don't create home directory"
 //usage:     "\n	-u UID		User id"
+//usage:     "\n	-k		SKEL directory (/etc/skel)"
 
 #include "libbb.h"
 
@@ -39,6 +40,7 @@
 #define OPT_SYSTEM_ACCOUNT (1 << 5)
 #define OPT_DONT_MAKE_HOME (1 << 6)
 #define OPT_UID            (1 << 7)
+#define OPT_SKEL           (1 << 8)
 
 /* remix */
 /* recoded such that the uid may be passed in *p */
@@ -134,6 +136,7 @@ static const char adduser_longopts[] ALIGN1 =
 		"system\0"              No_argument       "S"
 		"no-create-home\0"      No_argument       "H"
 		"uid\0"                 Required_argument "u"
+		"skel\0"                Required_argument "k"
 		;
 #endif
 
@@ -150,6 +153,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
 	char *p;
 	unsigned opts;
 	char *uid;
+	char *skel = (char*)"/etc/skel";
 
 #if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS
 	applet_long_options = adduser_longopts;
@@ -168,7 +172,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
 	/* at least one and at most two non-option args */
 	/* disable interactive passwd for system accounts */
 	opt_complementary = "-1:?2:SD";
-	opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid);
+	opts = getopt32(argv, "h:g:s:G:DSHu:k:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid, &skel);
 	if (opts & OPT_UID)
 		pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID);
 
@@ -250,8 +254,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
 				NULL
 			};
 			/* Be silent on any errors (like: no /etc/skel) */
-			logmode = LOGMODE_NONE;
-			copy_file("/etc/skel", pw.pw_dir, FILEUTILS_RECUR);
+			if (!(opts & OPT_SKEL))
+				logmode = LOGMODE_NONE;
+			copy_file(skel, pw.pw_dir, FILEUTILS_RECUR);
 			logmode = LOGMODE_STDIO;
 			chown_main(4, (char**)args);
 		}
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: adduser: add -k [was: Re: Post USERADD_PARAM action]
  2015-05-25 21:32 ` adduser: add -k [was: Re: Post USERADD_PARAM action] Bernhard Reutner-Fischer
@ 2015-05-26  9:08   ` Laszlo Papp
  0 siblings, 0 replies; 4+ messages in thread
From: Laszlo Papp @ 2015-05-26  9:08 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer; +Cc: busybox, openembedded-core

On Mon, May 25, 2015 at 10:32 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> On Fri, May 22, 2015 at 12:37:13PM +0100, Laszlo Papp wrote:
>> Hi,
>>
>> is it possible to do some post action after useradd_param is executed?
>>
>> I would like to modify the created user's home directory, in this
>> special case the profile. I see that the useradd util has this on
>> desktop, but busybox does not have it, and very likely will not have
>> it, at least not in the near future anyway:
>
> mhm, why so?

People tend to complain about not very common and minimalistic
features going in. Perhaps, if it is optional, it may sneak in easier.
Man proposes, Denys disposes.


> The attached compiles for me.
>
> cheers,
>
>>
>>        -k, --skel SKEL_DIR
>>            The skeleton directory, which contains files and
>> directories to be copied in the user's home directory, when the home
>> directory is created by useradd.
>>
>>            This option is only valid if the -m (or --create-home)
>> option is specified.
>>
>>            If this option is not set, the skeleton directory is
>> defined by the SKEL variable in /etc/default/useradd or, by default,
>> /etc/skel.
>>
>>            If possible, the ACLs and extended attributes are copied.
>>
>> I would like to do something like this with the created user's home directory:
>>
>> echo PATH=/sbin:$PATH > /home/foo/.profile
>> chmod foo:foo /home/foo/.profile
>>
>> But then again, for this, I need to make sure that the user is already created.
>>
>> Ys, L.
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Post USERADD_PARAM action
  2015-05-22 11:37 Post USERADD_PARAM action Laszlo Papp
  2015-05-25 21:32 ` adduser: add -k [was: Re: Post USERADD_PARAM action] Bernhard Reutner-Fischer
@ 2015-05-28  1:23 ` Khem Raj
  1 sibling, 0 replies; 4+ messages in thread
From: Khem Raj @ 2015-05-28  1:23 UTC (permalink / raw)
  To: Laszlo Papp; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1492 bytes --]


> On May 22, 2015, at 4:37 AM, Laszlo Papp <lpapp@kde.org> wrote:
> 
> Hi,
> 
> is it possible to do some post action after useradd_param is executed?
> 
> I would like to modify the created user's home directory, in this
> special case the profile. I see that the useradd util has this on
> desktop, but busybox does not have it, and very likely will not have
> it, at least not in the near future anyway:
> 
>       -k, --skel SKEL_DIR
>           The skeleton directory, which contains files and
> directories to be copied in the user's home directory, when the home
> directory is created by useradd.
> 
>           This option is only valid if the -m (or --create-home)
> option is specified.
> 
>           If this option is not set, the skeleton directory is
> defined by the SKEL variable in /etc/default/useradd or, by default,
> /etc/skel.
> 
>           If possible, the ACLs and extended attributes are copied.
> 
> I would like to do something like this with the created user's home directory:
> 
> echo PATH=/sbin:$PATH > /home/foo/.profile
> chmod foo:foo /home/foo/.profile
> 
> But then again, for this, I need to make sure that the user is already created.
> 

may be you can insert a custom task after useradd_sysroot ?

> Ys, L.
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 211 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-28  1:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-22 11:37 Post USERADD_PARAM action Laszlo Papp
2015-05-25 21:32 ` adduser: add -k [was: Re: Post USERADD_PARAM action] Bernhard Reutner-Fischer
2015-05-26  9:08   ` Laszlo Papp
2015-05-28  1:23 ` Post USERADD_PARAM action Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.