This commit is contained in:
Your Name 2024-09-30 16:11:43 +03:00
parent 04ff3cf8e7
commit 0306c4319b
3 changed files with 32 additions and 15 deletions

View file

@ -3,23 +3,30 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <libgen.h>
#define _MUSUID_C
#include "config.h"
const char *progs[] = {"su", "ping"};
int main(int argc, char **argv) {
if (argc == 1) {
char *prog = basename(argv[0]);
if (argc == 1 && !strcmp(prog, "musuid")) {
fputs("musuid: missing operand\n", stderr);
return 1;
}
argc--;
argv++;
else if (!strcmp(prog, "musuid")) {
argv++;
argc--;
prog = argv[0];
}
/* RUN */
for (size_t i = 0; i < sizeof(progs) / sizeof(char *); i++)
if (!strcmp(argv[0], progs[i]))
if (!strcmp(prog, progs[i]))
execv(MUTILS_PATH, argv);
fprintf(stderr, "musuid: unknown command: %s\n", argv[0]);