mirror of
https://github.com/atmoz/sftp.git
synced 2024-11-17 12:51:33 -05:00
Remove unused stdin args and parse args from env
This commit is contained in:
parent
9405974cc9
commit
a2863269a0
3 changed files with 22 additions and 13 deletions
11
README.md
11
README.md
|
@ -18,13 +18,14 @@ This is an automated build linked with the [debian](https://hub.docker.com/_/deb
|
|||
|
||||
# Usage
|
||||
|
||||
- Required: define users in command arguments or in file mounted as `/etc/sftp/users.conf`
|
||||
(syntax: `user:pass[:e][:uid[:gid[:dir1[,dir2]...]]]...`).
|
||||
- Define users in (1) command arguments, (2) `SFTP_USERS` environment variable
|
||||
or (3) in file mounted as `/etc/sftp/users.conf` (syntax:
|
||||
`user:pass[:e][:uid[:gid[:dir1[,dir2]...]]] ...`, see below for examples)
|
||||
- Set UID/GID manually for your users if you want them to make changes to
|
||||
your mounted volumes with permissions matching your host filesystem.
|
||||
- Add directory names at the end, if you want to create them under the user's
|
||||
home directory. Perfect when you just want a fast way to upload something.
|
||||
- Optional (but recommended): mount volumes.
|
||||
- Directory names at the end will be created under user's home directory with
|
||||
write permission, if they aren't already present.
|
||||
- Mount volumes
|
||||
- The users are chrooted to their home directory, so you can mount the
|
||||
volumes in separate directories inside the user's home directory
|
||||
(/home/user/**mounted-directory**) or just mount the whole **/home** directory.
|
||||
|
|
15
entrypoint
15
entrypoint
|
@ -131,18 +131,17 @@ if [ ! -f "$userConfFinalPath" ]; then
|
|||
cat "$userConfPath" | grep -v -E "$reArgSkip" > "$userConfFinalPath"
|
||||
fi
|
||||
|
||||
# Append users from STDIN to final config
|
||||
# DEPRECATED on 2017-10-08, DO NOT USE
|
||||
# TODO: Remove code after 6-12 months
|
||||
if [ ! -t 0 ]; then
|
||||
while IFS= read -r user || [[ -n "$user" ]]; do
|
||||
if $startSshd; then
|
||||
# Append users from arguments to final config
|
||||
for user in "$@"; do
|
||||
echo "$user" >> "$userConfFinalPath"
|
||||
done
|
||||
fi
|
||||
|
||||
if $startSshd; then
|
||||
# Append users from arguments to final config
|
||||
for user in "$@"; do
|
||||
if [ -n "$SFTP_USERS" ]; then
|
||||
# Append users from environment variable to final config
|
||||
usersFromEnv=($SFTP_USERS) # as array
|
||||
for user in "${usersFromEnv[@]}"; do
|
||||
echo "$user" >> "$userConfFinalPath"
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -52,10 +52,12 @@ function beforeTest() {
|
|||
$sudo docker run \
|
||||
-v "$tmpDir/users:/etc/sftp/users.conf:ro" \
|
||||
-v "$scriptDir/id_rsa.pub":/home/test/.ssh/keys/id_rsa.pub:ro \
|
||||
-v "$scriptDir/id_rsa.pub":/home/userFromEnv/.ssh/keys/id_rsa.pub:ro \
|
||||
-v "$scriptDir/id_rsa.pub":/home/user.with.dot/.ssh/keys/id_rsa.pub:ro \
|
||||
-v "$tmpDir":/home/test/share \
|
||||
--name "$sftpContainerName" \
|
||||
--expose 22 \
|
||||
-e "SFTP_USERS=userFromEnv::$(id -u):$(id -g) userFromEnv2::$(id -u):$(id -g)" \
|
||||
-d "$sftpImageName" \
|
||||
> "$redirect"
|
||||
|
||||
|
@ -145,6 +147,13 @@ function testUserWithDotLogin() {
|
|||
assertReturn $? 0
|
||||
}
|
||||
|
||||
function testLoginUsingUserFromEnv() {
|
||||
$skipAllTests && skip && return 0
|
||||
|
||||
runSftpCommands "$sftpContainerName" "userFromEnv" "exit"
|
||||
assertReturn $? 0
|
||||
}
|
||||
|
||||
function testWritePermission() {
|
||||
$skipAllTests && skip && return 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue