Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error could not read Username for '[URL]': No such device or address #5

Closed
cwenger opened this issue Mar 3, 2014 · 16 comments

Comments

Projects
None yet
6 participants
@cwenger
Copy link

commented Mar 3, 2014

When trying to clone a Git repository that requires authentication, I get "Error could not read Username for '[URL]': No such device or address". Through the command line it asks for my username and password and then works fine. Any operations I try to do through RabbitVCS Git that require authentication also fail. There is a workaround but it involves adding your username and password to the repository URL but then they are exposed in plain text. This issue was originally posted at https://code.google.com/p/rabbitvcs/issues/detail?id=836.

@Gwani

This comment has been minimized.

Copy link

commented Mar 4, 2014

Same problem here. Using RabbitVCS version 0.16.0 on Linux Mint 16 (Cinnamon) via RabbitVCS-PPA (http://ppa.launchpad.net/rabbitvcs). Trying to clone a git repository on my server (https://my-server-ip:444/git/project) gives me

Error could not read Username for 'https://my-server-ip:444': No such device or address

where i would expect some kind of dialog asking me for username/password. Using 'git' to clone the repository via the command line works fine. Pushing to repo gives same error, just like in the original issue.

@david-libremone

This comment has been minimized.

Copy link

commented Mar 4, 2014

I know this won't help everyone, but if you switch to key-based authentication does that help? (I only use key-based authentication so I haven't encountered this issue, just hoping I can provide a workaround while the RabbitVCS team work on a solution.)

@CloCkWeRX

This comment has been minimized.

Copy link
Member

commented Mar 4, 2014

Can I get either of you to paste a full backtrace for that error?

@CloCkWeRX CloCkWeRX added the bug label Mar 4, 2014

@Gwani

This comment has been minimized.

Copy link

commented Mar 4, 2014

For some reason, the error does not log any traceback in ~/.config/rabbitvcs/RabbitVCS.log, even with log level set to "Debug":

section of ~/.config/rabbitvcs/settings.conf:
[logging]
type = File
level = Debug

I called RabbitVCS via the CLI with

/usr/bin/rabbitvcs clone --vcs=git https://my-server-ip:444/git/project

However, forcing an obvious error by asking RabbitVCS to do a SVN checkout on the very same URL (which is a git URL), does produce the expected error and a traceback in RabbitVCS.log:

/usr/bin/rabbitvcs checkout --vcs=svn https://my-server-ip:444/git/project

2014-03-04 14:17:53,063 ERROR rabbitvcs.util.init
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/rabbitvcs/util/init.py", line 119, in start
func.start()
[...]
ClientError: Unable to connect to a repository at URL 'https://my-server-ip:444/git/project'
...and so on.

If you have any other ideas on getting more information on the error, i'm glad to help.

@CloCkWeRX

This comment has been minimized.

Copy link
Member

commented Mar 4, 2014

So, perhaps the best way forward is to checkout rabbitvcs from git and stick in a few prints/debugging statements.

Installing from git is easy:

git clone https://github.com/rabbitvcs/rabbitvcs.git ~/rabbitvcs
cd rabbitvcs
sudo python setup.py install

In gittup/client.py you can see

    def clone(self, host, path, bare=False, origin="origin"):
        self.numberOfCommandStages = 3

        more = ["-o", "origin","--progress"]
        if bare:
            more.append("--bare")

        base_dir = os.path.split(path)[0]

        cmd = ["git", "clone", host, path] + more

        try:
            (status, stdout, stderr) = GittyupCommand(cmd, cwd=base_dir, notify=self.notify_and_parse_progress, cancel=self.get_cancel).execute()
        except GittyupCommandError, e:
            self.callback_notify(e)

If you work out the exact command it generates and can execute that manually with success; it'll be some kind of thing to do with GittyupCommand

    def execute(self):
        env = os.environ.copy()
        env["LANG"] = "C";
        proc = subprocess.Popen(self.command,
                                cwd=self.cwd,
                                stdin=None,
                                stderr=subprocess.STDOUT,
                                stdout=subprocess.PIPE,
                                env=env,
                                close_fds=True,
                                preexec_fn=os.setsid,
                                universal_newlines=True)

If it fails, perhaps we can parse the strings it emits and pop up a password prompt

@cwenger

This comment has been minimized.

Copy link
Author

commented Mar 4, 2014

I got rabbitvcs installed from git, but can you clarify, where is
gittup/client.py located? I can't find it anywhere on my system.

On Tue, Mar 4, 2014 at 5:35 AM, CloCkWeRX notifications@github.com wrote:

So, perhaps the best way forward is to checkout rabbitvcs from git and
stick in a few prints/debugging statements.

Installing from git is easy:

git clone https://github.com/rabbitvcs/rabbitvcs.git ~/rabbitvcs
cd rabbitvcs
sudo python setup.py install

In gittup/client.py you can see

def clone(self, host, path, bare=False, origin="origin"):
    self.numberOfCommandStages = 3

    more = ["-o", "origin","--progress"]
    if bare:
        more.append("--bare")

    base_dir = os.path.split(path)[0]

    cmd = ["git", "clone", host, path] + more

    try:
        (status, stdout, stderr) = GittyupCommand(cmd, cwd=base_dir, notify=self.notify_and_parse_progress, cancel=self.get_cancel).execute()
    except GittyupCommandError, e:
        self.callback_notify(e)

If you work out the exact command it generates and can execute that
manually with success; it'll be some kind of thing to do with
GittyupCommand

def execute(self):
    env = os.environ.copy()
    env["LANG"] = "C";
    proc = subprocess.Popen(self.command,
                            cwd=self.cwd,
                            stdin=None,
                            stderr=subprocess.STDOUT,
                            stdout=subprocess.PIPE,
                            env=env,
                            close_fds=True,
                            preexec_fn=os.setsid,
                            universal_newlines=True)

If it fails, perhaps we can parse the strings it emits and pop up a
password prompt

Reply to this email directly or view it on GitHubhttps://github.com//issues/5#issuecomment-36623847
.

@cwenger

This comment has been minimized.

Copy link
Author

commented Mar 4, 2014

I can't seem to get rabbitvcs working from the git repo. Perhaps somebody
who already has this configured could reproduce the issue? Any git
repository that requires authentication should work. For example, try to
clone https://github.com/dphansti/Sushi.git.

On Tue, Mar 4, 2014 at 10:15 AM, CloCkWeRX notifications@github.com wrote:

https://github.com/rabbitvcs/rabbitvcs/blob/master/rabbitvcs/vcs/git/gittyup/client.py

Reply to this email directly or view it on GitHubhttps://github.com//issues/5#issuecomment-36655573
.

@CloCkWeRX

This comment has been minimized.

Copy link
Member

commented Mar 5, 2014

Alright, so broadly it's to do with

    def execute(self):
        env = os.environ.copy()
        env["LANG"] = "C";
        proc = subprocess.Popen(self.command,
                                cwd=self.cwd,
                                stdin=None,
                                stderr=subprocess.STDOUT,
                                stdout=subprocess.PIPE,
                                env=env,
                                close_fds=True,
                                preexec_fn=os.setsid,
                                universal_newlines=True)

        stdout = []

        while True:
            line = proc.stdout.readline()

            if line == '':
                break
            line = line.rstrip('\n') # Strip trailing newline.
            self.notify(line)
            stdout.append(line)

            if self.get_cancel():
                proc.kill()

        return (0, stdout, None)

I don't quite have the time to work out what arguments to send to subprocess.Popen; so that it is easy to detect that we're waiting for stdin.

Doing

        try:
            (status, stdout, stderr) = GittyupCommand(cmd, cwd=base_dir, notify=self.notify_and_parse_progress, cancel=self.get_cancel).execute()
            if stdout[1].find('fatal: could not read Username for') > -1:
                print "HEY WHATS YOUR PASSWORD"
        except GittyupCommandError, e:
            self.callback_notify(e)

Seems a bit clunky.

@Gwani

This comment has been minimized.

Copy link

commented Mar 5, 2014

Hello again. I also had a quick look at the code and my impression is that there is more work involved than just fixing a few lines to get this working right. Gittyup calls the git command line client directly, so i don't see how to extract reliable information about the underlying protocols such as "site asks for user/password" except for parsing the git's output like in your "clunky" suggestion.
But even if you do that, you might have to distinguish between several possible input requests: My server uses a self-signed SSL certificate, so the first "input request" from git was whether to accept the certificate (yes/no/permanently), and after that came the user/password prompts.
Further, Gittyup doesn't appear to provide the facilities to present the user with an input dialog for user/password/accepting certificates/etc., so that might have to be programmed as well - for the SVN parts of RabbitVCS these dialogs seem to be provided by pysvn (correct me if i'm wrong).
Unfortunately I also don't have the time nor the necessary Python expertise for this job, but i'll be happy to help testing if somebody finds the time to give it a try.

@cwenger

This comment has been minimized.

Copy link
Author

commented Mar 5, 2014

I'm 99% sure this worked correctly in old versions. I can't determine the
precise version easily, but probably the latest one as of about a year ago,

On Wed, Mar 5, 2014 at 5:42 AM, Gwani notifications@github.com wrote:

Hello again. I also had a quick look at the code and my impression is that
there is more work involved than just fixing a few lines to get this
working right. Gittyup calls the git command line client directly, so i
don't see how to extract reliable information about the underlying
protocols such as "site asks for user/password" except for parsing the
git's output like in your "clunky" suggestion.
But even if you do that, you might have to distinguish between several
possible input requests: My server uses a self-signed SSL certificate, so
the first "input request" from git was whether to accept the certificate
(yes/no/permanently), and after that came the user/password prompts.
Further, Gittyup doesn't appear to provide the facilities to present the
user with an input dialog for user/password/accepting certificates/etc., so
that might have to be programmed as well - for the SVN parts of RabbitVCS
these dialogs seem to be provided by pysvn (correct me if i'm wrong).
Unfortunately I also don't have the time nor the necessary Python
expertise for this job, but i'll be happy to help testing if somebody finds
the time to give it a try.

Reply to this email directly or view it on GitHubhttps://github.com//issues/5#issuecomment-36742752
.

@bas524

This comment has been minimized.

Copy link

commented Jun 25, 2014

rabbitvcs clone --vcs=git https://USERNAME:PASSWORD@URL.ORG

@primaryobjects

This comment has been minimized.

Copy link

commented Aug 22, 2014

I'm experiencing the same issue in Linux Mint. While bas524 is correct that editing the .config file and setting the username:password in the url works, this is a security concern as the password is saved in plain text.

I have a working solution for push and pull, based on CloCkWeRX's comment above. I've forked the code and updated the version to 0.16.1. In this version, you can leave the remote url either with a username or with none at all (https://user@github.com or https://github.com). You'll be prompted in a dialog for the username and password. This is implemented for Push and Pull, so far.

Screenshot
http://imgur.com/ZGTYpRZ

Fork
https://github.com/primaryobjects/rabbitvcs

@CloCkWeRX

This comment has been minimized.

Copy link
Member

commented Aug 23, 2014

Cursory review looks OK, want to turn it into a pull request?

@primaryobjects

This comment has been minimized.

Copy link

commented Aug 23, 2014

Sure, here's the pull request #46

I've added support for Clone as well. So now we have Push, Pull, and Clone prompting for username/password. In fact, I've been using it to push my changes for this fork!

@CloCkWeRX

This comment has been minimized.

Copy link
Member

commented Aug 23, 2014

Closed with #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.