forked from ungleich-public/cdist
		
	[type/__user] Fix shadow explorer for OpenBSD
This commit is contained in:
		
					parent
					
						
							
								45890cc7e4
							
						
					
				
			
			
				commit
				
					
						999e7b0134
					
				
			
		
					 1 changed files with 13 additions and 7 deletions
				
			
		| 
						 | 
					@ -23,18 +23,24 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
name=$__object_id
 | 
					name=$__object_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
case $("$__explorer/os") in
 | 
					case $("${__explorer}/os") in
 | 
				
			||||||
  'freebsd'|'netbsd'|'openbsd')
 | 
					  freebsd|netbsd)
 | 
				
			||||||
    database='passwd'
 | 
					    database='passwd'
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  # Default to using shadow passwords
 | 
					  openbsd)
 | 
				
			||||||
 | 
					    database='master.passwd'
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
  *)
 | 
					  *)
 | 
				
			||||||
 | 
					    # Default to using shadow passwords
 | 
				
			||||||
    database='shadow'
 | 
					    database='shadow'
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if command -v getent >/dev/null; then
 | 
					if command -v getent >/dev/null 2>&1
 | 
				
			||||||
  getent "$database" "$name" || true
 | 
					then
 | 
				
			||||||
elif [ -f /etc/shadow ]; then
 | 
					  getent "${database}" "${name}" 2>/dev/null && exit || true  # fallback to file
 | 
				
			||||||
  grep "^${name}:" /etc/shadow || true
 | 
					fi
 | 
				
			||||||
 | 
					if test -n "${database}" -a -f "/etc/${database}"
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					  grep -e "^${name}:" "/etc/${database}" && exit || true  # ignore failure
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue