This repository has been archived by the owner on Feb 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14e8a6e
commit f5018b7
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2012-2018 Red Hat, Inc. | ||
# This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v2.0 | ||
# which is available at http://www.eclipse.org/legal/epl-2.0.html | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
|
||
set -e | ||
|
||
export USER_ID=$(id -u) | ||
export GROUP_ID=$(id -g) | ||
|
||
if ! grep -Fq "${USER_ID}" /etc/passwd; then | ||
# current user is an arbitrary | ||
# user (its uid is not in the | ||
# container /etc/passwd). Let's fix that | ||
cat ${HOME}/passwd.template | \ | ||
sed "s/\${USER_ID}/${USER_ID}/g" | \ | ||
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \ | ||
sed "s/\${HOME}/\/home\/user/g" > /etc/passwd | ||
|
||
cat ${HOME}/group.template | \ | ||
sed "s/\${USER_ID}/${USER_ID}/g" | \ | ||
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \ | ||
sed "s/\${HOME}/\/home\/user/g" > /etc/group | ||
fi | ||
|
||
if test "${USER_ID}" = 0; then | ||
# current user is root | ||
/usr/sbin/sshd -D & | ||
elif sudo -n true > /dev/null 2>&1; then | ||
# current user is a suoder | ||
sudo /usr/sbin/sshd -D & | ||
fi | ||
|
||
exec "$@" |