mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-27 12:05:15 +00:00
iodine/iodined: do not print usage if no superuser
There is no value in printing the usage in this case, as the usage doesn't give the user any hint on how to solve this issue. Furthermore, replace the Windows implementation with an empty inline function, which will result in no code. Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
parent
c83d2ae03c
commit
1c86bf347f
12
src/common.c
12
src/common.c
@ -101,18 +101,16 @@ int setgroups(int count, int *groups)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
check_superuser(void (*usage_fn)(void))
|
|
||||||
{
|
|
||||||
#ifndef WINDOWS32
|
#ifndef WINDOWS32
|
||||||
|
void
|
||||||
|
check_superuser(void)
|
||||||
|
{
|
||||||
if (geteuid() != 0) {
|
if (geteuid() != 0) {
|
||||||
warnx("Run as root and you'll be happy.\n");
|
warnx("Run as root and you'll be happy.\n");
|
||||||
usage_fn();
|
exit(-1);
|
||||||
/* NOTREACHED */
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
format_addr(struct sockaddr_storage *sockaddr, int sockaddr_len)
|
format_addr(struct sockaddr_storage *sockaddr, int sockaddr_len)
|
||||||
|
@ -102,7 +102,13 @@ enum connection {
|
|||||||
CONN_MAX
|
CONN_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
void check_superuser(void (*usage_fn)(void));
|
#ifdef WINDOWS32
|
||||||
|
static inline void check_superuser(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void check_superuser(void);
|
||||||
|
#endif
|
||||||
char *format_addr(struct sockaddr_storage *sockaddr, int sockaddr_len);
|
char *format_addr(struct sockaddr_storage *sockaddr, int sockaddr_len);
|
||||||
int get_addr(char *, int, int, int, struct sockaddr_storage *);
|
int get_addr(char *, int, int, int, struct sockaddr_storage *);
|
||||||
int open_dns(struct sockaddr_storage *, size_t);
|
int open_dns(struct sockaddr_storage *, size_t);
|
||||||
|
@ -275,7 +275,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_superuser(usage);
|
check_superuser();
|
||||||
|
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
@ -2537,7 +2537,7 @@ main(int argc, char **argv)
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
check_superuser(usage);
|
check_superuser();
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
usage();
|
usage();
|
||||||
|
Loading…
Reference in New Issue
Block a user