Classic confinement for git-todos

Note that ~/.gitconfig can contain sensitive information and while I’m not saying that an interface can’t be created for it (or more probably, the home interface adjusted in some manner), we should think through this. Suppose ~/.gitconfig is exposed via an interface. Because .gitconfig can contain sensitive information, we would make the interface manually connected. Anything using git (like git-todos) would almost certainly request an auto-connection of the interface so all these git-using snaps would have access to the sensitive information. While I could see a git command snap needing to use this interface, it seems like snaps like git-todos that happen to use git to store things would want snap-specific git configuration.

In that light, can git-todos (and other similar snaps) simply use $HOME/.gitconfig (which evaluates to ~/snap/git-todos/SNAP_REVISION/.gitconfig)? The snap could do something like:

if [ ! -e "$HOME/.gitconfig" ]; then # $HOME is $SNAP_USER_DATA here
    echo "Creating default git configuration in $HOME/.gitconfig"
    touch "$HOME/.gitconfig" # could also ask some questions to populate .gitconfig
    REAL_HOME=$(getent passwd $USER|cut -d ':' -f 6)
    if [ -e "$REAL_HOME/.gitconfig ]; then
       echo "Detected '$REAL_HOME/.gitconfig'. You may want to ..."
       ...
    fi
fi

In this manner, your snap has just the git configuration it needs and other snaps have just the git configuration they need, while the global configuration is intact. Alternately, pass --local to git config (man git-config) and in your project directory and it will use .git/config.

1 Like