public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH] misc-progs: Fix passing argument list
@ 2022-06-23 11:43 Michael Tremer
  2022-06-23 13:20 ` Peter Müller
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Tremer @ 2022-06-23 11:43 UTC (permalink / raw)
  To: development

[-- Attachment #1: Type: text/plain, Size: 3750 bytes --]

The run() function expects all arguments without the basename of the
program.

This regression was introduced in a609195a26f2666a177b988a6691bc27b10e6d64.

Fixes: #12886
Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
 src/misc-progs/backupctrl.c  | 2 +-
 src/misc-progs/extrahdctrl.c | 2 +-
 src/misc-progs/getipstat.c   | 2 +-
 src/misc-progs/mpfirectrl.c  | 2 +-
 src/misc-progs/pakfire.c     | 2 +-
 src/misc-progs/sambactrl.c   | 4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/misc-progs/backupctrl.c b/src/misc-progs/backupctrl.c
index 0a85141ca..bb2ca69ef 100644
--- a/src/misc-progs/backupctrl.c
+++ b/src/misc-progs/backupctrl.c
@@ -11,5 +11,5 @@ int main(int argc, char** argv) {
 	if (!initsetuid())
 		exit(1);
 
-	return run("/var/ipfire/backup/bin/backup.pl", argv);
+	return run("/var/ipfire/backup/bin/backup.pl", argv + 1);
 }
diff --git a/src/misc-progs/extrahdctrl.c b/src/misc-progs/extrahdctrl.c
index 49a25387f..255050acd 100644
--- a/src/misc-progs/extrahdctrl.c
+++ b/src/misc-progs/extrahdctrl.c
@@ -11,5 +11,5 @@ int main(int argc, char** argv) {
 	if (!initsetuid())
 		exit(1);
 
-	return run("/var/ipfire/extrahd/bin/extrahd.pl", argv);
+	return run("/var/ipfire/extrahd/bin/extrahd.pl", argv + 1);
 }
diff --git a/src/misc-progs/getipstat.c b/src/misc-progs/getipstat.c
index 37e01c81a..66d5b5a92 100644
--- a/src/misc-progs/getipstat.c
+++ b/src/misc-progs/getipstat.c
@@ -27,7 +27,7 @@ int main(int argc, char** argv)
 	// but /sbin/iptables is actually a symlink to /sbin/xtables-legacy-multi hence that program is executed
 	// however without the notion that it was called as "iptables". So we have to pass "iptables" as first
 	// argument.
-	char *args[10] = {"iptables", "--list", "--verbose", "--numeric", "--wait", "5", NULL, NULL, NULL, NULL};
+	char *args[] = {"--list", "--verbose", "--numeric", "--wait", "5", NULL, NULL, NULL, NULL};
 	char *usage = "getipstat [-x][-f|-n|-m]";
 	unsigned int pcount = 6;
 	unsigned int table_set = 0;
diff --git a/src/misc-progs/mpfirectrl.c b/src/misc-progs/mpfirectrl.c
index a71789c0f..4ea1fb543 100644
--- a/src/misc-progs/mpfirectrl.c
+++ b/src/misc-progs/mpfirectrl.c
@@ -11,5 +11,5 @@ int main(int argc, char** argv) {
 	if (!initsetuid())
 		exit(1);
 
-	return run("/var/ipfire/mpfire/bin/mpfire.pl", argv);
+	return run("/var/ipfire/mpfire/bin/mpfire.pl", argv + 1);
 }
diff --git a/src/misc-progs/pakfire.c b/src/misc-progs/pakfire.c
index 93a18e604..35bea8677 100644
--- a/src/misc-progs/pakfire.c
+++ b/src/misc-progs/pakfire.c
@@ -11,5 +11,5 @@ int main(int argc, char** argv) {
 	if (!initsetuid())
 		exit(1);
 
-	return run("/opt/pakfire/pakfire", argv);
+	return run("/opt/pakfire/pakfire", argv + 1);
 }
diff --git a/src/misc-progs/sambactrl.c b/src/misc-progs/sambactrl.c
index 501535799..38c26089c 100644
--- a/src/misc-progs/sambactrl.c
+++ b/src/misc-progs/sambactrl.c
@@ -82,7 +82,7 @@ int main(int argc, char *argv[]) {
 		snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba User' -m -g sambauser -s /bin/false %s >/dev/null", argv[2]);
 		safe_system(command);
 
-		run("/usr/sbin/samba-change-password", argv + 1);
+		run("/usr/sbin/samba-change-password", argv + 2);
 
 	} else if (strcmp(argv[1], "smbchangepw") == 0) {
 		if (!is_valid_argument_alnum(argv[2])) {
@@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
 			exit(2);
 		}
 
-		run("/usr/sbin/samba-change-password", argv + 1);
+		run("/usr/sbin/samba-change-password", argv + 2);
 
 	} else if (strcmp(argv[1], "readsmbpasswd") == 0) {
 		safe_system("/bin/chown root:nobody /var/ipfire/samba/private >/dev/null");
-- 
2.30.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] misc-progs: Fix passing argument list
  2022-06-23 11:43 [PATCH] misc-progs: Fix passing argument list Michael Tremer
@ 2022-06-23 13:20 ` Peter Müller
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Müller @ 2022-06-23 13:20 UTC (permalink / raw)
  To: development

[-- Attachment #1: Type: text/plain, Size: 3981 bytes --]

Acked-by: Peter Müller <peter.mueller(a)ipfire.org>

> The run() function expects all arguments without the basename of the
> program.
> 
> This regression was introduced in a609195a26f2666a177b988a6691bc27b10e6d64.
> 
> Fixes: #12886
> Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
> ---
>  src/misc-progs/backupctrl.c  | 2 +-
>  src/misc-progs/extrahdctrl.c | 2 +-
>  src/misc-progs/getipstat.c   | 2 +-
>  src/misc-progs/mpfirectrl.c  | 2 +-
>  src/misc-progs/pakfire.c     | 2 +-
>  src/misc-progs/sambactrl.c   | 4 ++--
>  6 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/misc-progs/backupctrl.c b/src/misc-progs/backupctrl.c
> index 0a85141ca..bb2ca69ef 100644
> --- a/src/misc-progs/backupctrl.c
> +++ b/src/misc-progs/backupctrl.c
> @@ -11,5 +11,5 @@ int main(int argc, char** argv) {
>  	if (!initsetuid())
>  		exit(1);
>  
> -	return run("/var/ipfire/backup/bin/backup.pl", argv);
> +	return run("/var/ipfire/backup/bin/backup.pl", argv + 1);
>  }
> diff --git a/src/misc-progs/extrahdctrl.c b/src/misc-progs/extrahdctrl.c
> index 49a25387f..255050acd 100644
> --- a/src/misc-progs/extrahdctrl.c
> +++ b/src/misc-progs/extrahdctrl.c
> @@ -11,5 +11,5 @@ int main(int argc, char** argv) {
>  	if (!initsetuid())
>  		exit(1);
>  
> -	return run("/var/ipfire/extrahd/bin/extrahd.pl", argv);
> +	return run("/var/ipfire/extrahd/bin/extrahd.pl", argv + 1);
>  }
> diff --git a/src/misc-progs/getipstat.c b/src/misc-progs/getipstat.c
> index 37e01c81a..66d5b5a92 100644
> --- a/src/misc-progs/getipstat.c
> +++ b/src/misc-progs/getipstat.c
> @@ -27,7 +27,7 @@ int main(int argc, char** argv)
>  	// but /sbin/iptables is actually a symlink to /sbin/xtables-legacy-multi hence that program is executed
>  	// however without the notion that it was called as "iptables". So we have to pass "iptables" as first
>  	// argument.
> -	char *args[10] = {"iptables", "--list", "--verbose", "--numeric", "--wait", "5", NULL, NULL, NULL, NULL};
> +	char *args[] = {"--list", "--verbose", "--numeric", "--wait", "5", NULL, NULL, NULL, NULL};
>  	char *usage = "getipstat [-x][-f|-n|-m]";
>  	unsigned int pcount = 6;
>  	unsigned int table_set = 0;
> diff --git a/src/misc-progs/mpfirectrl.c b/src/misc-progs/mpfirectrl.c
> index a71789c0f..4ea1fb543 100644
> --- a/src/misc-progs/mpfirectrl.c
> +++ b/src/misc-progs/mpfirectrl.c
> @@ -11,5 +11,5 @@ int main(int argc, char** argv) {
>  	if (!initsetuid())
>  		exit(1);
>  
> -	return run("/var/ipfire/mpfire/bin/mpfire.pl", argv);
> +	return run("/var/ipfire/mpfire/bin/mpfire.pl", argv + 1);
>  }
> diff --git a/src/misc-progs/pakfire.c b/src/misc-progs/pakfire.c
> index 93a18e604..35bea8677 100644
> --- a/src/misc-progs/pakfire.c
> +++ b/src/misc-progs/pakfire.c
> @@ -11,5 +11,5 @@ int main(int argc, char** argv) {
>  	if (!initsetuid())
>  		exit(1);
>  
> -	return run("/opt/pakfire/pakfire", argv);
> +	return run("/opt/pakfire/pakfire", argv + 1);
>  }
> diff --git a/src/misc-progs/sambactrl.c b/src/misc-progs/sambactrl.c
> index 501535799..38c26089c 100644
> --- a/src/misc-progs/sambactrl.c
> +++ b/src/misc-progs/sambactrl.c
> @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) {
>  		snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba User' -m -g sambauser -s /bin/false %s >/dev/null", argv[2]);
>  		safe_system(command);
>  
> -		run("/usr/sbin/samba-change-password", argv + 1);
> +		run("/usr/sbin/samba-change-password", argv + 2);
>  
>  	} else if (strcmp(argv[1], "smbchangepw") == 0) {
>  		if (!is_valid_argument_alnum(argv[2])) {
> @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
>  			exit(2);
>  		}
>  
> -		run("/usr/sbin/samba-change-password", argv + 1);
> +		run("/usr/sbin/samba-change-password", argv + 2);
>  
>  	} else if (strcmp(argv[1], "readsmbpasswd") == 0) {
>  		safe_system("/bin/chown root:nobody /var/ipfire/samba/private >/dev/null");

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-23 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 11:43 [PATCH] misc-progs: Fix passing argument list Michael Tremer
2022-06-23 13:20 ` Peter Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox