#include #include #include #include #include #define version "pppctl v1.0 by Vladimir Gancheff " void usage(char *name); main(int argc, char *argv[]) { int option; if (getuid() != 0) { printf("This program should be run by the superuser\n"); return 1; } if (argc < 2) { printf("%s: option missing\n", argv[0]); printf("Try `%s --help' for more information.\n", argv[0]); return 1; } if (strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "--connect") == 0) option = 1; if (strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "--demand") == 0) option = 2; if (strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--terminate") == 0) option = 3; if (strcmp(argv[1], "--help") == 0) option = 4; if (strcmp(argv[1], "--version") == 0) option = 5; switch(option) { case 1: system("/usr/sbin/pppd -detach connect '/usr/sbin/chat -v -f /etc/ppp/pppscript' &"); break; case 2: system("/usr/sbin/pppd file '/etc/ppp/options.demand' &"); printf("%s: demand dialing started\n", argv[0]); break; case 3: system("killall -INT pppd 2>/dev/null"); system("rm -f /var/lock/LCK* /var/run/ppp*.pid"); printf("%s: terminating connection to ppp0\n", argv[0]); break; case 4: usage(argv[0]); break; case 5: printf("%s\n", version); break; default: printf("%s: unrecognized option `%s'\n", argv[0], argv[1]); printf("Try `%s --help' for more information.\n", argv[0]); return 1; } return 0; } void usage(char *name) { printf("Usage: %s [OPTION]\n\n", name); printf("\t-c, --connect create connection\n"); printf("\t-d, --demand put pppd in demand dialing mode.\n"); printf("\t-t, --terminate terminate connection\n"); printf("\t --help display this help and exit\n"); printf("\t --version output version information and exit\n\n"); printf("Report bugs to shudder@gbg.bg\n"); }