Skip to content

Commit 9cae52c

Browse files
committed
Move root/opt and usr/bin scripts to src.
Move scripts to version agnostic pathway which allows copying during generation.
1 parent fe72fa1 commit 9cae52c

4 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Set current user in nss_wrapper
2+
USER_ID=$(id -u)
3+
GROUP_ID=$(id -g)
4+
5+
if [ x"$USER_ID" != x"0" -a x"$USER_ID" != x"1001" ]; then
6+
7+
NSS_WRAPPER_PASSWD=/opt/app-root/etc/passwd
8+
NSS_WRAPPER_GROUP=/etc/group
9+
10+
cat /etc/passwd | sed -e 's/^default:/builder:/' > $NSS_WRAPPER_PASSWD
11+
12+
echo "default:x:${USER_ID}:${GROUP_ID}:Default Application User:${HOME}:/sbin/nologin" >> $NSS_WRAPPER_PASSWD
13+
14+
export NSS_WRAPPER_PASSWD
15+
export NSS_WRAPPER_GROUP
16+
export LD_PRELOAD=libnss_wrapper.so
17+
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
async
2+
mime
3+
mkdirp
4+
qs
5+
minimatch
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This will make scl collection binaries work out of box.
2+
unset BASH_ENV PROMPT_COMMAND ENV
3+
source scl_source enable rh-nodejs${NODEJS_VERSION}

src/root/usr/bin/fix-permissions

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
# Allow this script to fail without failing a build
4+
set +e
5+
6+
SYMLINK_OPT=${2:--L}
7+
8+
# Fix permissions on the given directory or file to allow group read/write of
9+
# regular files and execute of directories.
10+
11+
[ $(id -u) -ne 0 ] && CHECK_OWNER=" -uid $(id -u)"
12+
13+
# If argument does not exist, script will still exit with 0,
14+
# but at least we'll see something went wrong in the log
15+
if ! [ -e "$1" ] ; then
16+
echo "ERROR: File or directory $1 does not exist." >&2
17+
# We still want to end successfully
18+
exit 0
19+
fi
20+
21+
find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -gid 0 -exec chgrp 0 {} +
22+
find $SYMLINK_OPT "$1" ${CHECK_OWNER} \! -perm -g+rw -exec chmod g+rw {} +
23+
find $SYMLINK_OPT "$1" ${CHECK_OWNER} -perm /u+x -a \! -perm /g+x -exec chmod g+x {} +
24+
find $SYMLINK_OPT "$1" ${CHECK_OWNER} -type d \! -perm /g+x -exec chmod g+x {} +
25+
26+
# Always end successfully
27+
exit 0

0 commit comments

Comments
 (0)