Skip to content

When using -noqr and logging the output the URL fragment is printed #49

Open

Description

@lars18th

This is based on the last comment in #34

The fix fits the rule 0.5.2 just established. Off a terminal the startup block
already prints less, because nobody is looking; the URL should lose its
fragment on the same test. On a terminal it stays whole, because that is where
you are reading it in order to use it.

At time, the LOG includes the # URL fragment. And this could be considered a bug. Only the initial part of the URL needs to be logged for security reasons.

What I want to think about for a minute is how you first obtain the URL on a
headless box once the log no longer carries it -- there is a bitbang link
family for the access-link table, and the answer is probably there rather than
in a new flag.

Inside OpenWRT, and until you fix the #41 with -state-dir, the "config" is stored in /.bitbang when executed as daemon with a script in /etc/init.d/.

So, you're right that when the first time the daemon is executed... where is the config? In my case, I'm copied it from a previous manual execution in a terminal. So I have the full URL access. Anyway, at the end of the bitbang/identity.pem file it's the ACCESS CODE. Therefore, reading the LOG and the PEM file you got the two parts. Perhaps you can add a simple privileged command to get the full URL manually. 🤔

Activity

  1. richlegrand commented on Oct 21, 2026

    @richlegrand
    Owner

    Thanks for opening it, and for carrying the quotes across.

    Agreed on both halves. Off a terminal the URL loses its fragment; on a
    terminal it stays whole. Only the part before the # has any business in a
    journal.

    You do not need the PEM file for the other half, and you do not need a new
    command either. bitbang link qr owner prints the full URL, fragment
    included, as its last line:

    bitbang link qr owner | tail -1
    

    owner is the label for the identity's own code, so it works with no
    access links configured at all -- it only needs the identity to exist. I
    said in #34 that the answer was probably in the link family rather than
    in a new flag, and it is. I should have checked and handed you the command
    instead of leaving you to dig the code out of identity.pem.

    One catch on your setup, and it is the defect you had already spotted
    without naming it. /.bitbang is not a deliberate location: identityDir
    falls back to home = "." when os.UserHomeDir() fails, and an init
    script runs with no HOME and a working directory of /. So run that
    command from a root shell and it looks in /root/.bitbang instead, which
    is empty. Point it at the directory the daemon actually used:

    HOME=/ bitbang link qr owner | tail -1
    

    So the headless answer exists, but it is only trustworthy once #41 is
    fixed. That moves #41 up rather than making this wait on it -- the fragment
    can come out of the log on its own.

  2. lars18th commented on Oct 22, 2026

    @lars18th
    Author

    Hi @richlegrand ,

    Thank you for the tip HOME=/ bitbang-cli link qr owner. I recommend documenting this when #41 is fixed, indicating that HOME needs to point to the config directory. Therefore, perhaps it will have sense to print out this directory in the LOG. Don't you think so?

  3. added a commit that references this issue on Nov 9, 2026
  4. richlegrand commented on Nov 9, 2026

    @richlegrand
    Owner

    Reopening this. The fix went in and came straight back out, and the issue
    auto-closed on the merge that landed it.

    What happened: off a terminal the URL lost its fragment, which is what I said
    in #34 and what you asked for here. It also broke every script that reads the
    URL off stdout, because that line is how a program learns where to connect.
    Our own end-to-end suite runs the listener with its output on a pipe and greps
    URL: for the address; once the code was gone, nothing could connect.

    isTTY was the wrong test. It separates a terminal from everything else, when
    what this needs is a system log separated from a script -- and both of those
    are pipes. The defect you reported is real and still there. The first answer
    to it was not.

    The version worth building is in #54, and it is not the one I would have
    guessed. Rather than working out who is reading stdout, write the full URL to
    a file in the config directory, 0600, and let the log carry only the part a
    journal should hold. Permissions are a real boundary; detecting a terminal is
    not. There is already a pattern for it here -- bitbang share keeps its
    state, URLs and fragments included, in exactly that way.

    It buys something else you may care about on a headless box: written when the
    listener becomes ready, the file's existence is the readiness signal, so a
    script waits for a file instead of watching a log. And it means the log can
    simply always be sanitized, with no heuristic deciding whether this run counts
    as a daemon.

    It needs #41 first, though. The file belongs in the config directory, and on
    your box that is still wherever HOME is not pointing.

    On your question from October, and apologies for the wait: yes, the log should
    print the config directory, and it does not today. It is a path rather than a
    credential, so nothing argues against it, and it would have saved you working
    out that /.bitbang was a fallback rather than a choice. That belongs with
    #41, where the directory stops being wherever HOME happened to point.

    One thing you are already insulated from, but worth knowing: the QR encodes
    the same URL, and it is dropped only by -noqr. You run with that, so your
    journal has the text and not the picture -- but on a stock headless install
    the access code is going into the log as a scannable image too. Whatever rule
    the URL line ends up with, the QR gets the same one.

    Unrelated, and in your hands now: 0.5.3 is out with the Ctrl-C fix you
    confirmed. bitbang-linux-armv7 is on the release page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions