views:

1776

answers:

11

When I try to do any svn command and supply the "--username" and/or "--password" options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified by "--username". Neither "--no-auth-cache" nor "--non-interactive" have any effect on this. This is a problem because I'm trying to call svn commands from a script, and I can't have it show the prompt.

For example, logged in as user1:

# $ svn update --username 'user2' --password 'password'
# [email protected]'s password:

Other options work correctly:

# $ svn --version --quiet
# 1.3.2

Why does it prompt me? And why is it asking for user1's password instead of user2's? I'm 99% sure all of my permissions are set correctly. Is there some config option for svn that switches off command-line passwords? Or is it something else entirely?

I'm running svn 1.3.2 (r19776) on Fedora Core 5 (Bordeaux).


Here's a list of my environment variables (with sensitive information X'ed out). None of them seem to apply to SVN:

# HOSTNAME=XXXXXX
# TERM=xterm
# SHELL=/bin/sh
# HISTSIZE=1000
# KDE_NO_IPV6=1
# SSH_CLIENT=XXX.XXX.XXX.XXX XXXXX XX
# QTDIR=/usr/lib/qt-3.3
# QTINC=/usr/lib/qt-3.3/include
# SSH_TTY=/dev/pts/2
# USER=XXXXXX
# LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
# KDEDIR=/usr
# MAIL=/var/spool/mail/XXXXXX
# PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
# INPUTRC=/etc/inputrc
# PWD=/home/users/XXXXXX/my_repository
# KDE_IS_PRELINKED=1
# LANG=en_US.UTF-8
# SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
# SHLVL=1
# HOME=/home/users/XXXXXX
# LOGNAME=XXXXXX
# QTLIB=/usr/lib/qt-3.3/lib
# CVS_RSH=ssh
# SSH_CONNECTION=69.202.73.122 60998 216.7.19.47 22
# LESSOPEN=|/usr/bin/lesspipe.sh %s
# G_BROKEN_FILENAMES=1
# _=/bin/env
# OLDPWD=/home/users/XXXXXX
A: 

Check your environment variables carefully, there might be some variable used by SVN that is causing this.

Drakiula
A: 

Best I can give you is a "works for me" on SVN 1.5. You may try adding --no-auth-cache to your svn update to see if that lets you override more easily.

If you want to permanently switch from user2 to user1, head into ~/.subversion/auth/ on *nix and delete the auth cache file for domain.com (most likely in ~/.subversion/auth/svn.simple/ -- just read through them and you'll find the one you want to drop). While it is possible to update the current auth cache, you have to make sure to update the length tokens as well. Simpler just to get prompted again next time you update.

Thomas G. Mayfield
+1  A: 

This is a long shot, but perhaps the svn you're executing isn't the real svn - is there an alias, function, shell script, or other command that's being hit? If there's an svn wrapper, maybe it's not so good about passing arguments along.

which svn
type -a svn
Blair Conrad
+1  A: 

Do you actually have the single quotes in your command? I don't think they are necessary. Plus, I think you also need --no-auth-cache and --non-interactive

Here is what I use (no single quotes)

--non-interactive --no-auth-cache --username XXXX --password YYYY

See the Client Credentials Caching documentation in the svnbook for more information.

crashmstr
A: 

Another long shot: are you 100% sure that the password is correct? If not, svn doesn't give you an error message. (On my system, with svn 1.4.4, it simply asks me for another username, but maybe 1.3.2 behaves differently?)

If you just do

$ svn update --username user2

does it still ask for user1's password?

dF
A: 

In response to some of the answers so far:

@Blair Conrad:

# $ which svn
# /usr/bin/svn

# $ type -a svn
# svn is /usr/bin/svn

# $ file /usr/bin/svn
# /usr/bin/svn: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, stripped

Doesn't seem like anything too funky is going on.


@crashmstr:

There are some crazy symbols in my password that would need escaping without the quotes. Also, using "--non-interactive --no-auth-cache" still gives me the prompt (I'm really confused about why "--non-interactive" doesn't work).


@Daniel:

I'm sure the password is correct.

And it asks for the password for whatever user I'm logged in as, not the one specified by --username:

# $ svn update --username user2
# [email protected]'s password: 

@Joril:

My config file is using the defaults (everything is commented out).


@Thomas:

# $ svn info
# Path: .
# URL: svn+ssh://[email protected]/path/to/repo
# Repository Root: svn+ssh://[email protected]/path/to/repo
# Repository UUID: 8397572a-6293-4696-b0bc-7f7839384894
# Revision: 40
# Node Kind: directory
# Schedule: normal
# Last Changed Author: user1
# Last Changed Rev: 40
# Last Changed Date: 2008-08-28 15:45:26 -0400 (Thu, 28 Aug 2008)

It is an svn+ssh repository, but I didn't think that that mattered since in this case I'm just running the svn commands locally (on the same machine as the actual repository). Is it making an ssh connection to itself? If so, can I check it out locally using svn:// so that I can use the "--username" and "--password" options?

Matt Kantor
A: 

I don't know *nix shells - but are you actually using the single quotes there? Shouldn't they be double quotes?

Duncan Smart
A: 

Any custom configuration inside your $HOME/.subversion maybe?

Joril
+8  A: 

The prompt you're getting doesn't look like Subversion asking you for a password, it looks like ssh asking for a password. So my guess is that you have checked out an svn+ssh:// checkout, not an svn:// or http:// or https:// checkout.

IIRC all the options you're trying only work for the svn/http/https checkouts. Can you run svn info to confirm what kind of repository you are using ?

If you are using ssh, you should set up key-based authentication so that your scripts will work without prompting for a password.

Thomas Vander Stichele
A: 

The problem was that the working copy was checked out via svn+ssh (thanks, Thomas). Instead of setting up ssh keys as was suggested, I just checked out a new working copy using svn://domain.com/path/to/repo rather than svn+ssh://domain.com/path/to/repo. Because this working copy is on the same machine as the repository itself, I'm not really missing out on anything, and I can now use the --password and --username options gratuitously. Seems obvious now that I think about it.

Matt Kantor
+1  A: 

I had this same issue and solved it by setting up my ~/.ssh/config file to explicitly use the correct username (i.e. the one you use to login to the server, not your local machine). So, for example:

Host server.hostname
  User username

I found this blog post helpful: http://www.highlevelbits.com/2007/04/svn-over-ssh-prompts-for-wrong-username.html

tjstankus