aboutsummaryrefslogtreecommitdiff
Use $SHELL instead of hardcoding /bin/sh in ratpoison.

Patch by Mark H Weaver <mhw@netris.org>.

--- ratpoison/src/actions.c.orig	2014-09-14 16:46:08.000000000 +0200
+++ ratpoison/src/actions.c	2015-08-06 15:00:54.951575260 +0200
@@ -228,12 +228,12 @@
   add_command ("escape",        cmd_escape,     1, 1, 1,
                "Key: ", arg_KEY);
   add_command ("exec",          cmd_exec,       1, 1, 1,
-               "/bin/sh -c ", arg_SHELLCMD);
+               "$SHELL -c ", arg_SHELLCMD);
   add_command ("execa",		cmd_execa,	1, 1, 1, 
-	       "/bin/sh -c ", arg_SHELLCMD);
+	       "$SHELL -c ", arg_SHELLCMD);
   add_command ("execf",		cmd_execf,	2, 2, 2, 
 	       "frame to execute in:", arg_FRAME,
-	       "/bin/sh -c ", arg_SHELLCMD);
+	       "$SHELL -c ", arg_SHELLCMD);
   add_command ("fdump",         cmd_fdump,      1, 0, 0,
                "", arg_NUMBER);
   add_command ("focus",         cmd_next_frame, 0, 0, 0);
@@ -367,7 +367,7 @@
   add_command ("unsetenv",      cmd_unsetenv,   1, 1, 1,
                "Variable: ", arg_STRING);
   add_command ("verbexec",      cmd_verbexec,   1, 1, 1,
-               "/bin/sh -c ", arg_SHELLCMD);
+               "$SHELL -c ", arg_SHELLCMD);
   add_command ("version",       cmd_version,    0, 0, 0);
   add_command ("vsplit",        cmd_v_split,    1, 0, 0,
                "Split: ", arg_STRING);
@@ -2671,6 +2671,9 @@
   pid = fork();
   if (pid == 0)
     {
+      char *shell_path;
+      char *shell_name;
+
       /* Some process setup to make sure the spawned process runs
          in its own session. */
       putenv(current_screen()->display_string);
@@ -2700,7 +2703,18 @@
       /* raw means don't run it through sh.  */
       if (raw)
         execl (cmd, cmd, (char *)NULL);
-      execl("/bin/sh", "sh", "-c", cmd, (char *)NULL);
+
+      shell_path = getenv ("SHELL");
+      if (shell_path == NULL)
+        shell_path = "/bin/sh";
+
+      shell_name = strrchr (shell_path, '/');
+      if (shell_name == NULL)
+        shell_name = shell_path;
+      else
+        shell_name++;
+
+      execl(shell_path, shell_name, "-c", cmd, (char *)NULL);
       _exit(EXIT_FAILURE);
     }
 
--- ratpoison/src/events.c.orig	2014-09-14 16:46:23.000000000 +0200
+++ ratpoison/src/events.c	2015-08-06 15:02:17.287578780 +0200
@@ -919,7 +919,7 @@
             {
               /* Report any child that didn't return 0. */
               if (cur->status != 0)
-                marked_message_printf (0,0, "/bin/sh -c \"%s\" finished (%d)",
+                marked_message_printf (0,0, "$SHELL -c \"%s\" finished (%d)",
                                        cur->cmd, cur->status);
               list_del  (&cur->node);
               free (cur->cmd);
--- ratpoison/src/messages.h.orig	2014-04-09 01:22:08.000000000 +0200
+++ ratpoison/src/messages.h	2015-08-06 15:04:14.759583801 +0200
@@ -39,7 +39,7 @@
 
 #define MESSAGE_PROMPT_SWITCH_TO_WINDOW "Switch to window: "
 #define MESSAGE_PROMPT_NEW_WINDOW_NAME  "Set window's title to: "
-#define MESSAGE_PROMPT_SHELL_COMMAND    "/bin/sh -c "
+#define MESSAGE_PROMPT_SHELL_COMMAND    "$SHELL -c "
 #define MESSAGE_PROMPT_COMMAND          ":"
 #define MESSAGE_PROMPT_SWITCH_WM        "Switch to wm: "
 #define MESSAGE_PROMPT_XTERM_COMMAND    MESSAGE_PROMPT_SHELL_COMMAND TERM_PROG " -e "
subject'>substitute: Cache and reuse connections while substituting.Ludovic Courtès That way, when fetching a series of substitutes from the same server(s), the connection is reused instead of being closed/opened for each substitutes, which saves on network round trips and TLS handshakes. * guix/http-client.scm (http-fetch): Add #:keep-alive? and honor it. * guix/progress.scm (progress-report-port): Add #:close? parameter and honor it. * guix/scripts/substitute.scm (at-most): Return the tail as a second value. (fetch): Add #:port and #:keep-alive? and honor them. (%max-cached-connections): New variable. (open-connection-for-uri/cached, call-with-cached-connection): New procedures. (with-cached-connection): New macro. (process-substitution): Wrap 'fetch' call in 'with-cached-connection'. Pass #:close? to 'progress-report-port'. 2020-12-08daemon: Run 'guix substitute --substitute' as an agent.Ludovic Courtès This avoids spawning one substitute process per substitution. * nix/libstore/build.cc (class Worker)[substituter]: New field. [outPipe, logPipe, pid]: Remove. (class SubstitutionGoal)[expectedHashStr, status, substituter]: New fields. (SubstitutionGoal::timedOut): Adjust to check 'substituter'. (SubstitutionGoal::tryToRun): Remove references to 'outPipe' and 'logPipe'. Run "guix substitute --substitute" as an 'Agent'. Send the request with 'writeLine'. (SubstitutionGoal::finished): Likewise. (SubstitutionGoal::handleChildOutput): Change to fill in 'expectedHashStr' and 'status'. (SubstitutionGoal::handleEOF): Call 'wakeUp' unconditionally. (SubstitutionGoal::~SubstitutionGoal): Adjust to check 'substituter'. * guix/scripts/substitute.scm (process-substitution): Write "success\n" to stdout upon success. (%error-to-file-descriptor-4?): New variable. (guix-substitute): Set 'current-error-port' to file descriptor 4 unless (%error-to-file-descriptor-4?) is false. Remove "--substitute" arguments. Loop reading line from stdin. * tests/substitute.scm <top level>: Call '%error-to-file-descriptor-4?'. (request-substitution): New procedure. ("substitute, no signature") ("substitute, invalid hash") ("substitute, unauthorized key") ("substitute, authorized key") ("substitute, unauthorized narinfo comes first") ("substitute, unsigned narinfo comes first") ("substitute, first narinfo is unsigned and has wrong hash") ("substitute, first narinfo is unsigned and has wrong refs") ("substitute, two invalid narinfos") ("substitute, narinfo with several URLs"): Adjust to new "guix substitute --substitute" calling convention. 2020-12-08daemon: Factorize substituter agent spawning.Ludovic Courtès * nix/libstore/local-store.hh (class LocalStore)[substituter]: New method. [runningSubstituter]: Turn into a shared_ptr. * nix/libstore/local-store.cc (LocalStore::querySubstitutablePaths): Call 'substituter' instead of using inline code. (LocalStore::querySubstitutablePathInfos): Likewise. (LocalStore::substituter): New method. 2020-12-08daemon: Use 'Agent' to spawn 'guix substitute --query'.Ludovic Courtès * nix/libstore/local-store.hh (RunningSubstituter): Remove. (LocalStore)[runningSubstituter]: Change to unique_ptr<Agent>. [setSubstituterEnv, didSetSubstituterEnv]: Remove. [getLineFromSubstituter, getIntLineFromSubstituter]: Take an 'Agent'. * nix/libstore/local-store.cc (LocalStore::~LocalStore): Remove reference to 'runningSubstituter'. (LocalStore::setSubstituterEnv, LocalStore::startSubstituter): Remove. (LocalStore::getLineFromSubstituter): Adjust to 'run' being an 'Agent'. (LocalStore::querySubstitutablePaths): Spawn substituter agent if needed. Adjust to 'Agent' interface. (LocalStore::querySubstitutablePathInfos): Likewise. * nix/libstore/build.cc (SubstitutionGoal::tryToRun): Remove call to 'setSubstituterEnv' and add 'setenv' call for "_NIX_OPTIONS" instead. (SubstitutionGoal::finished): Remove 'readLine' call for 'dummy'. * guix/scripts/substitute.scm (%allow-unauthenticated-substitutes?): Remove second argument to 'make-parameter'. (process-query): Call 'warn-about-missing-authentication' when (%allow-unauthenticated-substitutes?) is #t. (guix-substitute): Wrap body in 'parameterize'. Set 'guix-warning-port' too. No longer exit when 'substitute-urls' returns the empty list. No longer print newline initially. * tests/substitute.scm (test-quit): Parameterize 'current-error-port' to account for the port changes in 'guix-substitute'. 2020-12-08daemon: 'Agent' constructor takes a list of environment variables.Ludovic Courtès * nix/libutil/util.hh (struct Agent)[Agent]: Add 'env' parameter. * nix/libutil/util.cc (Agent::Agent): Honor it. 2020-12-01daemon: Remove unneeded forward declaration.Ludovic Courtès This is a followup to ee9dff34f9317509cb2b833d07a0d5e01a36a4ae. * nix/libstore/build.cc: Remove 'struct Agent' forward declaration. 2020-11-29daemon: Remove pre-Guix hack.Ludovic Courtès * nix/libstore/build.cc (DerivationGoal::startBuilder): Remove "NIX_OUTPUT_CHECKED" hack. 2020-11-29Use substitute servers on the local network.Mathieu Othacehe * guix/scripts/discover.scm: New file. * Makefile.am (MODULES): Add it. * nix/nix-daemon/guix-daemon.cc (options): Add "discover" option, (parse-opt): parse it, (main): start "guix discover" process when the option is set. * guix/scripts/substitute.scm (%local-substitute-urls): New variable, (substitute-urls): add it. * gnu/services/base.scm (<guix-configuration>): Add "discover?" field, (guix-shepherd-service): honor it. * doc/guix.texi (Invoking guix-daemon): Document "discover" option, (Base Services): ditto. 2020-10-27maint: Add 'etc/gnu-store.mount.in' to the distribution.Ludovic Courtès Reported by Vagrant Cascadian. * nix/local.mk (EXTRA_DIST): Add 'etc/gnu-store.mount.in'. 2020-10-09nix: Honor '--rounds' when also using '--check'.Maxim Cournoyer Fixes <https://issues.guix.gnu.org/40144>. Until now, the '--rounds' option, when also using '--check', was ignored. This change makes it possible to use both, so that an item that has already been built once can be rebuilt as many times as desired. * nix/libstore/build.cc: Remove the conditionals causing the daemon to complete a build task early when 'buildMode' is equal to 'nix::bmCheck'. Reported-by: Brice Waegeneire <brice@waegenei.re> 2020-10-01daemon: Try to execute derivation builders only for matching OS kernels.Ludovic Courtès Fixes <https://bugs.gnu.org/43668>. Previously, guix-daemon would try to run GNU/Hurd executables on GNU/Linux. execve(2) would succeed, but the executable would immediately crash. This change prevents it from attempting to execute "i586-gnu" code on "*-linux", while preserving the binfmt_misc-friendly behavior implemented in commit 7bf2a70a4ffd976d50638d3b9f2ec409763157df. * nix/libstore/build.cc (sameOperatingSystemKernel): New function. (DerivationGoal::runChild): Call 'execve' only when 'sameOperatingSystemKernel' returns true. 2020-09-17guix-install.sh: Support OpenRC.Morgan Smith * etc/guix-install.sh (chk_init_sys): Detect OpenRC. (sys_enable_guix_daemon): Install & enable the Guix daemon on such systems. * etc/openrc/guix-daemon.in: New file. * nix/local.mk: Add a rule for it. (openrcservicedir, nodist_openrcservice_DATA): New variables. (CLEANFILES, EXTRA_DIST): Add them. * .gitignore: Ignore etc/openrc/guix-daemon. Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr> 2020-09-14daemon: Spawn 'guix authenticate' once for all.Ludovic Courtès Previously, we'd spawn 'guix authenticate' once for each item that has to be signed (when exporting) or authenticated (when importing). Now, we spawn it once for all and then follow a request/reply protocol. This reduces the wall-clock time of: guix archive --export -r $(guix build coreutils -d) from 30s to 2s. * guix/scripts/authenticate.scm (sign-with-key): Return the signature instead of displaying it. Raise a &formatted-message instead of calling 'leave'. (validate-signature): Likewise. (read-command): New procedure. (define-enumerate-type, reply-code): New macros. (guix-authenticate)[send-reply]: New procedure. Change to read commands from current-input-port. * nix/libstore/local-store.cc (runAuthenticationProgram): Remove. (authenticationAgent, readInteger, readAuthenticateReply): New functions. (signHash, verifySignature): Rewrite in terms of the agent. * tests/store.scm ("import not signed"): Remove 'pk' call. ("import signed by unauthorized key"): Check the error message of C. * tests/guix-authenticate.sh: Rewrite using the new protocol. fixlet 2020-09-14daemon: Move 'Agent' to libutil.Ludovic Courtès * nix/libstore/build.cc (DerivationGoal::tryBuildHook): Add "offload" to 'args' and pass settings.guixProgram as the first argument to Agent::Agent. (pathNullDevice, commonChildInit, Agent, Agent::Agent) (Agent::~Agent): Move to... * nix/libutil/util.cc: ... here. * nix/libutil/util.hh (struct Agent, commonChildInit): New declarations. 2020-09-14daemon: Isolate signing and signature verification functions.Ludovic Courtès * nix/libstore/local-store.cc (signHash, verifySignature): New functions. (LocalStore::exportPath): Use 'signHash' instead of inline code. (LocalStore::importPath): Use 'verifySignature' instead of inline code. 2020-09-14daemon: Generalize 'HookInstance' to 'Agent'.Ludovic Courtès * nix/libstore/build.cc (HookInstance): Rename to... (Agent): ... this. Rename 'toHook' and 'fromHook' similarly and update users. Change constructor to require a command and an argument list. (DerivationGoal::tryBuildHook): Pass arguments to the 'Agent' constructor. 2020-09-11daemon: Simplify interface with 'guix authenticate'.Ludovic Courtès There's no reason at this point to mimic the calling convention of the 'openssl' command. * nix/libstore/local-store.cc (LocalStore::exportPath): Add only "sign" and HASH to ARGS. Remove 'tmpDir' and 'hashFile'. (LocalStore::importPath): Add only "verify" and SIGNATURE to * guix/scripts/authenticate.scm (guix-authenticate): Adjust accordingly; remove the OpenSSL-style clauses. (read-hash-data): Remove. (sign-with-key): Replace 'port' with 'sha256' and adjust accordingly. (validate-signature): Export SIGNATURE to be a canonical sexp. * tests/guix-authenticate.sh: Adjust tests accordingly.