(add the "nonet" group)
Code: Select all
# groupadd nonet
Code: Select all
# iptables -I OUTPUT -m owner --gid-owner nonet -j REJECT --reject-with icmp-net-unreachable
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <grp.h>
#include <unistd.h>
#ifndef _NONET_GROUP
#define _NONET_GROUP "nonet"
#endif
int main(int argc, char *argv[])
{
struct group *gr;
if (argc <= 1) {
fprintf(stderr, "Usage: %s command [ arg ... ]\n", argv[0]);
exit(1);
}
if (!(gr = getgrnam(_NONET_GROUP))) {
perror("getgrnam");
exit(1);
}
if (setgid(gr->gr_gid) == -1) {
perror("setgid");
exit(1);
}
if (setuid(getuid()) == -1) {
perror("setuid");
exit(1);
}
argv++;
argc--;
if (execvp(*argv, argv) == -1) {
perror("execvp");
exit(1);
}
exit(0); /* not reached */
}
Code: Select all
# gcc -o nonet nonet.c ; chown root:staff nonet ; chmod 4750 nonet
Code: Select all
# nonet wine some.exe