git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-cvsserver: pserver-auth-script

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 2, 2010, 14:33 UTC
Message-ID
<AANLkTil29nTVJS_dqsdyoH0BmRE8-U7HqNeeghDkbuEq@mail.gmail.com>
In-Reply-To
<20100702095406.7af15d20@ashinlaszlo.pta.neti.hu>
On Fri, Jul 2, 2010 at 07:54, László ÁSHIN <laszlo.ashin@neti.hu> wrote:
Show 116 quoted lines
> Hi,
>
> The following patch makes git-cvsserver capable of authenticating users through an external executable script using pserver method.
> The script can be specified in the gitcvs section of the config file:
> [gitcvs]
>        enabled = 1
>        authscript = /some/where/script.sh
>
> The script, itself will get username and password on its standard input, so it can look like something like this:
>
> #!/bin/sh
> read username
> read password
>
> wbinfo -a "$username%$password"
>
> --
> Only a return value of zero means a successful authentication.
>
> Please comment and keep me on cc.
>
> --
> Regards,
> László Áshin
>
> diff -ruN a/git-cvsserver b/git-cvsserver
> --- a/git-cvsserver     2010-07-01 15:31:18.000000000 +0200
> +++ b/git-cvsserver     2010-07-01 15:35:41.000000000 +0200
> @@ -200,35 +200,54 @@
>         # Fall through to LOVE
>     } else {
>         # Trying to authenticate a user
> -        if (not exists $cfg->{gitcvs}->{authdb}) {
> -            print "E the repo config file needs a [gitcvs] section with an 'authdb' parameter set to the filename of the authentication database\n";
> -            print "I HATE YOU\n";
> -            exit 1;
> -        }
> -
> -        my $authdb = $cfg->{gitcvs}->{authdb};
> -
> -        unless (-e $authdb) {
> -            print "E The authentication database specified in [gitcvs.authdb] does not exist\n";
> -            print "I HATE YOU\n";
> -            exit 1;
> -        }
> -
> -        my $auth_ok;
> -        open my $passwd, "<", $authdb or die $!;
> -        while (<$passwd>) {
> -            if (m{^\Q$user\E:(.*)}) {
> -                if (crypt($user, descramble($password)) eq $1) {
> -                    $auth_ok = 1;
> -                }
> -            };
> -        }
> -        close $passwd;
> +        if (exists $cfg->{gitcvs}->{authscript}) {
> +            my $authscript = $cfg->{gitcvs}->{authscript};
> +            unless (-x $authscript) {
> +                print "E The authentication script specified in [gitcvs.authscript] cannot be executed\n";
> +                print "I HATE YOU\n";
> +                exit 1;
> +            }
> +
> +            open SCRIPTIN, '|' . $authscript or die $!;
> +            print SCRIPTIN $user . "\n";
> +            print SCRIPTIN descramble($password) . "\n";
> +            close SCRIPTIN;
> +            if ($? != 0) {
> +                print "E External script authentication failed.\n";
> +                print "I HATE YOU\n";
> +                exit 1;
> +            }
> +        } else {
> +            if (not exists $cfg->{gitcvs}->{authdb}) {
> +                print "E the repo config file needs a [gitcvs] section with an 'authdb' parameter set to the filename of the authentication database\n";
> +                print "I HATE YOU\n";
> +                exit 1;
> +            }
> +
> +            my $authdb = $cfg->{gitcvs}->{authdb};
> +
> +            unless (-e $authdb) {
> +                print "E The authentication database specified in [gitcvs.authdb] does not exist\n";
> +                print "I HATE YOU\n";
> +                exit 1;
> +            }
> +
> +            my $auth_ok;
> +            open my $passwd, "<", $authdb or die $!;
> +            while (<$passwd>) {
> +                if (m{^\Q$user\E:(.*)}) {
> +                    if (crypt($user, descramble($password)) eq $1) {
> +                        $auth_ok = 1;
> +                    }
> +                };
> +            }
> +            close $passwd;
>
> -        unless ($auth_ok) {
> -            print "I HATE YOU\n";
> -            exit 1;
> -        }
> +            unless ($auth_ok) {
> +                print "I HATE YOU\n";
> +                exit 1;
> +            }
> +       }
>
>         # Fall through to LOVE
>     }
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Previous: László ÁSHINNext: Ævar Arnfjörð Bjarmason
Message 2 of 8 in “git-cvsserver: pserver-auth-script”
  1. git-cvsserver: pserver-auth-scriptLászló ÁSHIN, Jul 2, 2010
  2. Ævar Arnfjörð BjarmasonJul 2, 2010
  3. Ævar Arnfjörð BjarmasonJul 2, 2010
  4. Ævar Arnfjörð BjarmasonJul 2, 2010
  5. Jakub NarebskiJul 2, 2010
  6. Ævar Arnfjörð BjarmasonJul 2, 2010
  7. Áshin LászlóJul 3, 2010
  8. Ævar Arnfjörð BjarmasonJul 3, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.