Skip to content

Commit

Permalink
login: fake /proc/sys/fs/inotify/max_user_watches
Browse files Browse the repository at this point in the history
  • Loading branch information
sylirre committed Nov 15, 2024
1 parent 2abfb39 commit 41eb221
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions proot-distro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ run_proot_cmd() {
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.version:/proc/version" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.vmstat:/proc/vmstat" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_entry_cap_last_cap:/proc/sys/kernel/cap_last_cap" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_inotify_max_user_watches:/proc/sys/fs/inotify/max_user_watches" \
--bind="${INSTALLED_ROOTFS_DIR}/${distro_name}/sys/.empty:/sys/fs/selinux" \
/usr/bin/env -i \
"HOME=/root" \
Expand Down Expand Up @@ -978,6 +979,12 @@ setup_fake_sysdata() {
40
EOF
fi

if [ ! -f "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_inotify_max_user_watches" ]; then
cat <<- EOF > "${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_inotify_max_user_watches"
4096
EOF
fi
}

command_install_help() {
Expand Down Expand Up @@ -1829,35 +1836,29 @@ command_login() {
# With this tools should assume that no SELinux present.
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/sys/.empty:/sys/fs/selinux" "$@"

# Fake /proc/loadavg if necessary.
# Fake various /proc entries commonly used by programs unless read access
# available.
if ! cat /proc/loadavg > /dev/null 2>&1; then
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.loadavg:/proc/loadavg" "$@"
fi

# Fake /proc/stat if necessary.
if ! cat /proc/stat > /dev/null 2>&1; then
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.stat:/proc/stat" "$@"
fi

# Fake /proc/uptime if necessary.
if ! cat /proc/uptime > /dev/null 2>&1; then
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.uptime:/proc/uptime" "$@"
fi

# Fake /proc/version if necessary.
if ! cat /proc/version > /dev/null 2>&1; then
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.version:/proc/version" "$@"
fi

# Fake /proc/vmstat if necessary.
if ! cat /proc/vmstat > /dev/null 2>&1; then
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.vmstat:/proc/vmstat" "$@"
fi

# Fake /proc/sys/kernel/cap_last_cap if necessary.
if ! cat /proc/sys/kernel/cap_last_cap > /dev/null 2>&1; then
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_entry_cap_last_cap:/proc/sys/kernel/cap_last_cap" "$@"
fi
if ! cat /proc/sys/fs/inotify/max_user_watches > /dev/null 2>&1; then
set -- "--bind=${INSTALLED_ROOTFS_DIR}/${distro_name}/proc/.sysctl_inotify_max_user_watches:/proc/sys/fs/inotify/max_user_watches" "$@"
fi

# Bind /tmp to /dev/shm.
if [ ! -d "${INSTALLED_ROOTFS_DIR}/${distro_name}/tmp" ]; then
Expand Down

0 comments on commit 41eb221

Please sign in to comment.