Re: [PATCH 2/2] shell: new no-interactive-login command to print a custom message

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

 



Jonathan Nieder wrote:
>  * If the file ~/git-shell-commands/no-interactive-login exists,
>    run no-interactive-login to let the server say what it likes,
>    then hang up.
>
>  * Otherwise, if ~/git-shell-commands/ is present, start an
>    interactive read-eval-print loop.
>
>  * Otherwise, print the usual configuration hint and hang up.

Excellent.  A way to suppress the ugly warning, and replace it with a
nice message in a non-interactive shell.  You've chosen
"no-interactive-login" as the name of this special file, which is
reasonable.  I'm not too fond of the name "git-shell-commands" in the
first place, but I suspect it's too late to do anything about it now.

> diff --git a/shell.c b/shell.c
> index 84b237fe..1429870a 100644
> --- a/shell.c
> +++ b/shell.c
> @@ -6,6 +6,7 @@
>
>  #define COMMAND_DIR "git-shell-commands"
>  #define HELP_COMMAND COMMAND_DIR "/help"
> +#define NOLOGIN_COMMAND COMMAND_DIR "/no-interactive-login"
>
>  static int do_generic_cmd(const char *me, char *arg)
>  {
> @@ -65,6 +66,18 @@ static void run_shell(void)
>  {
>         int done = 0;
>         static const char *help_argv[] = { HELP_COMMAND, NULL };
> +
> +       if (!access(NOLOGIN_COMMAND, F_OK)) {
> +               /* Interactive login disabled. */

You're just checking for its existence here, not for execute permissions.

> +               const char *argv[] = { NOLOGIN_COMMAND, NULL };
> +               int status;
> +
> +               status = run_command_v_opt(argv, 0);

If "no-interactive-login" doesn't have execute permissions, we'll get
an error from here:

    fatal: cannot exec 'git-shell-commands/no-interactive-login':
Permission denied

Would you like to check that the file has execute permission in
advance to prevent some extra processing (in run_command_v_opt,
start_command and friends) before this message is printed?

Looks good otherwise.
--
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]