Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions common/documentserver/bin/documentserver-generate-allfonts.sh.m4
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,19 @@ echo -n Generating js caches, please wait...

echo Done

# Setting user rights for files created in the previous steps
# Setting user rights for files created in the previous steps.
# Only the generated ones, by name: the converters in this directory belong to
# root, because the scripts in /usr/bin run them, and this script is one of
# those. Handing the directory over to ds here would put back what the packages
# take away, and a program root runs must not be one ds can rewrite. -h keeps
# chown on a symlink in place of one of these names, as chown -R did before,
# instead of handing ds whatever file the link points at.
if [ "${ONLYOFFICE_K8S_CONTAINER}" != "true" ]; then
chown -R ds:ds "$DIR/sdkjs"
chown -R ds:ds "$DIR/server/FileConverter/bin"
chown -h ds:ds \
"$DIR/server/FileConverter/bin/AllFonts.js" \
"$DIR/server/FileConverter/bin/font_selection.bin" \
"$DIR/server/FileConverter/bin/fonts.log" 2>/dev/null
chown -R ds:ds "$DIR/fonts"
fi

Expand Down
14 changes: 14 additions & 0 deletions deb/template/postinst.m4
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ ifelse('M4_DS_ADMINPANEL_ENABLE','1',`mkdir -p "$LOG_DIR/adminpanel"
chown ds:ds -R "$DIR"*
# set up read-only access to prevent modification ds's home directory
chmod a-w -R "$DIR"*
# what the root owned scripts in /usr/bin run stays owned by root: the
# blanket chown above hands everything under here to ds, and the owner of
# a program is one chmod away from replacing what root will execute. The
# directories count as much as the files: chmod a-w does not hold against
# the owner of a directory, who can make it writable again, and a ds
# writable directory lets ds swap out x2t no matter who owns the file in it.
# That goes for every directory on the way down, not only the last one:
# in a ds owned server/ ds can rename the root owned tools/ aside and put
# its own in its place. Only the directories themselves change owner, what
# is in them keeps its owner.
for f in "$DIR" "$DIR"*/server "$DIR"*/server/FileConverter "$DIR"*/npm "$DIR"*/server/tools "$DIR"*/server/tools/* "$DIR"*/server/FileConverter/bin "$DIR"*/server/FileConverter/bin/x2t "$DIR"*/server/FileConverter/bin/*.so* "$DIR"*/npm/json
do
if [ -e "$f" ]; then chown root:root "$f"; fi
done
chown ds:ds "$CONF_DIR"/*.json

getent group onlyoffice >/dev/null && { DATA_OWNER="onlyoffice:onlyoffice"; usermod -aG onlyoffice ds; } || DATA_OWNER="ds:ds"
Expand Down
16 changes: 13 additions & 3 deletions rpm/common.spec
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,12 @@ rm -rf "%{buildroot}"
%defattr(440, ds, ds, 555)
%{_localstatedir}/www/%{_ds_prefix}*/*

%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/npm/json
%attr(550, root, root) %{_localstatedir}/www/%{_ds_prefix}/npm/json
%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/server/DocService/docservice
%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/server/FileConverter/converter
%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/server/FileConverter/bin/docbuilder
%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/server/FileConverter/bin/x2t
%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/server/Metrics/metrics
%{?adminpanel:%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/server/AdminPanel/server/adminpanel}
%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}/server/tools/*
%if %{defined example}
%attr(550, ds, ds) %{_localstatedir}/www/%{_ds_prefix}-example/example
%endif
Expand All @@ -180,6 +178,18 @@ rm -rf "%{buildroot}"

%attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/server/FileConverter/bin/*.so*
%attr(744, root, root) %{_bindir}/documentserver-*.sh
# The scripts installed into /usr/bin are owned by root and run these programs,
# so the programs and every directory on the way down to them are root owned
# too: ds may execute them but neither rewrite them nor rename them, or a
# directory holding them, aside from a writable parent.
%dir %attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}
%dir %attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/server
%dir %attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/server/FileConverter
%dir %attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/npm
%dir %attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/server/tools
%dir %attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/server/FileConverter/bin
%attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/server/tools/*
%attr(755, root, root) %{_localstatedir}/www/%{_ds_prefix}/server/FileConverter/bin/x2t
%attr(-, root, root) %{_sysconfdir}/logrotate.d/*
%attr(-, root, root) %{_sysconfdir}/nginx/%{nginx_conf_d}/*
%attr(-, root, root) %{_sysconfdir}/nginx/includes/*
Expand Down
Loading