25a9982c by Adam Heath

Some uid/gid protections against 0.

1 parent 7c10c413
......@@ -4,12 +4,12 @@ set -ex
hostuser_home="$(getent passwd hostuser | cut -f 6 -d :)"
if [[ $GID ]]; then
if [[ $GID && $GID -ne 0 ]]; then
old_gid=$(getent group hostgroup | cut -f 3 -d :)
groupmod -g $GID hostgroup
find "$hostuser_home" -gid $old_gid -print0 | xargs -0r chgrp hostgroup
fi
if [[ $UID ]]; then
if [[ $UID && $UID -ne 0 ]]; then
usermod -u $UID hostuser
fi
......
......@@ -6,17 +6,13 @@ _mysql() {
mysqld_safe "$@"
}
if [[ $GID ]]; then
if [[ $GID && $GID -ne 0 ]]; then
old_gid=$(getent group mysql | cut -f 3 -d :)
groupmod -g $GID mysql
else
found_errors+=("gid not set")
fi
if [[ $UID ]]; then
if [[ $UID && $UID -ne 0 ]]; then
usermod -u $UID mysql
else
found_errors+=("uid not set")
fi
if [[ $(find /var/lib/mysql -maxdepth 1 -mindepth 1|wc -l) = 0 ]]; then
......@@ -24,13 +20,6 @@ if [[ $(find /var/lib/mysql -maxdepth 1 -mindepth 1|wc -l) = 0 ]]; then
zcat /var/lib/container/var_lib_mysql.tar.gz | tar -C /var/lib/mysql -xf -
fi
if [[ ${#found_errors[*]} -gt 0 ]]; then
for error in "${found_errors[@]}"; do
echo "$error"
done
exit 1
fi
declare -i i=0
mysqld_safe --skip-networking &
while eval [[ \$DB_INFO_$i ]]; do
......
......@@ -4,12 +4,12 @@ set -ex
node_home="$(getent passwd node | cut -f 6 -d :)"
if [[ $GID ]]; then
if [[ $GID && $GID -ne 0 ]]; then
old_gid=$(getent group node | cut -f 3 -d :)
groupmod -g $GID node
find "$node_home" -gid $old_gid -print0 | xargs -0r chgrp node
fi
if [[ $UID ]]; then
if [[ $UID && $UID -ne 0 ]]; then
usermod -u $UID node
fi
if [[ -e package.json ]]; then
......
......@@ -4,12 +4,12 @@ set -ex
hostuser_home="$(getent passwd hostuser | cut -f 6 -d :)"
if [[ $GID ]]; then
if [[ $GID && $GID -ne 0 ]]; then
old_gid=$(getent group hostgroup | cut -f 3 -d :)
groupmod -g $GID hostgroup
find "$hostuser_home" -gid $old_gid -print0 | xargs -0r chgrp hostgroup
fi
if [[ $UID ]]; then
if [[ $UID && $GID -ne 0 ]]; then
usermod -u $UID hostuser
fi
mkdir -p /run/php
......
......@@ -4,12 +4,12 @@ set -ex
hostuser_home="$(getent passwd hostuser | cut -f 6 -d :)"
if [[ $GID ]]; then
if [[ $GID && $GID -ne 0 ]]; then
old_gid=$(getent group hostgroup | cut -f 3 -d :)
groupmod -g $GID hostgroup
find "$hostuser_home" -gid $old_gid -print0 | xargs -0r chgrp hostgroup
fi
if [[ $UID ]]; then
if [[ $UID && $UID -ne 0 ]]; then
usermod -u $UID hostuser
fi
......
#!/bin/bash
declare -a found_errors
set -ex
if [[ $(find /var/lib/postgresql -maxdepth 1 -mindepth 1|wc -l) = 0 ]]; then
......@@ -10,13 +8,13 @@ fi
postgres_home="$(getent passwd postgres | cut -f 6 -d :)"
if [[ $GID ]]; then
if [[ $GID && $GID -ne 0 ]]; then
old_gid=$(getent group postgres | cut -f 3 -d :)
groupmod -g $GID postgres
find "$postgres_home" /etc/postgresql /var/run/postgresql -gid $old_gid -print0 | xargs -0r chgrp postgres
fi
if [[ $UID ]]; then
if [[ $UID && $UID -ne 0 ]]; then
old_uid=$(getent passwd postgres | cut -f 3 -d :)
usermod -u $UID postgres
find /etc/postgresql /var/run/postgresql -uid $old_uid -print0 | xargs -0r chown postgres
......
......@@ -4,12 +4,12 @@ set -ex
hostuser_home="$(getent passwd hostuser | cut -f 6 -d :)"
if [[ $GID ]]; then
if [[ $GID && $GID -ne 0 ]]; then
old_gid=$(getent group hostgroup | cut -f 3 -d :)
groupmod -g $GID hostgroup
find "$hostuser_home" -gid $old_gid -print0 | xargs -0r chgrp hostgroup
fi
if [[ $UID ]]; then
if [[ $UID && $UID -ne 0 ]]; then
usermod -u $UID hostuser
fi
......