Skip to contentSkip to conversation

add ability to pass additional users tables

RFC New Eric Le Bihan 2 participants 6 messages Mar 27, 2014 – Apr 20, 2014 VFS

lore
Share & tools
lore
#0 lore raw

Hi!

I wanted to add some predefined users on my target system, but did not want to set up a skeleton. So I added a new entry into the "System configuration" menu, to set the location of an additional users table, to be passed to the powerful mkusers script, as it is done for the device tables.

This is an RFC, as I do not know where to add the help instructions in the manual about this feature.

Best regards,
ELB

Eric Le Bihan (1):
system: add ability to pass additional users tables.

 fs/common.mk     |    6 +++++-
 system/Config.in |    9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

--
1.7.9.5

#1 lore raw

PATCH 1/1 system: add ability to pass additional users tables.

A new entry has been added to the "System Configuration" menu to allow the user to set the location of additional user tables (besides the ones defined in packages).

A user table is a text file, formatted using the mkusers syntax, which describes the users on the target system, with their UID/GID, home directory, password, etc.

The target root file system will be populated according the content of these files.

---
 fs/common.mk     |    6 +++++-
 system/Config.in |    9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
fs/common.mk +5 -1
index d95c26b..6f37bd0 100644
@@ -33,6 +33,7 @@ FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
 ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
        $(BR2_ROOTFS_STATIC_DEVICE_TABLE))
 USERS_TABLE = $(BUILD_DIR)/_users_table.txt
+ROOTFS_USERS_TABLE = $(call qstrip,$(BR2_ROOTFS_USERS_TABLE))
 
 define ROOTFS_TARGET_INTERNAL
 
@@ -78,7 +79,10 @@ endif
 	printf '$$(subst $$(sep),\n,$$(PACKAGES_PERMISSIONS_TABLE))' >> $$(FULL_DEVICE_TABLE)
 	echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
 endif
-	printf '$(subst $(sep),\n,$(PACKAGES_USERS))' > $(USERS_TABLE)
+ifneq ($$(ROOTFS_USERS_TABLE),)
+	cat $$(ROOTFS_USERS_TABLE) > $(USERS_TABLE)
+endif
+	printf '$(subst $(sep),\n,$(PACKAGES_USERS))' >> $(USERS_TABLE)
 	$(TOPDIR)/support/scripts/mkusers $(USERS_TABLE) $(TARGET_DIR) >> $(FAKEROOT_SCRIPT)
 	echo "$$(ROOTFS_$(2)_CMD)" >> $$(FAKEROOT_SCRIPT)
 	chmod a+x $$(FAKEROOT_SCRIPT)
system/Config.in +9 -0
index e8f1ed6..b7052f5 100644
@@ -280,6 +280,15 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
 
+config BR2_ROOTFS_USERS_TABLE
+	string "Path to the users tables"
+	help
+	  Specify a space-separated list of users table locations,
+	  that will be passed to the mkusers utility to create
+	  users on the system, with home directory, password, etc.
+
+	  See manual for details on the usage and syntax of these files.
+
 config BR2_ROOTFS_OVERLAY
 	string "Root filesystem overlay directories"
 	default ""
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/1 system: add ability to pass additional users tables.

Eric, All,

On 2014-03-27 17:19 +0100, Eric Le Bihan spake thusly:

Quoted 48 lines

A new entry has been added to the "System Configuration" menu to allow the user to set the location of additional user tables (besides the ones defined in packages).

A user table is a text file, formatted using the mkusers syntax, which describes the users on the target system, with their UID/GID, home directory, password, etc.

The target root file system will be populated according the content of these files.

---
 fs/common.mk     |    6 +++++-
 system/Config.in |    9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
fs/common.mk +5 -1
index d95c26b..6f37bd0 100644
@@ -33,6 +33,7 @@ FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
 ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
        $(BR2_ROOTFS_STATIC_DEVICE_TABLE))
 USERS_TABLE = $(BUILD_DIR)/_users_table.txt
+ROOTFS_USERS_TABLE = $(call qstrip,$(BR2_ROOTFS_USERS_TABLE))
 
 define ROOTFS_TARGET_INTERNAL
 
@@ -78,7 +79,10 @@ endif
 	printf '$$(subst $$(sep),\n,$$(PACKAGES_PERMISSIONS_TABLE))' >> $$(FULL_DEVICE_TABLE)
 	echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
 endif
-	printf '$(subst $(sep),\n,$(PACKAGES_USERS))' > $(USERS_TABLE)
+ifneq ($$(ROOTFS_USERS_TABLE),)
+	cat $$(ROOTFS_USERS_TABLE) > $(USERS_TABLE)
+endif
+	printf '$(subst $(sep),\n,$(PACKAGES_USERS))' >> $(USERS_TABLE)
 	$(TOPDIR)/support/scripts/mkusers $(USERS_TABLE) $(TARGET_DIR) >> $(FAKEROOT_SCRIPT)
 	echo "$$(ROOTFS_$(2)_CMD)" >> $$(FAKEROOT_SCRIPT)
 	chmod a+x $$(FAKEROOT_SCRIPT)
system/Config.in +0 -0
index e8f1ed6..b7052f5 100644
@@ -280,6 +280,15 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT

system/Config.in config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW · line 291

Quoted 10 lines
system/Config.in +9 -0
 
+config BR2_ROOTFS_USERS_TABLE
+	string "Path to the users tables"
+	help
+	  Specify a space-separated list of users table locations,
+	  that will be passed to the mkusers utility to create
+	  users on the system, with home directory, password, etc.
+
+	  See manual for details on the usage and syntax of these files.
+

There is a discrepancy bewteen the description commit log and this help text, and the actual behaviour. The commit log and help text both explain this can be a space-separated list of files, but in the code you just treat it as if it were a unique file:

    ifneq ($$(ROOTFS_USERS_TABLE),)
        cat $$(ROOTFS_USERS_TABLE) > $(USERS_TABLE)
    endif

I think you should do something like:

    $(foreach f,$$(ROOTFS_USERS_TABLE),cat $$(f) >>$(USERS_TABLE)$(sep))

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 1/1 system: add ability to pass additional users tables.

Hi!

Quoted 2 lines · Yann E. MORIN

Eric, All,

[...]

Quoted 6 lines

There is a discrepancy bewteen the description commit log and this help text, and the actual behaviour. The commit log and help text both explain this can be a space-separated list of files, but in the code you just treat it as if it were a unique file:

Quoted 7 lines
    ifneq ($$(ROOTFS_USERS_TABLE),)
        cat $$(ROOTFS_USERS_TABLE) > $(USERS_TABLE)
    endif

I think you should do something like:

    $(foreach f,$$(ROOTFS_USERS_TABLE),cat $$(f) >>$(USERS_TABLE)$(sep))

In fact I use the same trick as for ROOTFS_DEVICE_TABLES: whether ROOTFS_USERS_TABLE is 'foo' or 'foo bar quux', the invocation of cat is valid, as cat takes a list of filenames as arguments. So no need to loop on a list. Or is the loop preferred because of portability issues?

But it is true that I should use the plural form ROOTFS_USERS_TABLES.

Thanks for your review.

Best regards,
ELB

#4 lore raw

PATCH 1/1 system: add ability to pass additional users tables.

Eric, All,

On 2014-03-28 12:10 +0100, Eric Le Bihan spake thusly:

Quoted 14 lines · Yann E. MORIN
Quoted 2 lines

Eric, All,

[...]

Quoted 10 lines

There is a discrepancy bewteen the description commit log and this help text, and the actual behaviour. The commit log and help text both explain this can be a space-separated list of files, but in the code you just treat it as if it were a unique file:

    ifneq ($$(ROOTFS_USERS_TABLE),)
        cat $$(ROOTFS_USERS_TABLE) > $(USERS_TABLE)
    endif
Quoted 7 lines
Quoted 3 lines

I think you should do something like:

    $(foreach f,$$(ROOTFS_USERS_TABLE),cat $$(f) >>$(USERS_TABLE)$(sep))

In fact I use the same trick as for ROOTFS_DEVICE_TABLES: whether ROOTFS_USERS_TABLE is 'foo' or 'foo bar quux', the invocation of cat is valid, as cat takes a list of filenames as arguments. So no need to loop on a list.

Oh, right. OK, then.

Quoted 1 line

But it is true that I should use the plural form ROOTFS_USERS_TABLES.

Yes, please.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 1/1 system: add ability to pass additional users tables.

In reply to Eric Le Bihan

On 2014-03-27 17:19 +0100, Eric Le Bihan spake thusly:

Quoted 4 lines

A new entry has been added to the "System Configuration" menu to allow the user to set the location of additional user tables (besides the ones defined in packages).

Quoted 8 lines

A user table is a text file, formatted using the mkusers syntax, which describes the users on the target system, with their UID/GID, home directory, password, etc.

The target root file system will be populated according the content of these files.

Although a minor nit below:

Quoted 10 lines
---
 fs/common.mk     |    6 +++++-
 system/Config.in |    9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
fs/common.mk +0 -0
index d95c26b..6f37bd0 100644

fs/common.mk FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt · line 36

Quoted 4 lines
fs/common.mk +1 -0
@@ -33,6 +33,7 @@ FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
 ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
        $(BR2_ROOTFS_STATIC_DEVICE_TABLE))
 USERS_TABLE = $(BUILD_DIR)/_users_table.txt
+ROOTFS_USERS_TABLE = $(call qstrip,$(BR2_ROOTFS_USERS_TABLE))

This is a list of space-separated files, so I'd prefer TABLE be a plural TABLES.

fs/common.mk endif · line 83

Quoted 9 lines
fs/common.mk +2 -1
 define ROOTFS_TARGET_INTERNAL
 
@@ -78,7 +79,10 @@ endif
 	printf '$$(subst $$(sep),\n,$$(PACKAGES_PERMISSIONS_TABLE))' >> $$(FULL_DEVICE_TABLE)
 	echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
 endif
-	printf '$(subst $(sep),\n,$(PACKAGES_USERS))' > $(USERS_TABLE)
+ifneq ($$(ROOTFS_USERS_TABLE),)
+	cat $$(ROOTFS_USERS_TABLE) > $(USERS_TABLE)

Rename here too.

Quoted 10 lines
fs/common.mk +2 -0
+endif
+	printf '$(subst $(sep),\n,$(PACKAGES_USERS))' >> $(USERS_TABLE)
 	$(TOPDIR)/support/scripts/mkusers $(USERS_TABLE) $(TARGET_DIR) >> $(FAKEROOT_SCRIPT)
 	echo "$$(ROOTFS_$(2)_CMD)" >> $$(FAKEROOT_SCRIPT)
 	chmod a+x $$(FAKEROOT_SCRIPT)
system/Config.in +0 -0
index e8f1ed6..b7052f5 100644

system/Config.in config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW · line 283

Quoted 4 lines
system/Config.in +1 -0
@@ -280,6 +280,15 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
 
+config BR2_ROOTFS_USERS_TABLE

Rename here.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'