rset: 2.1 -> 3.2 (#385404)

This commit is contained in:
Peder Bergebakken Sundt
2025-03-02 17:36:42 +01:00
committed by GitHub
2 changed files with 90 additions and 87 deletions
+18 -21
View File
@@ -1,7 +1,7 @@
{
lib,
stdenv,
fetchurl,
fetchFromGitHub,
coreutils,
openssh,
gnutar,
@@ -9,29 +9,31 @@
stdenv.mkDerivation rec {
pname = "rset";
version = "2.1";
version = "3.2";
src = fetchurl {
url = "https://scriptedconfiguration.org/code/${pname}-${version}.tar.gz";
sha256 = "0916f96afl8kcn2hpj4qhg92g2j93ycp2sb94nsz3q44sqc6ddhb";
src = fetchFromGitHub {
owner = "eradman";
repo = "rset";
tag = version;
hash = "sha256-b797R79aMopiPApTJ4Q3SP2MRjqCcNNO9BIxtuiNZks=";
};
patches = [ ./paths.patch ];
postPatch = ''
substituteInPlace rset.c \
--replace @ssh@ ${openssh}/bin/ssh \
--replace @miniquark@ $out/bin/miniquark \
--replace @rinstall@ $out/bin/rinstall \
--replace @rsub@ $out/bin/rsub
--replace-fail @ssh@ ${openssh}/bin/ssh \
--replace-fail @miniquark@ $out/bin/miniquark \
--replace-fail @rinstall@ $out/bin/rinstall \
--replace-fail @rsub@ $out/bin/rsub
substituteInPlace execute.c \
--replace @ssh@ ${openssh}/bin/ssh \
--replace @ssh-add@ ${openssh}/bin/ssh-add \
--replace @tar@ ${gnutar}/bin/tar
--replace-fail @ssh@ ${openssh}/bin/ssh \
--replace-fail @ssh-add@ ${openssh}/bin/ssh-add \
--replace-fail @tar@ ${gnutar}/bin/tar
substituteInPlace rutils.c \
--replace @install@ ${coreutils}/bin/install
--replace-fail @install@ ${coreutils}/bin/install
'';
# these are to be run on the remote host,
@@ -44,17 +46,12 @@ stdenv.mkDerivation rec {
dontAddPrefix = true;
installFlags = [ "PREFIX=$(out)" ];
meta = with lib; {
meta = {
homepage = "https://scriptedconfiguration.org/";
description = "Configure systems using any scripting language";
changelog = "https://github.com/eradman/rset/raw/${version}/NEWS";
license = licenses.isc;
platforms = platforms.unix;
license = lib.licenses.isc;
platforms = lib.platforms.unix;
maintainers = [ ];
# 2023-08-19, fails to compile with glibc-2.38 because of strlcpy.
# At the time of writing, this was 4 minors behind already and
# the `paths.patch` didn't apply anymore, so this is now considered
# broken until somebody cares enough to fix and upgrade this.
broken = true;
};
}
+72 -66
View File
@@ -2,76 +2,82 @@ diff --git a/execute.c b/execute.c
index be06068..3468fa7 100644
--- a/execute.c
+++ b/execute.c
@@ -242,7 +242,7 @@ verify_ssh_agent() {
@@ -260,7 +260,7 @@
char *output;
char *argv[32];
- append(argv, 0, "ssh-add", "-l", NULL);
+ append(argv, 0, "@ssh-add@", "-l", NULL);
output = cmd_pipe_stdout(argv, &error_code, &output_size);
free(output);
@@ -282,7 +282,7 @@ start_connection(char *socket_path, Label *route_label, int http_port, const cha
@@ -300,7 +300,7 @@
}
argc = 0;
- argc = append(argv, argc, "ssh", "-fN", "-R", port_forwarding, "-S",
+ argc = append(argv, argc, "@ssh@", "-fN", "-R", port_forwarding, "-S",
socket_path, "-M", NULL);
- argc = append(argv, argc, "ssh", "-fN", "-R", port_forwarding, "-S", socket_path, "-M", NULL);
+ argc = append(argv, argc, "@ssh@", "-fN", "-R", port_forwarding, "-S", socket_path, "-M", NULL);
if (ssh_config)
(void) append(argv, argc, "-F", ssh_config, host_name, NULL);
@@ -292,12 +292,12 @@ start_connection(char *socket_path, Label *route_label, int http_port, const cha
return -1;
snprintf(tmp_path, sizeof(tmp_path), "mkdir " REMOTE_TMP_PATH, http_port);
- append(argv, 0, "ssh", "-S", socket_path, host_name, tmp_path, NULL);
+ append(argv, 0, "@ssh@", "-S", socket_path, host_name, tmp_path, NULL);
if (run(argv) != 0)
return -1;
- snprintf(cmd, PATH_MAX, "tar -cf - %s -C " REPLICATED_DIRECTORY " ./ | "
- "exec ssh -q -S %s %s tar -xf - -C " REMOTE_TMP_PATH,
+ snprintf(cmd, PATH_MAX, "@tar@ -cf - %s -C " REPLICATED_DIRECTORY " ./ | "
+ "exec @ssh@ -q -S %s %s tar -xf - -C " REMOTE_TMP_PATH,
array_to_str(route_label->export_paths), socket_path, host_name,
http_port);
if (system(cmd) != 0) {
@@ -326,7 +326,7 @@ ssh_command_pipe(char *host_name, char *socket_path, Label *host_label, int http
else
@@ -309,8 +309,8 @@
return ret;
snprintf(cmd, PATH_MAX,
- "tar " TAR_OPTIONS " -cf - -C " REPLICATED_DIRECTORY " . "
- "| ssh -q -S %s %s 'mkdir %s; tar -xf - -C %s'",
+ "@tar@ " TAR_OPTIONS " -cf - -C " REPLICATED_DIRECTORY " . "
+ "| @ssh@ -q -S %s %s 'mkdir %s; tar -xf - -C %s'",
socket_path, host_name, stagedir(http_port), stagedir(http_port));
if ((ret = system(cmd)) != 0)
return ret;
@@ -320,8 +320,8 @@
array_to_str(route_label->export_paths, path_repr, sizeof(path_repr), " ");
snprintf(cmd, PATH_MAX,
- "tar " TAR_OPTIONS " -cf - %s "
- "| ssh -q -S %s %s 'tar -xf - -C %s'",
+ "@tar@ " TAR_OPTIONS " -cf - %s "
+ "| @ssh@ -q -S %s %s 'tar -xf - -C %s'",
path_repr, socket_path, host_name, stagedir(http_port));
if ((ret = system(cmd)) != 0)
@@ -407,7 +407,7 @@
/* construct ssh command */
argc = 0;
- argc = append(argv, argc, "ssh", "-T", "-S", socket_path, NULL);
+ argc = append(argv, argc, "@ssh@", "-T", "-S", socket_path, NULL);
(void) append(argv, argc, host_name, cmd, NULL);
return cmd_pipe_stdin(argv, host_label->content, host_label->content_size);
@@ -344,7 +344,7 @@ ssh_command_tty(char *host_name, char *socket_path, Label *host_label, int http_
http_port);
ret = cmd_pipe_stdin(argv, host_label->content, host_label->content_size);
@@ -432,7 +432,7 @@
snprintf(cmd, sizeof(cmd), "cat > %s/_script", stagedir(http_port));
/* construct ssh command */
argc = 0;
- argc = append(argv, argc, "ssh", "-T", "-S", socket_path, NULL);
+ argc = append(argv, argc, "@ssh@", "-T", "-S", socket_path, NULL);
(void) append(argv, argc, host_name, cmd, NULL);
cmd_pipe_stdin(argv, host_label->content, host_label->content_size);
@@ -360,7 +360,7 @@ ssh_command_tty(char *host_name, char *socket_path, Label *host_label, int http_
@@ -450,7 +450,7 @@
/* construct ssh command */
argc = 0;
- argc = append(argv, argc, "ssh", "-t", "-S", socket_path, NULL);
+ argc = append(argv, argc, "@ssh@", "-t", "-S", socket_path, NULL);
(void) append(argv, argc, host_name, cmd, NULL);
return run(argv);
@@ -375,11 +375,11 @@ end_connection(char *socket_path, char *host_name, int http_port) {
ret = run(argv);
@@ -498,11 +498,11 @@
if (access(socket_path, F_OK) == -1)
return;
snprintf(tmp_path, sizeof(tmp_path), REMOTE_TMP_PATH, http_port);
- append(argv, 0, "ssh", "-S", socket_path, host_name, "rm", "-rf", tmp_path , NULL);
+ append(argv, 0, "@ssh@", "-S", socket_path, host_name, "rm", "-rf", tmp_path , NULL);
- append(argv, 0, "ssh", "-S", socket_path, host_name, "rm", "-rf", stagedir(http_port), NULL);
+ append(argv, 0, "@ssh@", "-S", socket_path, host_name, "rm", "-rf", stagedir(http_port), NULL);
if (run(argv) != 0)
warn("remote tmp dir");
- append(argv, 0, "ssh", "-q", "-S", socket_path, "-O", "exit", host_name, NULL);
+ append(argv, 0, "@ssh@", "-q", "-S", socket_path, "-O", "exit", host_name, NULL);
if (run(argv) != 0)
@@ -81,47 +87,47 @@ diff --git a/rset.c b/rset.c
index 383fc82..9c20f65 100644
--- a/rset.c
+++ b/rset.c
@@ -128,10 +128,8 @@ int main(int argc, char *argv[])
hostnames[i] = argv[optind+i];
hostnames[i] = NULL;
@@ -104,10 +104,8 @@
if ((renv_bin = findprog("renv")) == 0)
not_found("renv");
- if ((rinstall_bin = findprog("rinstall")) == 0)
- not_found("rinstall");
- if ((rsub_bin = findprog("rsub")) == 0)
- not_found("rsub");
+ rinstall_bin = "@rinstall@";
+ rsub_bin = "@rsub@";
+ rinstall_bin = "@rinstall@";
+ rsub_bin = "@rsub@";
/* all operations must be relative to the routes file */
if (realpath(xdirname(routes_file), routes_realpath) == NULL)
@@ -159,10 +157,9 @@ int main(int argc, char *argv[])
/* Convert http server command line into a vector */
inputstring = malloc(PATH_MAX);
- snprintf(inputstring, PATH_MAX, "miniquark -p %d -d " PUBLIC_DIRECTORY, http_port);
+ snprintf(inputstring, PATH_MAX, "@miniquark@ -p %d -d " PUBLIC_DIRECTORY, http_port);
str_to_array(http_srv_argv, inputstring, sizeof(http_srv_argv));
- if ((httpd_bin = findprog(http_srv_argv[0])) == 0)
- not_found(http_srv_argv[0]);
+ httpd_bin = "@miniquark@";
/* start the web server */
pipe(stdout_pipe);
@@ -397,7 +394,7 @@ handle_exit(int sig) {
printf("caught signal %d, terminating connection to '%s'\n", sig,
hostname);
@@ -404,7 +402,7 @@
if (socket_path && hostname && http_port) {
printf("caught signal %d, terminating connection to '%s'\n", sig, hostname);
/* clean up socket and SSH connection; leaving staging dir */
- execlp("ssh", "ssh", "-S", socket_path, "-O", "exit", hostname, NULL);
+ execlp("@ssh@", "@ssh@", "-S", socket_path, "-O", "exit", hostname, NULL);
err(1, "ssh -O exit");
}
}
@@ -533,10 +531,9 @@
/* Convert http server command line into a vector */
inputstring = malloc(PATH_MAX);
- snprintf(inputstring, PATH_MAX, "miniquark -p %d -d " PUBLIC_DIRECTORY, http_port);
+ snprintf(inputstring, PATH_MAX, "@miniquark@ -p %d -d " PUBLIC_DIRECTORY, http_port);
str_to_array(http_srv_argv, inputstring, sizeof(http_srv_argv), " ");
- if ((httpd_bin = findprog(http_srv_argv[0])) == 0)
- not_found(http_srv_argv[0]);
+ httpd_bin = "@miniquark@";
/* start the web server */
pipe(stdout_pipe);
diff --git a/rutils.c b/rutils.c
index 1e182d8..9aef76d 100644
--- a/rutils.c
+++ b/rutils.c
@@ -77,7 +77,7 @@ install_if_new(const char *src, const char *dst) {
@@ -123,7 +123,7 @@
pid = fork();
if (pid == 0) {
- if (execl("/usr/bin/install", "/usr/bin/install", src, dst, NULL) != -1)