Re: [PATCH 03/13] introduce credentials API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> diff --git a/Documentation/technical/api-credentials.txt b/Documentation/technical/api-credentials.txt
> new file mode 100644
> index 0000000..3061077
> --- /dev/null
> +++ b/Documentation/technical/api-credentials.txt
> @@ -0,0 +1,148 @@
> + ...
> +`credential_fill`::
> +
> +	Attempt to fill the username and password fields of the passed
> +	credential struct, first consulting storage helpers, then asking
> +	the user. Guarantees that the username and password fields will
> +	be filled afterwards (or die() will be called).
> +
> +`credential_reject`::
> +
> +	Inform the credential subsystem that the provided credentials
> +	have been rejected. This will notify any storage helpers of the
> +	rejection (which allows them to, for example, purge the invalid
> +	credentials from storage), and then clear the username and
> +	password fields in `struct credential`. It can then be
> +	`credential_fill`-ed again.
> +
> +`credential_approve`::
> +
> +	Inform the credential subsystem that the provided credentials
> +	were successfully used for authentication. This will notify any
> +	storage helpers of the approval, so that they can store the
> +	result to be used again.

It's a bit hard to read and understand which part of the system calls
these and which other part of the system is responsible for implementing
them, and how "helper" fits into the picture (perhaps calling some of
these interfaces will result in "helper" getting called?).

> +Credential Storage Helpers
> +--------------------------
> +
> +Credential storage helpers are programs executed by git to fetch or save
> +credentials from and to long-term storage (where "long-term" is simply
> +longer than a single git process; e.g., credentials may be stored
> +in-memory for a few minutes, or indefinitely on disk).
> +
> +Helper scripts should generally be found in the PATH, and have names of
> +the form "git-credential-$HELPER".

Is this normal PATH or can a helper be moved away into $GIT_EXEC_PATH?

I briefly wondered if they want to be git-credential--$HELPER; I do not
deeply care either way, though.

> When the helper string "$HELPER" is
> +passed to credential functions, they will run "git-credential-$HELPER"
> +via the shell. If the first word of $HELPER contains non-alphanumeric
> +characters, then $HELPER is executed as a shell command. This makes it
> +possible to specify individual scripts by their full path (e.g.,
> +`/path/to/helper`) or even shell snippets (`f() { do_whatever; }; f`).

The definition of "the first word" above is not specified but it seems to
be "space separated". In other words, 'f() { do_whatever; }; f' would be
OK but 'f () { do_whatever; }; f' would not be. Am I reading and guessing
your intention correctly?

Funnily enough, 'f<TAB>() { do_whatever; }; f' would qualify as the first
word having a non alphanumeric.

> +The details of the credential will be provided on the helper's stdin
> +stream. The credential is split into a set of named attributes.
> +Attributes are provided to the helper, one per line. Each attribute is
> +specified by a key-value pair, separated by an `=` (equals) sign,
> +followed by a newline. The key may contain any bytes except `=` or
> +newline. The value may contain any bytes except a newline.  In both
> +cases, all bytes are treated as-is (i.e., there is no quoting, and one
> +cannot transmit a value with newline in it).

Can k or v contain a NUL? The literal reading of the above implies they
could, but I do not think you meant to.

> +int credential_read(struct credential *c, FILE *fp)
> +{
> ...
> +			c->host = xstrdup(value);
> +		}
> +		else if (!strcmp(key, "path")) {
> ...
> +		/* ignore other lines; we don't know what they mean, but
> +		 * this future-proofs us when later versions of git do
> +		 * learn new lines, and the helpers are updated to match */

Two style nits.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]