Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jul 2, 2018

With the current run file, gogs is unable to start because its home directory is owned by root. It should be owned by the user gogs as the program needs to create a .gitconfig file in there.

@Gottox
Copy link
Member

Gottox commented Jul 2, 2018

Please increase the revision of the package 👍

@Duncaen
Copy link
Member

Duncaen commented Jul 2, 2018

I don't think its a good idea to recursively chown the home directory each time the service starts.

@ghost
Copy link
Author

ghost commented Jul 2, 2018

True that if the run script is launched by a regular user, their whole home directory would be messed up.

I reverted my changes and just added the originally missing chown (for ${HOME} and ${HOME}/data).
Now what if the user already has a data or repo folder in their home directory? Should this case be considered?

I also increased the revision number in the template.

@Duncaen
Copy link
Member

Duncaen commented Jul 2, 2018

But still, why would the home directory owned by root, shouldn't this be fixed at the root and not while starting the service?

@ghost
Copy link
Author

ghost commented Jul 3, 2018

I'm not sure I understand your question, but I will try to answer by clearing things up.

why would the home directory owned by root

The home directory here is actually /srv/gogs/ right? That directory is owned by root because it is created by the service run script. That is why I want to chown it right away.

shouldn't this be fixed at the root and not while starting the service?

After looking into other packages, it doesn't look like an uncommon thing to do. This is my first contribution, so I get inspired by others and try to do minimal changes :)

That said, it could be improved by a simple test if the folder exists. The mkdir and chown lines could then be executed only at first start. I will do this, if you think it's necessary.

I will be on irc from now on, if needed.

@ghost
Copy link
Author

ghost commented Jul 17, 2018

  • moved /etc/gogs.ini to /etc/gogs/conf.ini.
    On first start, Gogs attempts to create a temporary file in /etc/ (beside its .ini file) but fails with the following error:
    Fail to save configuration: open /etc/gogs.ini.139946627.tmp: permission denied
    Having the .ini file in a subdir of /etc/ with write permissions for user gogs fixed the issue.
    I suppose this change would break the installation in case a user is updating from the previous revision of the package.

  • create directories using make_dirs rather than doing it in the run script.
    note: subdirectories of gogs' home are created by Gogs if they don't exist, so the package doesn't need to create them.

  • cleaned up run script and start the service as user gogs.

There is one more potential issue:
gogs modifies the /etc/gogs/conf.ini file
this triggers an error when uninstalling:

$ sudo xbps-remove -R gogs

Name Action    Version           New version            Download size
gogs remove    0.11.43_2         -                      -

Size freed on disk:             41MB
Space available on disk:       192GB

Do you want to continue? [Y/n]
Removing `gogs-0.11.43_2' ...
Disabled gogs (gogs) system user/group.
ERROR: gogs-0.11.43_2: configuration file `/etc/gogs/conf.ini' SHA256 mismatch, preserving file
Removed `gogs-0.11.43_2' successfully.

0 downloaded, 0 installed, 0 updated, 0 configured, 1 removed.

Is it supposed to stay this way ?

post)
if [ "$UPDATE" = "no" ]; then
chown gogs:gogs etc/gogs.ini
chown gogs:gogs /etc/gogs/conf.ini
Copy link
Member

@Gottox Gottox Jul 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paths in INSTALL scripts must be relative in case xbps-install is used with --rootdir <PATH> and chroot(2) isn't available. xbps chdirs to the rootdir in such a case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@maxice8
Copy link
Contributor

maxice8 commented Aug 14, 2018

ping

@ghost ghost closed this Sep 19, 2018
@ghost ghost deleted the gogs-service-bugfix branch September 19, 2018 18:03
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants