- proto = getprotobyname("icmp");
- /* if getprotobyname failed, just silently force
- * proto->p_proto to have the correct value for "icmp" */
- if ((pingsock = socket(AF_INET, SOCK_RAW,
- (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
- if (errno == EPERM) {
- errorMsg("permission denied. (are you root?)\n");
- } else {
- perror("ping: creating a raw socket");
- }
- exit(1);
- }
-
- /* drop root privs if running setuid */
- setuid(getuid());