Skip to content

Commit f7533c5

Browse files
author
Jeremy Price
committed
Fix webserver/user file permissions issue
Fixes #16777 We weren't adding the webserver user to the app-user's group, which was a problem for the webserver trying to write to the log file if it had been created by a user-owned process (like a cron) or the installation script chown-ing everything... even though the log file was created 664 This would often present in mysterious ways. In the linked case, trying to upload a cvs for import would fail with an unhelpful message, because the actual error is swallowed in the generic error handler for the page. I've filed an issue to hopefully help with that: #16893 Used this opportunity to condense some logic that was identical between architectures,
1 parent f181e0f commit f7533c5

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

snipeit.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,22 @@ create_user () {
179179

180180
if [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]] || [[ "$distro" == "Raspbian" ]] ; then
181181
/usr/sbin/adduser --quiet --disabled-password --gecos 'Snipe-IT User' "$APP_USER"
182-
su -c "/usr/sbin/usermod -a -G "$apache_group" "$APP_USER""
183182
else
184-
adduser "$APP_USER"
185-
usermod -a -G "$apache_group" "$APP_USER"
183+
adduser -c "Snipe-IT User" "$APP_USER"
186184
fi
185+
186+
# Add the user to the apache group so the app can write to any files apache
187+
# creates (eg, if apache process creates the log, but then a an app-user-owned
188+
# cron also tries writing
189+
usermod -a -G "$apache_group" "$APP_USER"
190+
191+
# Now do the reverse -- so apache can write to the log that the user may
192+
# have created. This was actively a problem on new installs, hobbling
193+
# imports
194+
# redefining these varaible just for clarity
195+
apache_user="$apache_group"
196+
app_group="$APP_USER"
197+
usermod -a -G "$app_group" "$apache_user"
187198
}
188199

189200
run_as_app_user () {

0 commit comments

Comments
 (0)