Terminal app && ~purism/.profile

I’ve added a few line to the file ~purism/.profile because these are necessary for GnuPG and the OpenPGP card usage:

$ tail -4 ~purism/.profile

# for GnuPG
export GNUPGHOME=/home/purism/.gnupg
export GPG_TTY=$(tty)

and was a bit surprised that the terminal app does not know them, i.e. the .profile is not sourced. Is this by intention? Meanwhile y have added them to the ~purism/.bashrc and all is fine with GnuPG.

What is it that needs these lines? It can’t be an absolute necessity as I’ve been using the smart card on the phone since March without these lines and the smart card, OpenPGP and GnuPG have all been working fine for me.

I moved from Amber to Byzantium approximately 3 weeks ago and I’m also not seeing any issue using the smart card without these lines.

With regard sourcing .profile, I’m not sure any Debian based distros source .profile by default? Certainly my Debian boxes don’t and never have done as far as I recall.

I’ve seen it before, I think maybe in Mint? But I’ve also seen it absent. Some distros have it by default and some don’t.

Edit: I could be thinking of older Manjaro, but I don’t recall as they use zsh by default now.

Just read the man page of gpg-agent:

man gpg-agent
...
       You should always add the following lines to your .bashrc or whatever
       initialization file is used for all shell invocations:

         GPG_TTY=$(tty)
         export GPG_TTY

and related to .profile read the comments on top of the file ~/.profile.

As I wrote that, I was thinking I’m hardly the knowledge when it comes to the vast pool of Debian based distros, I bet there are quite a few that do source .profile, cue 50+ replies citing various different Debian based distros that source .profile.

Yeah, I have read the man page previously, while it does state that the tty lines should be added, it does not offer any explanation or detail as to why or what it does, in a system that already appears to be working fine why should it be added?

I’ve also read the default contents of .profile on previous Debian releases which is why I know that my Debian boxes don’t source the file by default.

Re/ GPG_TTY, I think the pinentry component needs this. Since I have set it in .profile and .bashrc it ask correctly when I use pass ... in the terminal with a Gnome popup, and when I do it a SSH session with a curses pinentry in the SSH session.

Re/ .profile, I know UNIX systems for 40++ years now and any login shell is sourcing .profile on any UNIX system, just test is with putting echo bla in that file and running xterm -ls on your preferred Linux flavor.

I have not had cause to use the smart card via SSH as yet, it’s all been on the phone directly so far, so your thinking may be correct that the GPG_TTY environment variable is used to throw up a suitable pinentry utility, I’ll put that to test if ever I need to use the card over an SSH session.

I just don’t care enough about the sourcing of .profile to spend any time running round various Linux flavors to see which do and do not source the file by default.

Well, to be fair, I saw .profile and read something completely different, so you can go ahead and disregard everything I’d said.

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
3 Likes

After exchanging a lot of opinions, can we please return to the core question: why the shell in the terminal app is not a login shell?

A login shell doesn’t require to ask for user name and password when you start it? maybe that’s the reason, can I ask why do you need a proper login shell? in theory when you log in to the desktop you are doing it to a login shell that launches the desktop, you can move between other ones by pressing Ctrl+Alt+F1-7, I just tested it in my Librem5.

Mind that I’m not an expert and I may be completely wrong.

I just tried changing my login shell to zsh and kgx obeyed it.