mirror of
				https://github.com/drwetter/testssl.sh.git
				synced 2025-10-30 21:35:26 +01:00 
			
		
		
		
	fix: Manually create testssl user and home
				
					
				
			BusyBox `adduser` was reading config from `/etc` that unnecessarily populates the home folder with various dot files. Alternative approach is to create the user and home folder manually. This avoids some extra files like the `-` suffixed backup copies from `adduser`.
This commit is contained in:
		
							
								
								
									
										20
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								Dockerfile
									
									
									
									
									
								
							| @@ -70,17 +70,17 @@ EOF | |||||||
| FROM scratch | FROM scratch | ||||||
| ARG INSTALL_ROOT | ARG INSTALL_ROOT | ||||||
| COPY --link --from=builder ${INSTALL_ROOT} / | COPY --link --from=builder ${INSTALL_ROOT} / | ||||||
|  | RUN <<EOF | ||||||
|  |   # Create user: | ||||||
|  |   echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /etc/passwd | ||||||
|  |   echo 'testssl:x:1000:' >> /etc/group | ||||||
|  |   echo 'testssl:!::0:::::' >> /etc/shadow | ||||||
|  |  | ||||||
| # zypper package `busybox-adduser` fails to install with `--installroot`, |   # Create user home with SGID set: | ||||||
| # while the `shadow` package is too heavy just to add a user. |   install --mode 2755 --owner testssl --group testssl --directory /home/testssl | ||||||
| # |  | ||||||
| # Temporarily bind mount the `/bin` dir from another image that already |   # Add relative symlink to point to content that will COPY later: | ||||||
| # has the `adduser` command, and it'll update `/etc/{group,passwd,shadow}` for us: |   ln -sr /home/testssl/testssl.sh /usr/local/bin/ | ||||||
| # Absolute path provided as some base images PATH would use those binaries instead, |  | ||||||
| # `adduser` varies in supported args, so this should avoid any surprises: |  | ||||||
| RUN --mount=type=bind,from=busybox:latest,source=/bin,target=/bin <<EOF |  | ||||||
|   /bin/adduser -D -s /bin/bash testssl |  | ||||||
|   /bin/ln -s /home/testssl/testssl.sh /usr/local/bin/ |  | ||||||
| EOF | EOF | ||||||
|  |  | ||||||
| USER testssl | USER testssl | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Brennan Kinney
					Brennan Kinney