~kennylevinsen/seatd

483dbf76faf9f23117454aa8fc6d22abee3edc89 — Kenny Levinsen a month ago d5c1a78
seatd-launch: Use optind to find the command

The command indexing had not been updated afer the introduction of
getopt, so combining a command with flags would fail.

Add error handling for if no command was specified while we're at it.
1 files changed, 7 insertions(+), 1 deletions(-)

M seatd-launch/seatd-launch.c
M seatd-launch/seatd-launch.c => seatd-launch/seatd-launch.c +7 -1
@@ 41,6 41,12 @@ int main(int argc, char *argv[]) {
		}
	}

	if (optind >= argc) {
		fprintf(stderr, "A command must be specified\n\n%s", usage);
		return 1;
	}
	char **command = &argv[optind];

	char sockbuf[256];
	if (sockpath == NULL) {
		sprintf(sockbuf, "/tmp/seatd.%d.sock", getpid());


@@ 139,7 145,7 @@ int main(int argc, char *argv[]) {
		goto error_seatd;
	} else if (child == 0) {
		setenv("SEATD_SOCK", sockpath, 1);
		execvp(argv[1], &argv[1]);
		execvp(command[0], command);
		perror("Could not start target");
		_exit(1);
	}