-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add set_unix_permissions and syno_user_add_to_legacy_group #3161
Add set_unix_permissions and syno_user_add_to_legacy_group #3161
Conversation
6253204
to
a79e9a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely that is the right way to do it. And I guess it will probably fix troubles I saw with set_syno_permissions
.
Still to confirm it properly works as expected on DSM 5.2
mk/spksrc.service.installer
Outdated
# Set read/write permissions for GROUP for folder and subfolders | ||
if [ ! "`synoacltool -get \"${DIRNAME}\"| grep \"group:${GROUP}:allow:rwxpdDaARWcC-:fd--\"`" ]; then | ||
# First Unix permissions, but only if it's in Linux mode | ||
if [ ! "`synoacltool -get \"${DIRNAME}\"| grep \"Linux mocde\"`" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a typo: "mocde" !
mk/spksrc.service.installer
Outdated
|
||
# Check if user in old group | ||
MEMBERS="$(synogroup --get $LEGACY_GROUP | grep '^[0-9]' | sed 's/.*\[\([^]]*\)].*/\1/' | tr '\n' ' ')" | ||
if [[ $MEMBERS = *"$LEGACY_USER"* && $MEMBERS != *"$NEW_USER"* ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum. I would take care about such expression which may only run on bash
... so only on DSM 6. I would check against on DSM 5.2 which runs busybox
as default shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I came to this, because (at least on DSM61) this if
statement in postinst
always returns true and the user always gets added even if already present:~~
if ! synogroup --get "$GROUP" | grep '^[0-9]:\[${EFF_USER}\]' &> /dev/null; then
So something is wrong with this syntax, but I couldn't figure out what.~~
I just tested and indeed seems busybox does not support this syntax.. Will come up with a new one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah, my bash/shell-noobness that it took me an hour to figure out. It should be of course:
grep "^[0-9]:\[${EFF_USER}\]"
and not
grep '^[0-9]:\[${EFF_USER}\]'
In both commands.
mk/spksrc.service.installer
Outdated
if [[ $MEMBERS = *"$LEGACY_USER"* && $MEMBERS != *"$NEW_USER"* ]]; then | ||
# Add new user and remove old one | ||
echo "Adding '${NEW_USER}' to '${LEGACY_GROUP}' for backwards compatibility" >> ${INST_LOG} | ||
MEMBERS=${MEMBERS//$LEGACY_USER} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here again, probably requires bash
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support functions needed to: - Correct permissions on folders during upgrade in Linux mode. - For transfer for download-related packages from 'sc-media' to 'sc-download'
a79e9a2
to
323f639
Compare
Now it is working as expected.
|
Just found out that |
So that service_postinst can assume the var directory is available.
250f5af
to
0aea8ee
Compare
Removed Sonarr/Radarr specific things from this PR, creating separate one. |
Another small bug: all code assumes |
b9f0e30
to
3a9e320
Compare
OK. Do you consider it as ready to merge ? |
I would say so yes. |
If this is merged I'll do a proper rebuild of all the testing packages and test it again on all 3 systems. |
@ymartin59 @Diaoul Thanks a lot for inviting me to this elect club. More than happy to join, although I will consider myself as a "junior" member for the time being. @Safihre I have been on a business trip the last couple of days and am amazed about the progress you have made in the meantime. This is great, great work. Thanks so much! Looking forward to review "my" packages as well once this is in! |
if [ -n "${EFF_USER}" ]; then | ||
echo "Granting '${EFF_USER}' unix permissions on ${DIRNAME}" >> ${INST_LOG} | ||
if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 6 ]; then | ||
chown -R ${EFF_USER}:root "${DIRNAME}" >> $INST_LOG 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Safihre @ymartin59 I have continued to debug the upgrade problems on DSM5.2 systems that I ran into yesterday (packages did not start anymore after upgrade due to permission issues). I suspect the culprit is that the group is set to root
here rather than users
for DSM lt 6. Do you agree? If so, we probaby have to re-build all packages which were built since.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most test packages have only built for DSM 6... Group "users" is used for share folders accessible from other processes. For a package specific folder, group "root" should be far enough as owner matches service user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @ymartin59, but unfortunately in the case of Tvheaded everything is mixed. Package and "user" folders blend together.
But @m4tt075, do you need to use set_syno_permmissions
at all in your case? Since everything stays in the Package directory, do you need to call any permissions command at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't really impossible to configure TVH download location to a share folder as other applications ? I think that may be the key. If download locations are "hardcoded", it is still possible to create symbolic link from expected/original locations to DSM share folder(s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks for clarifying. @Safihre I agree with you. Unix permissions need to be sufficient for all folders within @appstore
. I have been able to implement that approach successfully for DSM6.1 now. I have tested clean installs, upgrading by itself and upgrading from the currently published package. But it does not work on DSM 5.2, when upgrading from the currently published package. In that version, ACL permissions were still set on the target
and traversal folders. Is there a way to "remove" those ACL permissions again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m4tt075 Why are ACL permissions applied? Only if set_syno_permissions
is called this happens, but that shouldn't be needed at all, right?
…nity#3161) * Add set_unix_permissions and syno_user_add_to_legacy_group Support functions needed to: - Correct permissions on folders during upgrade in Linux mode. - For transfer for download-related packages from 'sc-media' to 'sc-download' * Highlight logging of Generic Service to identify steps easier * Create INST_VAR before calling service_postinst So that service_postinst can assume the var directory is available. * Do not assume that EFF_USER exists
Support functions needed to:
@ymartin59 This separate PR to keep package PR's clean. But all my other PR's kind of depend on it.
After this is merged, I can rebase #3092 #3153 #3053 on
master
after that so they are package-only.