gpt4 book ai didi

perl - SVN::Client中的SVN登录访问提示

转载 作者:行者123 更新时间:2023-12-02 05:04:12 25 4
gpt4 key购买 nike

use SVN::Client;
my $ctx = new SVN::Client(
auth => [SVN::Client::get_simple_provider(),
SVN::Client::get_simple_prompt_provider(\&simple_prompt,2),
SVN::Client::get_username_provider()]
);

$ctx->cat(\*STDOUT, 'http://mysvn.repo.com/www/xxx','HEAD');

sub simple_prompt {
my $cred = shift;
my $realm = shift;
my $default_username = shift;
my $may_save = shift;
my $pool = shift;

print "Enter authentication info for realm: $realm\n";
print "Username: ";
my $username = <>;
chomp($username);
$cred->username($username);
print "Password: ";
my $password = <>;
chomp($password);
$cred->password($password);
}

问题

首次登录后,SVN 会缓存凭据并且不会提示我再次输入身份验证。我在 configservers 文件中启用了某些条目以禁用缓存。但它没有用。

还有一件事:
我使用 CPAN 安装了 SVN::Client 并使用 apt-get 安装了 svn/apache 库。不知道perl模块用的是哪个SVN。

我更改的配置是我后来重新安装的 SVN 的配置。

有人可以告诉我如何解决这个问题吗?我希望 perl 脚本始终提示输入凭据。

最佳答案

根据 this :

The functions that return the svn_auth_provider_object_t for prompt style providers take a reference to a Perl subroutine to use for the callback. The first parameter each of these subroutines receive is a credential object. ... These functions and credential objects always have a may_save member which specifies if the authentication data will be cached.

所以,我想在实现回调时,您需要设置 $may_save:

$cred->may_save(0);

或与描述的用户交互here :

print(
$may_save
? "(R)eject, accept (t)emporarily or accept (p)ermanently? "
: "(R)eject or accept (t)emporarily? "
);

my $choice = lc(substr(<STDIN> || 'R', 0, 1));

if ($choice eq 't') {
$cred->may_save(0);
}
elsif ($may_save and $choice eq 'p') {
$cred->may_save(1);
}

关于perl - SVN::Client中的SVN登录访问提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13517337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com