After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 658539 - git bz doesn't see my cookie (it could ask for password in such case)
git bz doesn't see my cookie (it could ask for password in such case)
Status: RESOLVED WONTFIX
Product: git-bz
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: git-bz-maint
git-bz-maint
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2011-09-08 10:12 UTC by Matěj Cepl
Modified: 2018-07-10 22:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Choose between multiple Firefox profiles. (5.22 KB, patch)
2015-07-03 22:32 UTC, Matěj Cepl
none Details | Review
Choose between multiple Firefox profiles. (5.39 KB, patch)
2015-07-03 22:44 UTC, Matěj Cepl
none Details | Review
Choose between multiple Firefox profiles. (3.60 KB, patch)
2015-07-04 18:12 UTC, Matěj Cepl
none Details | Review
Choose between multiple Firefox profiles. (3.59 KB, patch)
2015-08-02 06:29 UTC, Matěj Cepl
none Details | Review

Description Matěj Cepl 2011-09-08 10:12:16 UTC
When running 

git bz file gedit/Plugins 5ead5f4

with Mozilla/5.0 (X11; Linux x86_64; rv:8.0a2) Gecko/20110907 Firefox/8.0a2
(that's upstream Aurora version)

I get this error:

Error getting login cookie from browser:
   You don't appear to be signed into bugzilla.gnome.org; please log in with Firefox

Configured browser: firefox3 (change with 'git config --global bz.browser <value>')
Possible browsers: chromium, epiphany, firefox3, galeon, google-chrome

That isn't correct: I AM logged into bugzilla.gnome.org.

These are my settings:

bradford:gedit (tw) $ git config -l|grep ^bz
bz-tracker.gnome.host=bugzilla.gnome.org
bz-tracker.gnome.auth-user=mcepl@redhat.com
bz-tracker.gnome.auth-password=something
bz-tracker.mozilla.host=bugzilla.mozilla.org
bz-tracker.mozilla.auth-user=mcepl@redhat.com
bz-tracker.mozilla.auth-password=something
bz-tracker.redhat.host=bugzilla.redhat.com
bz-tracker.redhat.auth-user=mcepl@redhat.com
bz-tracker.redhat.auth-password==something
bz.default-tracker=gnome
bz.default-product=gedit
bz.default-component=general
bradford:gedit (tw) $
Comment 1 Philip Withnall 2015-02-01 12:44:23 UTC
git-bz should ideally have support for requesting credentials from the user and (securely) storing them itself, for handling such situations or unsupported browsers.
Comment 2 Matěj Cepl 2015-07-03 22:32:48 UTC
Created attachment 306782 [details] [review]
Choose between multiple Firefox profiles.

Current script was choosing only automatically default profile for the cookiefile to be used. Unfortunately, when the user doesn't explicitly set default profile, Firefox sets as default the last profile used, which can make git-bz choosing the wrong profile.

This patch makes git-bz to make the choice explicit and ask in the dialog for the corrent profile.
Comment 3 Matěj Cepl 2015-07-03 22:44:35 UTC
Created attachment 306784 [details] [review]
Choose between multiple Firefox profiles.

Current script was choosing only automatically default profile for the
cookiefile to be used. Unfortunately, when the user doesn't explicitly
set default profile, Firefox sets as default the last profile used,
which can make git-bz choosing the wrong profile.

This patch makes git-bz to make the choice explicit and ask in the
dialog for the corrent profile.

In case there is only one profile, user is not bothered with anything
and git-bz is as automatic as before.
Comment 4 Philip Withnall 2015-07-04 09:45:23 UTC
Review of attachment 306784 [details] [review]:

::: git-bz
@@ +675,3 @@
+        default = 0
+        for p in profiles:
+            is_default = '*' if cp.has_option(p, 'Default') else ' '

Should you not also check that ‘cp.get(p, 'Default').strip() == '1'’?

If the default profile is set, why prompt the user? If the user has set their default profile incorrectly, I think it’s reasonable to require them to use `git config --global bz.ff3-cookie-file blah` manually.

@@ +677,3 @@
+            is_default = '*' if cp.has_option(p, 'Default') else ' '
+            if is_default == '*':
+                default = int(profiles.index(p))

You could use “for idx, p in enumerate(profiles):” instead of re-indexing into profiles.

@@ +698,3 @@
+def get_bugzilla_cookies_ff3(host):
+    if 'cookiefile' in git_config:
+        profile_path = git_config['cookiefile']

Perhaps this should be ff3-cookie-file instead of cookiefile?

@@ +707,3 @@
+        git_config['cookiefile'] = profile_path
+        Popen('git config bz.cookiefile %s' % profile_path,
+              shell=True).wait()

Why persist the default? This means that if the user changes their default Firefox profile from within Firefox, git-bz will not pick up the change.

I think it would be better to get the user to set their default profile in Firefox, or explicitly give them the git-config command which sets ff3-cookie-file after they have chosen a profile in determine_ff3_cookie_file().

@@ +773,3 @@
+            'galeon': get_bugzilla_cookies_galeon,
+            'chromium': get_bugzilla_cookies_chromium,
+            'google-chrome': get_bugzilla_cookies_google_chrome}

Irrelevant whitespace changes.

@@ +784,3 @@
     else:
+        die('Unsupported browser %s (we only support %s)' %
+            (browser, browser_list()))

Please remove all the irrelevant whitespace changes.
Comment 5 Matěj Cepl 2015-07-04 17:03:58 UTC
(In reply to Philip Withnall from comment #4)
> Review of attachment 306784 [details] [review] [review]:
> 
> ::: git-bz
> @@ +675,3 @@
> +        default = 0
> +        for p in profiles:
> +            is_default = '*' if cp.has_option(p, 'Default') else ' '
> 
> Should you not also check that ‘cp.get(p, 'Default').strip() == '1'’?

Probably, but I don't think Default if exists can have any other value.

> If the default profile is set, why prompt the user? If the user has set
> their default profile incorrectly, I think it’s reasonable to require them
> to use `git config --global bz.ff3-cookie-file blah` manually.

I explained it in the commit message. Default=1 doesn't mean only that the user explicitly marked the profile as default, but when the user (e.g., me ;)) doesn't declare any profile default, Firefox marks as default always the last profile used (so when restarted it is used again). Which means that Default profile can point somewhere else than to the most used profile.

Actually, it is even more complicated ... according to http://kb.mozillazine.org/Profiles.ini_file Default doesn't mean "default" in our sense of the word, but only the last profile used. Also we should acknowledge IsRelative option. And yes, Default doesn't have any other value than 1, it's just a flag.

> @@ +677,3 @@
> +            is_default = '*' if cp.has_option(p, 'Default') else ' '
> +            if is_default == '*':
> +                default = int(profiles.index(p))
> 
> You could use “for idx, p in enumerate(profiles):” instead of re-indexing
> into profiles.

Good point.

> @@ +698,3 @@
> +def get_bugzilla_cookies_ff3(host):
> +    if 'cookiefile' in git_config:
> +        profile_path = git_config['cookiefile']
> 
> Perhaps this should be ff3-cookie-file instead of cookiefile?

Perhaps. I haven't expected people using more than one browser, but probvably a good idea from the defensive programming point of view.

> @@ +707,3 @@
> +        git_config['cookiefile'] = profile_path
> +        Popen('git config bz.cookiefile %s' % profile_path,
> +              shell=True).wait()
> 
> Why persist the default? This means that if the user changes their default
> Firefox profile from within Firefox, git-bz will not pick up the change.

I tried to avoid bothering user too often especially with dialogs.

Perhaps I could print some notice that in such case user could just use 'git config --unset bz.cookiefile'.

> I think it would be better to get the user to set their default profile in
> Firefox, or explicitly give them the git-config command which sets
> ff3-cookie-file after they have chosen a profile in
> determine_ff3_cookie_file().

Of course, if bz.cookiefile (or bz.ff3-cookie-file) is set, then all this mechanism is ignored. However, it is completely undiscoverable.

> @@ +773,3 @@
> +            'galeon': get_bugzilla_cookies_galeon,
> +            'chromium': get_bugzilla_cookies_chromium,
> +            'google-chrome': get_bugzilla_cookies_google_chrome}
> 
> Irrelevant whitespace changes.

Sorry, flake8 complained. I'll stick just to my changes.
Comment 6 Matěj Cepl 2015-07-04 18:12:35 UTC
Created attachment 306814 [details] [review]
Choose between multiple Firefox profiles.

Current script was choosing only automatically default profile for the
cookiefile to be used. Unfortunately, when the user doesn't explicitly
set default profile, Firefox sets as default the last profile used,
which can make git-bz choosing the wrong profile.

This patch makes git-bz to make the choice explicit and ask in the
dialog for the corrent profile.
Comment 7 Marc-Andre Laperle 2015-08-01 19:16:36 UTC
I tried the patch but got this error:

Traceback (most recent call last):
  • File "/usr/local/bin/git-bz", line 2695 in <module>
    do_attach(*args)
  • File "/usr/local/bin/git-bz", line 2080 in do_attach
    bug = Bug.load(handle)
  • File "/usr/local/bin/git-bz", line 1541 in load
    server = get_bug_server(bug_reference.host, bug_reference.path, bug_reference.https, bug_reference.auth_user, bug_reference.auth_password)
  • File "/usr/local/bin/git-bz", line 1247 in get_bug_server
    servers[identifier] = BugServer(host, path, https, auth_user, auth_password)
  • File "/usr/local/bin/git-bz", line 1102 in __init__
    self.cookies = get_bugzilla_cookies(host)
  • File "/usr/local/bin/git-bz", line 845 in get_bugzilla_cookies
    return do_get_cookies(host)
  • File "/usr/local/bin/git-bz", line 700 in get_bugzilla_cookies_ff3
    profile_path = determine_ff3_cookie_file()
  • File "/usr/local/bin/git-bz", line 672 in determine_ff3_cookie_file
    cp.getint(profiles[0], 'Path'))
  • File "/usr/lib/python2.7/ConfigParser.py", line 359 in getint
    return self._get(section, int, option)
  • File "/usr/lib/python2.7/ConfigParser.py", line 356 in _get
    return conv(self.get(section, option))
ValueError: invalid literal for int() with base 10: '4xyq5vh6.default'

Comment 8 Matěj Cepl 2015-08-02 06:29:11 UTC
Created attachment 308629 [details] [review]
Choose between multiple Firefox profiles.

Current script was choosing only automatically default profile for the
cookiefile to be used. Unfortunately, when the user doesn't explicitly
set default profile, Firefox sets as default the last profile used,
which can make git-bz choosing the wrong profile.

This patch makes git-bz to make the choice explicit and ask in the
dialog for the corrent profile.
Comment 9 Marc-Andre Laperle 2015-08-03 02:59:06 UTC
Thanks, that worked!
Comment 10 André Klapper 2018-07-10 22:11:10 UTC
git-bz saw its last code changes three years ago: http://git.fishsoup.net/cgit/git-bz/
GNOME is moving from Bugzilla (the "bz" in "git-bz") to Gitlab.

Closing this report as WONTFIX as part of Bugzilla Housekeeping.

Please feel free to reopen this ticket (or rather transfer the project to GNOME Gitlab, as Bugzilla is deprecated) if active development is about to take place again.