Is ukm out of date?

33 views
Skip to first unread message

Nick

unread,
Jul 28, 2020, 9:49:54 PM7/28/20
to gito...@googlegroups.com
I tried to use https://gitolite.com/gitolite/contrib/ukm.html because it sounds really neat, but I hit a snag. It doesn't seem to be compatible with the safety measures in perl added since it was last touched 5 years ago. But I am not super familiar with perl so maybe I have something configured wrong? Or maybe arch has made it more strict?

$ # on archlinux
$ sudo pacman -S gitolite
$ cp ~/.ssh/id_rsa.pub /tmp/admin.pub
$ sudo -u gitolite gitolite setup -pk /tmp/admin.pub
$ sudo wget -O /usr/lib/gitolite/commands/ukm https://raw.githubusercontent.com/sitaramc/gitolite/master/contrib/commands/ukm
$ sudo chmod +x /usr/lib/gitolite/commands/ukm
$ sudo -u gitolite vi ~gitolite/.gitolite.rc # -> add 'ukm', to ENABLE array

Verify it is enabled:

$ ssh gitolite@localhost help
Enter passphrase for key '/home/kousu/.ssh/id_rsa':
hello admin, this is gitolite@requiem running gitolite3 3.6.11 on git 2.27.0

list of remote commands available:

desc
help
info
perms
sskm
ukm
writable

But when I try to use it:

$ ssh gitolite@localhost ukm
Enter passphrase for key '/home/kousu/.ssh/id_rsa':
FATAL: Can't use global $_ in "my" at /usr/lib/gitolite/commands/ukm line 296, near "($_"
Execution of /usr/lib/gitolite/commands/ukm aborted due to compilation errors.


I'm using the perl given by ArchLinux:

$ pacman -Qi perl
Name : perl
Version : 5.32.0-1
Description : A highly capable, feature-rich programming language
Architecture : x86_64
URL : https://www.perl.org
Licenses : GPL PerlArtistic
Groups : None
Provides : [...]
Depends On : gdbm>=1.17 db glibc
Optional Deps : None
Required By : autoconf automake ghc-libs git gitolite gperftools groff hspell hyphen libwpg lm_sensors lxc netpbm ntp openssl
perl-common-sense perl-error perl-image-exiftool perl-json perl-json-xs perl-lchown perl-timedate perl-uri rlwrap
rsnapshot rsync strace texinfo valgrind
Optional For : aspell gd graphviz hexchat hunspell i3-wm insight-toolkit jemalloc libproxy qt5-base
Conflicts With : None
Replaces : None
Installed Size : 57.60 MiB
Packager : Florian Pritz <blue...@xinu.at>
Build Date : Sun 21 Jun 2020 05:19:43 AM
Install Date : Sun 28 Jun 2020 06:48:35 PM
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature

Sitaram Chamarty

unread,
Jul 29, 2020, 11:31:42 AM7/29/20
to Nick, gito...@googlegroups.com, Ralf Hemmecke
I'm sure Ralf will reply by and by, but looking at the code, I'm
pretty sure all you have to do is replace "my" with "local".

sitaram
> --
> You received this message because you are subscribed to the Google Groups "gitolite" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gitolite+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/gitolite/b3d394b65c8dd4efd4e831cb627311f0%40kousu.ca.

Nick Guenther

unread,
Jul 30, 2020, 2:30:12 PM7/30/20
to gito...@googlegroups.com
I've made and tested a patch (https://github.com/sitaramc/gitolite/pull/86) It seems to be working:

From 81ccd2ae7adfc2ab6af37753d817200203d5137b Mon Sep 17 00:00:00 2001
From: Nick <ngue...@uwaterloo.ca>
Date: Thu, 30 Jul 2020 14:22:34 -0400
Subject: [PATCH] Update ukm for modern perl

with perl 5.32.0 trying to use ukm gives:

```


$ ssh gitolite@localhost ukm
Enter passphrase for key '/home/kousu/.ssh/id_rsa':
FATAL: Can't use global $_ in "my" at /usr/lib/gitolite/commands/ukm line 296, near "($_"
Execution of /usr/lib/gitolite/commands/ukm aborted due to compilation errors.

```

This fixes it

```
$ ssh gitolite@localhost ukm list


Enter passphrase for key '/home/kousu/.ssh/id_rsa':

Hello alice, you manage the following keys:
fingerprint userid keyid
SHA256:VxHhqhOq5GxpPPUrYMeFMly4Mdc3YlP40qkLX4gr5fI alice alice
```
---
contrib/commands/ukm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/commands/ukm b/contrib/commands/ukm
index 3683154b9..4bb4f3eb2 100755
--- a/contrib/commands/ukm
+++ b/contrib/commands/ukm
@@ -293,7 +293,7 @@ sub sanitize_pubkeypath {
# This function is only relavant for guest key managers.
# It returns true if the pattern is OK and false otherwise.
sub required_guest_keyid {
- my ($_) = @_;
+ local ($_) = @_;
/$required_guest_pattern/ and ! /$forbidden_guest_pattern/;
}

Also available at
https://patch-diff.githubusercontent.com/raw/sitaramc/gitolite/pull/86.patch

July 29, 2020 6:54 PM, "Ralf Hemmecke" <ra...@hemmecke.org> wrote:

> Hi Sitaram, hi Nick,


>
> On 7/29/20 5:31 PM, Sitaram Chamarty wrote:
>
>> I'm sure Ralf will reply by and by, but looking at the code, I'm
>> pretty sure all you have to do is replace "my" with "local".
>

> Thank you for telling me directly, sometimes I might miss a ukm related
> message.
>
> Honestly, I know a bit of Perl, but I am certainly not as fluent in it
> as you are. I am currently on holiday, so it might take a while until I
> can check whether my vs. local solves the issue.
>
> I'll definitely will look into it (if it isn't resolved before that).
> I would, however, first have to setup an environment with a newer
> version of perl to be able to reproduce the problem.
>
> Ralf

Sitaram Chamarty

unread,
Feb 12, 2021, 10:59:43 AM2/12/21
to Ralf Hemmecke, Nick Guenther, gito...@googlegroups.com
On Thu, Feb 11, 2021 at 05:37:06PM +0100, Ralf Hemmecke wrote:
> Hi Sitaram,
>
> if you waited for input from my side, then I can only say that this "my"
> is certainly a missing knowledge on my side with newer perl versions.

The last mail I have on this is where I said I'd wait for Ralf
to weigh in.

>
> I do not see any reason whey the change "my" --> "local" should not be
> merged.
>
> Also
>
> sub required_guest_keyid {
> - my ($_) = @_;
> - /$required_guest_pattern/ and ! /$forbidden_guest_pattern/;
> + my ($p) = @_;
> + ($p =~ /$required_guest_pattern/) and ! ($p =~
> /$forbidden_guest_pattern/);
> }
>
> should be find.
>
> The latter seems somehow better to me since it doesn't unnecessarily
> mess with $_.
>
> Ralf
>
>
>
> On 11.02.21 17:20, Nick Guenther wrote:
> > July 30, 2020 2:31 PM, "Sitaram Chamarty" <sita...@gmail.com> wrote:
> >
> >> On Wed, Jul 29, 2020 at 06:54:22PM +0200, Ralf Hemmecke wrote:
> >>
> >>>
> >>

In fact, I don't have any email with this text:

> >> The only way this would need further introspection and testing
> >> would be if the actual processing involved a function call, thus
> >> making the dynamic scope something to consider. Since there is
> >> no function call, the dynamic scope is the same as the
> >> lexical scope.

which is odd.

> >>
> >> HTH.
> >
> > Hello! A gentle reminder about my patch here. It's still sitting open on github https://github.com/sitaramc/gitolite/pull/86; I know you don't like taking PRs by Github but it looks like it hasn't been merged to https://github.com/sitaramc/gitolite/blob/master/contrib/commands/ukm either.
> >

Anyway, I have merged and pushed the original pull request as
is.

sitaram

Reply all
Reply to author
Forward
0 new messages