Skip to content

Commit f151628

Browse files
authored
Merge pull request #16894 from grokability/resolve-webserver-permissions
Fix webserver/user file permissions issue
2 parents f181e0f + e44aad0 commit f151628

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 variables 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)