forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hyperledger#4292] Fix mounted data path directory permissions for be…
…su user (hyperledger#7575) * Fix mounted data path directory permissions for besu user Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * Add besu CLI option to output dirs needing permission update Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * run spotless apply to handle PR test failure Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * Remove newly added --print-paths-and-exit option from config file test This option doesn't have a corresponding config file entry as it's a standalone option to be used with docker containers Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * Add optional user argument to --print-paths-and-exit and fix directory permissions Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * Correct build.gradle changes, remove a duplicate line and extra whitespaces Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * Fix checking for user in path's group membership Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * Add platform check to restrict --print-paths-and-exit option usage to Linux and Mac Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> * Apply suggestions from code review Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Bhanu Pulluri <59369753+pullurib@users.noreply.github.com> --------- Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> Signed-off-by: Bhanu Pulluri <59369753+pullurib@users.noreply.github.com> Co-authored-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
- Loading branch information
1 parent
578104e
commit 0d9fa16
Showing
9 changed files
with
217 additions
and
3 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
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
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,49 @@ | ||
#!/bin/bash | ||
## | ||
## Copyright contributors to Hyperledger Besu. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
## the License. You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
## an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
## specific language governing permissions and limitations under the License. | ||
## | ||
## SPDX-License-Identifier: Apache-2.0 | ||
## | ||
|
||
# Run Besu first to get paths needing permission adjustment | ||
output=$(/opt/besu/bin/besu --print-paths-and-exit $BESU_USER_NAME "$@") | ||
|
||
# Parse the output to find the paths and their required access types | ||
echo "$output" | while IFS=: read -r prefix path accessType; do | ||
if [[ "$prefix" == "PERMISSION_CHECK_PATH" ]]; then | ||
# Change ownership to besu user and group | ||
chown -R $BESU_USER_NAME:$BESU_USER_NAME $path | ||
|
||
# Ensure read/write permissions for besu user | ||
|
||
echo "Setting permissions for: $path with access: $accessType" | ||
|
||
if [[ "$accessType" == "READ" ]]; then | ||
# Set read-only permissions for besu user | ||
# Add execute for directories to allow access | ||
find $path -type d -exec chmod u+rx {} \; | ||
find $path -type f -exec chmod u+r {} \; | ||
elif [[ "$accessType" == "READ_WRITE" ]]; then | ||
# Set read/write permissions for besu user | ||
# Add execute for directories to allow access | ||
find $path -type d -exec chmod u+rwx {} \; | ||
find $path -type f -exec chmod u+rw {} \; | ||
fi | ||
fi | ||
done | ||
|
||
# Finally, run Besu with the actual arguments passed to the container | ||
# Construct the command as a single string | ||
COMMAND="/opt/besu/bin/besu $@" | ||
|
||
# Switch to the besu user and execute the command | ||
exec su -s /bin/bash $BESU_USER_NAME -c "$COMMAND" |
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
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
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
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
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,10 @@ | ||
--- | ||
# runtime docker tests | ||
file: | ||
/var/lib/besu: | ||
exists: true | ||
owner: besu | ||
mode: "0755" | ||
process: | ||
java: | ||
running: true |
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