Ver Fonte

allow to add a unprivileged user

Waldemar Brodkorb há 9 anos atrás
pai
commit
1d95a3bbf1
2 ficheiros alterados com 45 adições e 3 exclusões
  1. 8 1
      package/base-files/Makefile
  2. 37 2
      target/config/Config.in.runtime

+ 8 - 1
package/base-files/Makefile

@@ -6,7 +6,7 @@ include $(ADK_TOPDIR)/mk/rootfs.mk
 
 PKG_NAME:=		base-files
 PKG_VERSION:=		1.1
-PKG_RELEASE:=		12
+PKG_RELEASE:=		13
 PKG_SECTION:=		base/apps
 PKG_DESCR:=		basic files and scripts
 
@@ -174,4 +174,11 @@ ifneq (${ADK_SIMPLE_NETWORK_CONFIG_PROXY},)
 endif
 endif
 
+ifeq ($(ADK_RUNTIME_ADDUSER),y)
+	mkdir -p ${IDIR_BASE_FILES}/$(ADK_RUNTIME_USER_HOME)
+	printf "$(ADK_RUNTIME_USER_NAME):x:100:100:$(ADK_RUNTIME_USER_NAME):$(ADK_RUNTIME_USER_HOME):$(ADK_RUNTIME_USER_SHELL)" >> ${IDIR_BASE_FILES}/etc/passwd
+	printf "$(ADK_RUNTIME_USER_NAME):$(ADK_RUNTIME_USER_PASSWORD):16514:0:::::" >> ${IDIR_BASE_FILES}/etc/shadow
+	printf "$(ADK_RUNTIME_USER_NAME):x:100:" >> ${IDIR_BASE_FILES}/etc/group
+endif
+
 include ${ADK_TOPDIR}/mk/pkg-bottom.mk

+ 37 - 2
target/config/Config.in.runtime

@@ -20,8 +20,43 @@ config ADK_RUNTIME_PASSWORD
 	default "$1$bJoW4DmS$7fUVat.9iFSAePzA4j4Jm."
 	help
 	  Predefine the root password enabled in the built image.
-	  Use ./host_x86_64-linux-gnu/usr/bin/mkcrypt to generate the hash.
-	  Default password is linux123.
+	  Use ./host_*/usr/bin/mkcrypt to generate the hash.
+	  Default password is linux123
+
+config ADK_RUNTIME_ADDUSER
+	bool "add an user"
+	default n
+	help
+	  Enable this option to add an unprivileged user.
+	  Fixed UID/GID 100 is used. A group with the same name is added.
+
+config ADK_RUNTIME_USER_NAME
+	string "user name"
+	default "adk"
+	depends on ADK_RUNTIME_ADDUSER
+
+config ADK_RUNTIME_USER_PASSWORD
+	string "user password"
+	default "$1$bJoW4DmS$7fUVat.9iFSAePzA4j4Jm."
+	depends on ADK_RUNTIME_ADDUSER
+	help
+	  Predefine the user password enabled in the built image.
+	  Use ./host_*/usr/bin/mkcrypt to generate the hash.
+	  Default password is linux123
+
+config ADK_RUNTIME_USER_HOME
+	string "user home directory"
+	default "/home/adk"
+	depends on ADK_RUNTIME_ADDUSER
+	help
+	  Set the home directory to use.
+
+config ADK_RUNTIME_USER_SHELL
+	string "user shell"
+	default "/bin/sh"
+	depends on ADK_RUNTIME_ADDUSER
+	help
+	  Set the shell to use.
 
 config ADK_RUNTIME_START_SERVICES
 	bool "start services by default"