git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Mar 10, 2013, 10:49 UTC
Message-ID
<CALkWK0kK3YCwkv26cxVf61yUd8WHmHDG+mFwb2VRwNF3k_40qA@mail.gmail.com>
In-Reply-To
<20130309220011.GC24777@elie.Belkin>
Jonathan Nieder wrote:
Show 8 quoted lines
>  * 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.

Show 19 quoted lines
> 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.
Previous: Jonathan NiederNext: Jonathan Nieder
Message 57 of 59 in “Git prompt”
  1. Ethan ReesorFeb 10, 2013
  2. Jonathan NiederFeb 10, 2013
  3. Ethan ReesorFeb 10, 2013
  4. Jeff KingFeb 10, 2013
  5. Junio C HamanoFeb 10, 2013
  6. Sitaram ChamartyFeb 11, 2013
  7. shell: allow 'help' command to disable interactive shellJonathan Nieder, Feb 11, 2013
  8. Junio C HamanoFeb 11, 2013
  9. Jonathan NiederFeb 11, 2013
  10. Junio C HamanoFeb 11, 2013
  11. Jonathan NiederFeb 11, 2013
  12. Jeff KingFeb 11, 2013
  13. Junio C HamanoFeb 11, 2013
  14. Ethan ReesorFeb 11, 2013
  15. Ethan ReesorFeb 11, 2013
  16. Jonathan NiederFeb 11, 2013
  17. Ethan ReesorFeb 11, 2013
  18. Jonathan NiederFeb 11, 2013
  19. Ethan ReesorFeb 11, 2013
  20. Jonathan NiederFeb 11, 2013
  21. Junio C HamanoFeb 11, 2013
  22. Jonathan NiederFeb 11, 2013
  23. Junio C HamanoFeb 11, 2013
  24. Jonathan NiederFeb 11, 2013
  25. Junio C HamanoFeb 11, 2013
  26. Jonathan NiederFeb 11, 2013
  27. Junio C HamanoFeb 11, 2013
  28. Jeff KingFeb 11, 2013
  29. Junio C HamanoFeb 11, 2013
  30. Jeff KingFeb 11, 2013
  31. Ethan ReesorFeb 11, 2013
  32. Ethan ReesorFeb 11, 2013
  33. Junio C HamanoFeb 11, 2013
  34. Ethan ReesorFeb 11, 2013
  35. Junio C HamanoFeb 11, 2013
  36. Jeff KingFeb 11, 2013
  37. Jonathan NiederFeb 11, 2013
  38. Jeff KingFeb 11, 2013
  39. Jonathan NiederFeb 11, 2013
  40. Jeff KingFeb 11, 2013
  41. 0/2 shell: allow 'help' command to disable interactive shellJonathan Nieder, Feb 11, 2013
  42. 1/2 shell doc: emphasize purpose and security modelJonathan Nieder, Feb 11, 2013
  43. Junio C HamanoFeb 11, 2013
  44. Jonathan NiederFeb 11, 2013
  45. Junio C HamanoFeb 11, 2013
  46. 2/2 shell: pay attention to exit status from 'help' commandJonathan Nieder, Feb 11, 2013
  47. Ethan ReesorFeb 11, 2013
  48. Junio C HamanoFeb 11, 2013
  49. Jonathan NiederFeb 11, 2013
  50. Junio C HamanoFeb 11, 2013
  51. Jeff KingFeb 11, 2013
  52. 0/2 shell: allow 'no-interactive-login' command to disable interactive shellJonathan Nieder, Mar 9, 2013
  53. 1/2 shell doc: emphasize purpose and security modelJonathan Nieder, Mar 9, 2013
  54. 2/2 shell: new no-interactive-login command to print a custom messageJonathan Nieder, Mar 9, 2013
  55. Junio C HamanoMar 10, 2013
  56. Jonathan NiederMar 10, 2013
  57. Ramkumar RamachandraMar 10, 2013
  58. Jonathan NiederMar 11, 2013
  59. Jeff KingMar 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.