Bug 208135 - devel/gitlab-shell: Hooks need to be executable
Summary: devel/gitlab-shell: Hooks need to be executable
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Dmitry Marakasov
URL:
Keywords:
Depends on:
Blocks: 202468
  Show dependency treegraph
 
Reported: 2016-03-19 11:46 UTC by Johannes Jost Meixner
Modified: 2016-03-30 19:30 UTC (History)
1 user (show)

See Also:
ports: maintainer-feedback+


Attachments
Fix gitlab-shell hook permissions (596 bytes, patch)
2016-03-19 11:46 UTC, Johannes Jost Meixner
no flags Details | Diff
Extended patch (2.23 KB, patch)
2016-03-24 11:44 UTC, Dmitry Marakasov
no flags Details | Diff
Extended patch + fixes logfile location (2.66 KB, patch)
2016-03-27 21:53 UTC, Dmitry Marakasov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Jost Meixner freebsd_committer freebsd_triage 2016-03-19 11:46:50 UTC
Created attachment 168382 [details]
Fix gitlab-shell hook permissions

In order for gitlab to work, the files in hooks/ need to be executable by git:git.

Patch attached fixes this.

Tested in poudriere and with a production Gitlab.

Logs: http://pkg.fractalcells.com/logs/2016-03-19_11h34m50s/logs/gitlab-shell-2.6.10.log
Comment 1 Dmitry Marakasov freebsd_committer freebsd_triage 2016-03-24 11:44:58 UTC
Created attachment 168563 [details]
Extended patch

I propose extended patch, please test. Additional changes:

- Fix misused targets
- Scripts under %%DATADIR%%/bin should probably not be owned by git (they are executable anyway, and are not to be changes by git user, right?)
- I assume logfile will be written to, yet it's included into package - this will lead to errors on package deinstallation/upgrade. Handle logfile via @sample instead (also I see no need for g+w)
- @dir's are only needed for empty directories or directories with non-default permissions
Comment 2 Johannes Jost Meixner freebsd_committer freebsd_triage 2016-03-25 15:29:23 UTC
(In reply to Dmitry Marakasov from comment #1)
Please don't make the logfile a sample.

It needs to be touched into existence with the right user, but a .sample file in /var/log is wrong in my opinion.
Comment 3 Dmitry Marakasov freebsd_committer freebsd_triage 2016-03-26 23:30:37 UTC
(In reply to Johannes Jost Meixner from comment #2)

> Please don't make the logfile a sample.
> 
> It needs to be touched into existence with the right user, but a .sample
> file in /var/log is wrong in my opinion.

You may not add a volatile file into a package either. Possible solutions:
- Create a directory with right owner and point an application there, so it is able to create its logfile. The most correct solution IMO
- Create rc.d script (doesn't seem suitable here, as this port does not install any daemons)
- Create a file with @postexec and remove with @postunexec if it's empty
Comment 4 Johannes Jost Meixner freebsd_committer freebsd_triage 2016-03-27 09:52:31 UTC
(In reply to Dmitry Marakasov from comment #3)
> - Create a directory with right owner and point an application there, so it is able to create its logfile. The most correct solution IMO

This sounds good if you can make gitlab-shell work with changed logfile-paths (I don't know enough 



> - Create a file with @postexec and remove with @postunexec if it's empty

I was thinking about this too, and it sounds the best option actually. It's basically what is behind @sample anyway.
Comment 5 Dmitry Marakasov freebsd_committer freebsd_triage 2016-03-27 21:53:25 UTC
Created attachment 168706 [details]
Extended patch + fixes logfile location

Updated patch which uses dedicated log directory (writable by `git' user) for gitlab-shell.
Comment 6 Johannes Jost Meixner freebsd_committer freebsd_triage 2016-03-28 06:06:42 UTC
(In reply to Dmitry Marakasov from comment #5)
Thanks. This builds in poudriere, and works in Gitlab.

To verify, I created a project. 

root@976f96ad-f45e-11e5-88b9-8b2395c19741:~ # cat /var/log/gitlab-shell/gitlab-shell.log                 
# Logfile created on 2016-03-28 06:04:39 +0000 by logger.rb/44203
I, [2016-03-28T06:04:39.437248 #36087]  INFO -- : Adding project xmj/asdf.git at </home/git/repositories/xmj/asdf.git>.
I, [2016-03-28T06:04:39.476972 #36087]  INFO -- : Moving existing hooks directory and symlinking global hooks directory for /home/git/repositories/xmj/asdf.git.
root@976f96ad-f45e-11e5-88b9-8b2395c19741:~ #
Comment 7 Torsten Zühlsdorff 2016-03-29 13:39:20 UTC
Hello,

i'm right back from vacation and will have a look at your patches!

Thank you for your efforts! :)
Comment 8 Torsten Zühlsdorff 2016-03-30 09:36:44 UTC
Comment on attachment 168706 [details]
Extended patch + fixes logfile location

I approve the extended patch. This looks much better than my version and works fine also :)

Thank you both for fixing this issue! :)
Comment 9 Torsten Zühlsdorff 2016-03-30 09:38:32 UTC
I set the approval flag to + but the change is not stored. Same for -. I don't know why :/
Comment 10 commit-hook freebsd_committer freebsd_triage 2016-03-30 19:30:57 UTC
A commit references this bug:

Author: amdmi3
Date: Wed Mar 30 19:30:07 UTC 2016
New revision: 412190
URL: https://svnweb.freebsd.org/changeset/ports/412190

Log:
  - Make hooks executable
  - Fix misused targets
  - Fix plist permissions and owners
  - Fix log file handling

  PR:		208135
  Submitted by:	xmj, amdmi3
  Approved by:	ports@toco-domains.de (maintainer)

Changes:
  head/devel/gitlab-shell/Makefile
  head/devel/gitlab-shell/files/patch-config.yml.example
  head/devel/gitlab-shell/pkg-plist