public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options
@ 2022-03-27 23:37 Matt Turner
  2022-03-27 23:37 ` [gentoo-catalyst] [PATCH 2/3] catalyst: add new options to stage4 step list Matt Turner
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Matt Turner @ 2022-03-27 23:37 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Patrice Clement

From: Patrice Clement <monsieurp@gentoo.org>

* stage4/groups: create a a list of groups.
* stage4/users: create a list of users. users can also be added to
  groups using the "foo.bar=wheel,audio,baz" format.
* stage4/ssh_public_keys: copy an SSH public key into the stage4 user's home
  (.ssh/authorized_keys) and set the file permission to 0644.

Bug: https://bugs.gentoo.org/236905
Signed-off-by: Patrice Clement <monsieurp@gentoo.org>
---
 catalyst/base/stagebase.py | 70 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index de1e30ef..76feb5f0 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -201,6 +201,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
         self.set_packages()
         self.set_rm()
         self.set_linuxrc()
+        self.set_groups()
+        self.set_users()
+        self.set_ssh_public_keys()
         self.set_busybox_config()
         self.set_overlay()
         self.set_repos()
@@ -583,6 +586,39 @@ class StageBase(TargetBase, ClearBase, GenBase):
                     self.settings[self.settings["spec_prefix"] + "/linuxrc"]
                 del self.settings[self.settings["spec_prefix"] + "/linuxrc"]
 
+    def set_groups(self):
+        groups = self.settings["spec_prefix"] + "/groups"
+        if groups in self.settings:
+            if isinstance(self.settings[groups], str):
+                self.settings["groups"] = self.settings[groups].split(",")
+            self.settings["groups"] = self.settings[groups]
+            del self.settings[groups]
+        else:
+            self.settings["groups"] = []
+        log.info('groups to create: %s' % self.settings["groups"])
+
+	def set_users(self):
+        users = self.settings["spec_prefix"] + "/users"
+        if users in self.settings:
+            if isinstance(self.settings[users], str):
+                self.settings["users"] = self.settings[users].split(",")
+            self.settings["users"] = self.settings[users]
+            del self.settings[users]
+        else:
+            self.settings["users"] = []
+        log.info('users to create: %s' % self.settings["users"])
+
+    def set_ssh_public_keys(self):
+        ssh_public_keys = self.settings["spec_prefix"] + "/ssh_public_keys"
+        if ssh_public_keys in self.settings:
+            if isinstance(self.settings[ssh_public_keys], str):
+                self.settings["ssh_public_keys"] = self.settings[ssh_public_keys].split(",")
+            self.settings["ssh_public_keys"] = self.settings[ssh_public_keys]
+            del self.settings[ssh_public_keys]
+        else:
+            self.settings["ssh_public_keys"] = []
+        log.info('ssh public keys to copy: %s' % self.settings["ssh_public_keys"])
+
     def set_busybox_config(self):
         if self.settings["spec_prefix"] + "/busybox_config" in self.settings:
             if isinstance(self.settings[self.settings['spec_prefix'] + '/busybox_config'], str):
@@ -894,6 +930,40 @@ class StageBase(TargetBase, ClearBase, GenBase):
                     cmd(['rsync', '-a', x + '/', self.settings['stage_path']],
                         env=self.env)
 
+    def groups(self):
+        for x in self.settings["groups"].split():
+            log.notice("Creating group: '%s'", x)
+            cmd(["groupadd", "-R", self.settings['chroot_path'], x], env=self.env)
+
+    def users(self):
+        for x in self.settings["users"]:
+            usr, grp = '', ''
+            try:
+                usr, grp = x.split("=")
+            except ValueError:
+                usr = x
+                log.debug("users: '=' separator not found on line " + x)
+                log.debug("users: missing separator means no groups found")
+            uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", x]
+            if grp != '':
+                uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", "-G", grp, usr]
+            log.notice("Creating user: '%s'", f"{usr}={grp}")
+            cmd(uacmd, env=self.env)
+
+    def ssh_public_keys(self):
+        for x in self.settings["ssh_public_keys"]:
+            usr, pub_key_src = '', ''
+            try:
+                usr, pub_key_src = x.split("=")
+            except ValueError:
+                raise CatalystError(f"ssh_public_keys: '=' separator not found on line {x}")
+            log.notice("Copying SSH public key for user: '%s'", usr)
+            pub_key_dest = self.settings['chroot_path'] + f"/home/{usr}/.ssh/authorized_keys"
+            cpcmd = ["cp", "-av", pub_key_src, pub_key_dest]
+            cmd(cpcmd, env=self.env)
+            chcmd = ["chmod", "0644", pub_key_dest]
+            cmd(chcmd, env=self.env)
+
     def bind(self):
         for x in [x for x in self.mount if self.mount[x]['enable']]:
             if str(self.mount[x]['source']) == 'config':
-- 
2.34.1



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

* [gentoo-catalyst] [PATCH 2/3] catalyst: add new options to stage4 step list
  2022-03-27 23:37 [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options Matt Turner
@ 2022-03-27 23:37 ` Matt Turner
  2022-03-27 23:37 ` [gentoo-catalyst] [PATCH 3/3] example: document new options Matt Turner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Matt Turner @ 2022-03-27 23:37 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Patrice Clement

From: Patrice Clement <monsieurp@gentoo.org>

Signed-off-by: Patrice Clement <monsieurp@gentoo.org>
---
 catalyst/targets/stage4.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index ff1d4dca..35309b45 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -19,13 +19,16 @@ class stage4(StageBase):
         "stage4/empty",
         "stage4/fsscript",
         "stage4/gk_mainargs",
+        "stage4/groups",
         "stage4/linuxrc",
         "stage4/rcadd",
         "stage4/rcdel",
         "stage4/rm",
         "stage4/root_overlay",
+        "stage4/ssh_public_keys",
         "stage4/unmerge",
         "stage4/use",
+        "stage4/users",
     ])
 
     def __init__(self, spec, addlargs):
@@ -51,6 +54,9 @@ class stage4(StageBase):
         ])
         self.finish_sequence.extend([
             self.remove,
+            self.groups,
+            self.users,
+            self.ssh_public_keys,
             self.empty,
             self.clean,
         ])
-- 
2.34.1



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

* [gentoo-catalyst] [PATCH 3/3] example: document new options
  2022-03-27 23:37 [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options Matt Turner
  2022-03-27 23:37 ` [gentoo-catalyst] [PATCH 2/3] catalyst: add new options to stage4 step list Matt Turner
@ 2022-03-27 23:37 ` Matt Turner
  2022-04-19 14:17 ` [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 " Daniel Cordero
  2022-04-19 15:23 ` Daniel Cordero
  3 siblings, 0 replies; 16+ messages in thread
From: Matt Turner @ 2022-03-27 23:37 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Patrice Clement

From: Patrice Clement <monsieurp@gentoo.org>

Closes: https://bugs.gentoo.org/236905
Signed-off-by: Patrice Clement <monsieurp@gentoo.org>
---
 examples/stage4_template.spec | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/examples/stage4_template.spec b/examples/stage4_template.spec
index 5fbf6a50..5d9a390c 100644
--- a/examples/stage4_template.spec
+++ b/examples/stage4_template.spec
@@ -171,15 +171,37 @@ stage4/root_overlay:
 # stage4/xinitrc:
 stage4/xinitrc:
 
-# This option is used to create non-root users on your CD.  It takes a space
-# separated list of user names.  These users will be added to the following
-# groups: users,wheel,audio,games,cdrom,usb
-# If this is specified in your spec file, then the first user is also the user
-# used to start X. Since this is not used on the release media, it is blank.
-# example:
+# This option is used to create groups. It takes a carriage-return separated
+# list of group names. For instance:
+# stage4/groups:
+#     admin
+#     web_group
+#     sudo_group
+stage4/groups:
+
+# This option is used to create non-root users. It takes a carriage-return
+# separated list of user names. For instance:
+# stage4/users:
+#     john.doe
+#     foo.bar
+#
+# These users are NOT added to any specific group. You can specify one
+# or more groups to add the user(s) to using an equal sign followed by a comma
+# separated list. For instance:
 # stage4/users:
+#     john.doe=wheel,audio,cdrom
+#     foo.bar=www,audio
 stage4/users:
 
+# This option is used to copy an SSH public key into a user's .ssh directory.
+# Catalyst will copy the SSH public key in the ~/.ssh/authorized_keys file and
+# set the file permission to 0644. It takes a carriage-return separated list of
+# users with a equal sign followed by the SSH public key path. For instance:
+# stage4/ssh_public_keys:
+#     john.doe=/path/to/johns/public/key/id_rsa.pub
+#     foo.bar=/path/to/foos/public/key/id_ed25519.pub
+stage4/ssh_public_keys:
+
 # This option is used to specify the number of kernels to build and also the
 # labels that will be used by the CD bootloader to refer to each kernel image.
 # example:
-- 
2.34.1



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

* Re: [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options
  2022-03-27 23:37 [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options Matt Turner
  2022-03-27 23:37 ` [gentoo-catalyst] [PATCH 2/3] catalyst: add new options to stage4 step list Matt Turner
  2022-03-27 23:37 ` [gentoo-catalyst] [PATCH 3/3] example: document new options Matt Turner
@ 2022-04-19 14:17 ` Daniel Cordero
  2022-04-20 23:25   ` Matt Turner
  2022-04-19 15:23 ` Daniel Cordero
  3 siblings, 1 reply; 16+ messages in thread
From: Daniel Cordero @ 2022-04-19 14:17 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Patrice Clement, Matt Turner

On Sun, Mar 27, 2022 at 04:37:10PM -0700, Matt Turner wrote:
> From: Patrice Clement
> 
> * stage4/groups: create a a list of groups.
> * stage4/users: create a list of users. users can also be added to
>   groups using the "foo.bar=wheel,audio,baz" format.
> * stage4/ssh_public_keys: copy an SSH public key into the stage4 user's home
>   (.ssh/authorized_keys) and set the file permission to 0644.
> 
> Bug: https://bugs.gentoo.org/236905
> ---
>  catalyst/base/stagebase.py | 70 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 70 insertions(+)
> 
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index de1e30ef..76feb5f0 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -201,6 +201,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
>          self.set_packages()
>          self.set_rm()
>          self.set_linuxrc()
> +        self.set_groups()
> +        self.set_users()
> +        self.set_ssh_public_keys()
>          self.set_busybox_config()
>          self.set_overlay()
>          self.set_repos()
> @@ -583,6 +586,39 @@ class StageBase(TargetBase, ClearBase, GenBase):
>                      self.settings[self.settings["spec_prefix"] + "/linuxrc"]
>                  del self.settings[self.settings["spec_prefix"] + "/linuxrc"]
>  
> +    def set_groups(self):
> +        groups = self.settings["spec_prefix"] + "/groups"
> +        if groups in self.settings:
> +            if isinstance(self.settings[groups], str):
> +                self.settings["groups"] = self.settings[groups].split(",")
> +            self.settings["groups"] = self.settings[groups]
> +            del self.settings[groups]
> +        else:
> +            self.settings["groups"] = []
> +        log.info('groups to create: %s' % self.settings["groups"])
> +
> +	def set_users(self):

Traceback (most recent call last):
...
  File "/catalyst/base/stagebase.py", line 600
    def set_users(self):
TabError: inconsistent use of tabs and spaces in indentation

> +        users = self.settings["spec_prefix"] + "/users"
> +        if users in self.settings:
> +            if isinstance(self.settings[users], str):
> +                self.settings["users"] = self.settings[users].split(",")
> +            self.settings["users"] = self.settings[users]
> +            del self.settings[users]
> +        else:
> +            self.settings["users"] = []
> +        log.info('users to create: %s' % self.settings["users"])
> +


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

* Re: [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options
  2022-03-27 23:37 [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options Matt Turner
                   ` (2 preceding siblings ...)
  2022-04-19 14:17 ` [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 " Daniel Cordero
@ 2022-04-19 15:23 ` Daniel Cordero
  2022-04-20 23:26   ` Matt Turner
  3 siblings, 1 reply; 16+ messages in thread
From: Daniel Cordero @ 2022-04-19 15:23 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Matt Turner, Patrice Clement

On Sun, Mar 27, 2022 at 04:37:10PM -0700, Matt Turner wrote:
> From: Patrice Clement
> 
> * stage4/groups: create a a list of groups.
> * stage4/users: create a list of users. users can also be added to
>   groups using the "foo.bar=wheel,audio,baz" format.
> * stage4/ssh_public_keys: copy an SSH public key into the stage4 user's home
>   (.ssh/authorized_keys) and set the file permission to 0644.
> 
> Bug: https://bugs.gentoo.org/236905
> ---
>  catalyst/base/stagebase.py | 70 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 70 insertions(+)
> 
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index de1e30ef..76feb5f0 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -894,6 +930,40 @@ class StageBase(TargetBase, ClearBase, GenBase):
>                      cmd(['rsync', '-a', x + '/', self.settings['stage_path']],
>                          env=self.env)
>  
> +    def groups(self):
> +        for x in self.settings["groups"].split():

For users() and ssh_public_keys() the setting is used as-is, but for
groups it is .split().

None of them handle 0/1/2+ length settings as they get converted into lists and strings.

These need to be able to handle both cases.


	INFO:catalyst:groups to create: []
	INFO:catalyst:users to create: []
	INFO:catalyst:ssh public keys to copy: []
	...
	Traceback (most recent call last):
	  File "/catalyst/base/stagebase.py", line 38, in run_sequence
	    func()
	  File "/catalyst/base/stagebase.py", line 934, in groups
	    for x in self.settings["groups"].split():
	AttributeError: 'list' object has no attribute 'split'


> +            log.notice("Creating group: '%s'", x)
> +            cmd(["groupadd", "-R", self.settings['chroot_path'], x], env=self.env)
> +
> +    def users(self):
> +        for x in self.settings["users"]:

With the specfile fragment:
	stage4/groups:
		a

	stage4/users:
		me=a



	INFO:catalyst:groups to create: a
	INFO:catalyst:users to create: me=a
	INFO:catalyst:ssh public keys to copy: []
	...
	NOTICE:catalyst:--- Running action sequence: groups
	NOTICE:catalyst:Creating group: 'a'
	NOTICE:catalyst:--- Running action sequence: users
	NOTICE:catalyst:Creating user: 'm='
	NOTICE:catalyst:Creating user: 'e='
	NOTICE:catalyst:Creating user: '='
	useradd: invalid user name '=': use --badname to ignore
	ERROR:catalyst:CatalystError: cmd(['useradd', '-R', '/substrate/tmp/stage4-amd64', '-m', '=']) exited 3


> +            usr, grp = '', ''
> +            try:
> +                usr, grp = x.split("=")
> +            except ValueError:
> +                usr = x
> +                log.debug("users: '=' separator not found on line " + x)
> +                log.debug("users: missing separator means no groups found")
> +            uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", x]
> +            if grp != '':
> +                uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", "-G", grp, usr]
> +            log.notice("Creating user: '%s'", f"{usr}={grp}")
> +            cmd(uacmd, env=self.env)
> +
> +    def ssh_public_keys(self):
> +        for x in self.settings["ssh_public_keys"]:
> +            usr, pub_key_src = '', ''
> +            try:
> +                usr, pub_key_src = x.split("=")
> +            except ValueError:
> +                raise CatalystError(f"ssh_public_keys: '=' separator not found on line {x}")
> +            log.notice("Copying SSH public key for user: '%s'", usr)
> +            pub_key_dest = self.settings['chroot_path'] + f"/home/{usr}/.ssh/authorized_keys"
> +            cpcmd = ["cp", "-av", pub_key_src, pub_key_dest]
> +            cmd(cpcmd, env=self.env)
> +            chcmd = ["chmod", "0644", pub_key_dest]
> +            cmd(chcmd, env=self.env)
> +
>      def bind(self):
>          for x in [x for x in self.mount if self.mount[x]['enable']]:
>              if str(self.mount[x]['source']) == 'config':
> -- 
> 2.34.1
> 
> 


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

* Re: [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options
  2022-04-19 14:17 ` [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 " Daniel Cordero
@ 2022-04-20 23:25   ` Matt Turner
  0 siblings, 0 replies; 16+ messages in thread
From: Matt Turner @ 2022-04-20 23:25 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Patrice Clement

On Tue, Apr 19, 2022 at 7:17 AM Daniel Cordero <gentoo.catalyst@xxoo.ws> wrote:
>
> On Sun, Mar 27, 2022 at 04:37:10PM -0700, Matt Turner wrote:
> > From: Patrice Clement
> >
> > * stage4/groups: create a a list of groups.
> > * stage4/users: create a list of users. users can also be added to
> >   groups using the "foo.bar=wheel,audio,baz" format.
> > * stage4/ssh_public_keys: copy an SSH public key into the stage4 user's home
> >   (.ssh/authorized_keys) and set the file permission to 0644.
> >
> > Bug: https://bugs.gentoo.org/236905
> > ---
> >  catalyst/base/stagebase.py | 70 ++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 70 insertions(+)
> >
> > diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> > index de1e30ef..76feb5f0 100644
> > --- a/catalyst/base/stagebase.py
> > +++ b/catalyst/base/stagebase.py
> > @@ -201,6 +201,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
> >          self.set_packages()
> >          self.set_rm()
> >          self.set_linuxrc()
> > +        self.set_groups()
> > +        self.set_users()
> > +        self.set_ssh_public_keys()
> >          self.set_busybox_config()
> >          self.set_overlay()
> >          self.set_repos()
> > @@ -583,6 +586,39 @@ class StageBase(TargetBase, ClearBase, GenBase):
> >                      self.settings[self.settings["spec_prefix"] + "/linuxrc"]
> >                  del self.settings[self.settings["spec_prefix"] + "/linuxrc"]
> >
> > +    def set_groups(self):
> > +        groups = self.settings["spec_prefix"] + "/groups"
> > +        if groups in self.settings:
> > +            if isinstance(self.settings[groups], str):
> > +                self.settings["groups"] = self.settings[groups].split(",")
> > +            self.settings["groups"] = self.settings[groups]
> > +            del self.settings[groups]
> > +        else:
> > +            self.settings["groups"] = []
> > +        log.info('groups to create: %s' % self.settings["groups"])
> > +
> > +     def set_users(self):
>
> Traceback (most recent call last):
> ...
>   File "/catalyst/base/stagebase.py", line 600
>     def set_users(self):
> TabError: inconsistent use of tabs and spaces in indentation

Thanks, fixed.


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

* Re: [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options
  2022-04-19 15:23 ` Daniel Cordero
@ 2022-04-20 23:26   ` Matt Turner
  2022-04-21  7:08     ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Daniel Cordero
  0 siblings, 1 reply; 16+ messages in thread
From: Matt Turner @ 2022-04-20 23:26 UTC (permalink / raw
  To: Daniel Cordero; +Cc: gentoo-catalyst, Patrice Clement

On Tue, Apr 19, 2022 at 8:23 AM Daniel Cordero <gentoo.catalyst@xxoo.ws> wrote:
>
> On Sun, Mar 27, 2022 at 04:37:10PM -0700, Matt Turner wrote:
> > From: Patrice Clement
> >
> > * stage4/groups: create a a list of groups.
> > * stage4/users: create a list of users. users can also be added to
> >   groups using the "foo.bar=wheel,audio,baz" format.
> > * stage4/ssh_public_keys: copy an SSH public key into the stage4 user's home
> >   (.ssh/authorized_keys) and set the file permission to 0644.
> >
> > Bug: https://bugs.gentoo.org/236905
> > ---
> >  catalyst/base/stagebase.py | 70 ++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 70 insertions(+)
> >
> > diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> > index de1e30ef..76feb5f0 100644
> > --- a/catalyst/base/stagebase.py
> > +++ b/catalyst/base/stagebase.py
> > @@ -894,6 +930,40 @@ class StageBase(TargetBase, ClearBase, GenBase):
> >                      cmd(['rsync', '-a', x + '/', self.settings['stage_path']],
> >                          env=self.env)
> >
> > +    def groups(self):
> > +        for x in self.settings["groups"].split():
>
> For users() and ssh_public_keys() the setting is used as-is, but for
> groups it is .split().
>
> None of them handle 0/1/2+ length settings as they get converted into lists and strings.
>
> These need to be able to handle both cases.

Would you like to send a patch? (Or Patrice?)


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

* [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys
  2022-04-20 23:26   ` Matt Turner
@ 2022-04-21  7:08     ` Daniel Cordero
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 2/4] stage4/groups: don't run split on a list Daniel Cordero
                         ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Daniel Cordero @ 2022-04-21  7:08 UTC (permalink / raw
  To: gentoo-catalyst

Previously, the set_*() functions would always set the result of the toml parsing
as the setting. Instead, only override it if it is a string.

This fixes an issue introduced in commit 5be6069bcbd5a7fa3f114f28366597bc5ddbb891.
---
 catalyst/base/stagebase.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 5c7e9adb..1d71c59d 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -589,9 +589,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
     def set_groups(self):
         groups = self.settings["spec_prefix"] + "/groups"
         if groups in self.settings:
+            self.settings["groups"] = self.settings[groups]
             if isinstance(self.settings[groups], str):
                 self.settings["groups"] = self.settings[groups].split(",")
-            self.settings["groups"] = self.settings[groups]
             del self.settings[groups]
         else:
             self.settings["groups"] = []
@@ -600,9 +600,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
     def set_users(self):
         users = self.settings["spec_prefix"] + "/users"
         if users in self.settings:
+            self.settings["users"] = self.settings[users]
             if isinstance(self.settings[users], str):
                 self.settings["users"] = self.settings[users].split(",")
-            self.settings["users"] = self.settings[users]
             del self.settings[users]
         else:
             self.settings["users"] = []
@@ -611,9 +611,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
     def set_ssh_public_keys(self):
         ssh_public_keys = self.settings["spec_prefix"] + "/ssh_public_keys"
         if ssh_public_keys in self.settings:
+            self.settings["ssh_public_keys"] = self.settings[ssh_public_keys]
             if isinstance(self.settings[ssh_public_keys], str):
                 self.settings["ssh_public_keys"] = self.settings[ssh_public_keys].split(",")
-            self.settings["ssh_public_keys"] = self.settings[ssh_public_keys]
             del self.settings[ssh_public_keys]
         else:
             self.settings["ssh_public_keys"] = []
-- 
2.35.1



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

* [gentoo-catalyst] [PATCH 2/4] stage4/groups: don't run split on a list
  2022-04-21  7:08     ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Daniel Cordero
@ 2022-04-21  7:08       ` Daniel Cordero
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 3/4] stage4/users: don't split a single entry Daniel Cordero
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Daniel Cordero @ 2022-04-21  7:08 UTC (permalink / raw
  To: gentoo-catalyst

"groups" has been normalised into a list and does not have a split()
method.

This fixes an issue introduced in commit 5be6069bcbd5a7fa3f114f28366597bc5ddbb891.
---
 catalyst/base/stagebase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 1d71c59d..7e6b9e32 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -931,7 +931,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
                         env=self.env)
 
     def groups(self):
-        for x in self.settings["groups"].split():
+        for x in self.settings["groups"]:
             log.notice("Creating group: '%s'", x)
             cmd(["groupadd", "-R", self.settings['chroot_path'], x], env=self.env)
 
-- 
2.35.1



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

* [gentoo-catalyst] [PATCH 3/4] stage4/users: don't split a single entry
  2022-04-21  7:08     ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Daniel Cordero
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 2/4] stage4/groups: don't run split on a list Daniel Cordero
@ 2022-04-21  7:08       ` Daniel Cordero
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 4/4] stage4/groups: improve log message Daniel Cordero
  2022-05-09 17:06       ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Matt Turner
  3 siblings, 0 replies; 16+ messages in thread
From: Daniel Cordero @ 2022-04-21  7:08 UTC (permalink / raw
  To: gentoo-catalyst

A single entry in users is one user who could have multiple groups.
---
 catalyst/base/stagebase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 7e6b9e32..d4875491 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -602,7 +602,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
         if users in self.settings:
             self.settings["users"] = self.settings[users]
             if isinstance(self.settings[users], str):
-                self.settings["users"] = self.settings[users].split(",")
+                self.settings["users"] = [self.settings[users]]
             del self.settings[users]
         else:
             self.settings["users"] = []
-- 
2.35.1



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

* [gentoo-catalyst] [PATCH 4/4] stage4/groups: improve log message
  2022-04-21  7:08     ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Daniel Cordero
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 2/4] stage4/groups: don't run split on a list Daniel Cordero
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 3/4] stage4/users: don't split a single entry Daniel Cordero
@ 2022-04-21  7:08       ` Daniel Cordero
  2022-04-21 21:01         ` Daniel Cordero
  2022-05-09 11:20         ` [gentoo-catalyst] [PATCH v2 4/4] stage4/users: " Daniel Cordero
  2022-05-09 17:06       ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Matt Turner
  3 siblings, 2 replies; 16+ messages in thread
From: Daniel Cordero @ 2022-04-21  7:08 UTC (permalink / raw
  To: gentoo-catalyst

When creating a user with no additional groups, don't print a misleading message
saying the user will be created with an equals sign in the username.
---
 catalyst/base/stagebase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index d4875491..9814ebcc 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -947,7 +947,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
             uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", x]
             if grp != '':
                 uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", "-G", grp, usr]
-            log.notice("Creating user: '%s'", f"{usr}={grp}")
+            log.notice("Creating user: '%s' in group(s): %s", usr, grp)
             cmd(uacmd, env=self.env)
 
     def ssh_public_keys(self):
-- 
2.35.1



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

* Re: [gentoo-catalyst] [PATCH 4/4] stage4/groups: improve log message
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 4/4] stage4/groups: improve log message Daniel Cordero
@ 2022-04-21 21:01         ` Daniel Cordero
  2022-05-09 11:20         ` [gentoo-catalyst] [PATCH v2 4/4] stage4/users: " Daniel Cordero
  1 sibling, 0 replies; 16+ messages in thread
From: Daniel Cordero @ 2022-04-21 21:01 UTC (permalink / raw
  To: gentoo-catalyst

On Thu, Apr 21, 2022 at 07:08:26AM +0000, Daniel Cordero wrote:
> When creating a user with no additional groups, don't print a misleading message
> saying the user will be created with an equals sign in the username.
> ---
>  catalyst/base/stagebase.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index d4875491..9814ebcc 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -947,7 +947,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
>              uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", x]
>              if grp != '':
>                  uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", "-G", grp, usr]
> -            log.notice("Creating user: '%s'", f"{usr}={grp}")
> +            log.notice("Creating user: '%s' in group(s): %s", usr, grp)

Ah, this patch is wrong as I appear to have mixed up % and .format()
syntaxes.

>              cmd(uacmd, env=self.env)
>  
>      def ssh_public_keys(self):
> -- 
> 2.35.1
> 
> 


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

* [gentoo-catalyst] [PATCH v2 4/4] stage4/users: improve log message
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 4/4] stage4/groups: improve log message Daniel Cordero
  2022-04-21 21:01         ` Daniel Cordero
@ 2022-05-09 11:20         ` Daniel Cordero
  1 sibling, 0 replies; 16+ messages in thread
From: Daniel Cordero @ 2022-05-09 11:20 UTC (permalink / raw
  To: gentoo-catalyst

When creating a user with no additional groups, don't print a misleading
message saying the user will be created with an equals sign in the
username.
---
 catalyst/base/stagebase.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index d4875491..eb869c70 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -945,9 +945,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
                 log.debug("users: '=' separator not found on line " + x)
                 log.debug("users: missing separator means no groups found")
             uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", x]
+            msg_create_user = "Creating user: '%s'" % usr
             if grp != '':
                 uacmd = ["useradd", "-R", self.settings['chroot_path'], "-m", "-G", grp, usr]
-            log.notice("Creating user: '%s'", f"{usr}={grp}")
+                msg_create_user = "Creating user: '%s' in group(s): %s" % usr, grp
+            log.notice(msg_create_user)
             cmd(uacmd, env=self.env)
 
     def ssh_public_keys(self):
-- 
2.35.1



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

* Re: [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys
  2022-04-21  7:08     ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Daniel Cordero
                         ` (2 preceding siblings ...)
  2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 4/4] stage4/groups: improve log message Daniel Cordero
@ 2022-05-09 17:06       ` Matt Turner
  2022-05-12 10:09         ` Daniel Cordero
  3 siblings, 1 reply; 16+ messages in thread
From: Matt Turner @ 2022-05-09 17:06 UTC (permalink / raw
  To: gentoo-catalyst, Patrice Clement

Thanks!

Somehow these patches didn't get picked up in the mailing list
archives. I've applied them locally and created a gitlab merge request
for them here: https://gitlab.gentoo.org/gentoo/catalyst/-/merge_requests/1

Could you provide your Signed-off-by tag?

I've pointed Patrice to the MR so he can review.


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

* Re: [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys
  2022-05-09 17:06       ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Matt Turner
@ 2022-05-12 10:09         ` Daniel Cordero
  2022-05-13 17:45           ` Matt Turner
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Cordero @ 2022-05-12 10:09 UTC (permalink / raw
  To: Matt Turner; +Cc: gentoo-catalyst, Patrice Clement

On Mon, May 09, 2022 at 01:06:44PM -0400, Matt Turner wrote:
> Thanks!
> 
> Somehow these patches didn't get picked up in the mailing list
> archives. I've applied them locally and created a gitlab merge request
> for them here: https://gitlab.gentoo.org/gentoo/catalyst/-/merge_requests/1
> 
> Could you provide your Signed-off-by tag?

Signed-off-by: Daniel Cordero <gentoo.catalyst@0xdc.io>

> 
> I've pointed Patrice to the MR so he can review.
> 


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

* Re: [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys
  2022-05-12 10:09         ` Daniel Cordero
@ 2022-05-13 17:45           ` Matt Turner
  0 siblings, 0 replies; 16+ messages in thread
From: Matt Turner @ 2022-05-13 17:45 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Patrice Clement

On Thu, May 12, 2022 at 6:09 AM Daniel Cordero <gentoo.catalyst@0xdc.io> wrote:
>
> On Mon, May 09, 2022 at 01:06:44PM -0400, Matt Turner wrote:
> > Thanks!
> >
> > Somehow these patches didn't get picked up in the mailing list
> > archives. I've applied them locally and created a gitlab merge request
> > for them here: https://gitlab.gentoo.org/gentoo/catalyst/-/merge_requests/1
> >
> > Could you provide your Signed-off-by tag?
>
> Signed-off-by: Daniel Cordero <gentoo.catalyst@0xdc.io>

Thanks, merged!


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

end of thread, other threads:[~2022-05-13 17:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-27 23:37 [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 new options Matt Turner
2022-03-27 23:37 ` [gentoo-catalyst] [PATCH 2/3] catalyst: add new options to stage4 step list Matt Turner
2022-03-27 23:37 ` [gentoo-catalyst] [PATCH 3/3] example: document new options Matt Turner
2022-04-19 14:17 ` [gentoo-catalyst] [PATCH 1/3] catalyst: support 3 " Daniel Cordero
2022-04-20 23:25   ` Matt Turner
2022-04-19 15:23 ` Daniel Cordero
2022-04-20 23:26   ` Matt Turner
2022-04-21  7:08     ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Daniel Cordero
2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 2/4] stage4/groups: don't run split on a list Daniel Cordero
2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 3/4] stage4/users: don't split a single entry Daniel Cordero
2022-04-21  7:08       ` [gentoo-catalyst] [PATCH 4/4] stage4/groups: improve log message Daniel Cordero
2022-04-21 21:01         ` Daniel Cordero
2022-05-09 11:20         ` [gentoo-catalyst] [PATCH v2 4/4] stage4/users: " Daniel Cordero
2022-05-09 17:06       ` [gentoo-catalyst] [PATCH 1/4] stage4: fix handling of groups, users and keys Matt Turner
2022-05-12 10:09         ` Daniel Cordero
2022-05-13 17:45           ` Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox