mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-02 23:35:36 +00:00
added mips & isc support
This commit is contained in:
55
sudo.c
55
sudo.c
@@ -85,6 +85,14 @@ static char rcsid[] = "$Id$";
|
|||||||
#else
|
#else
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif /* HAVE_SYS_SOCKIO_H */
|
#endif /* HAVE_SYS_SOCKIO_H */
|
||||||
|
#ifdef _ISC
|
||||||
|
#include <sys/stream.h>
|
||||||
|
#include <sys/sioctl.h>
|
||||||
|
#include <sys/stropts.h>
|
||||||
|
#endif /* _ISC */
|
||||||
|
#ifdef _MIPS
|
||||||
|
#include <net/soioctl.h>
|
||||||
|
#endif /* _MIPS */
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@@ -558,6 +566,10 @@ static void load_interfaces()
|
|||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int sock, len;
|
int sock, len;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
#ifdef _ISC
|
||||||
|
struct ifreq *ifrp;
|
||||||
|
struct strioctl strioctl;
|
||||||
|
#endif /* _ISC */
|
||||||
|
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
@@ -570,10 +582,20 @@ static void load_interfaces()
|
|||||||
*/
|
*/
|
||||||
ifconf.ifc_len = sizeof(buf);
|
ifconf.ifc_len = sizeof(buf);
|
||||||
ifconf.ifc_buf = buf;
|
ifconf.ifc_buf = buf;
|
||||||
|
#ifdef _ISC
|
||||||
|
strioctl.ic_cmd = SIOCGIFCONF;
|
||||||
|
strioctl.ic_dp = (char *)&ifconf;
|
||||||
|
strioctl.ic_len = sizeof(ifconf);
|
||||||
|
if (ioctl(sock, I_STR, &strioctl) < 0) {
|
||||||
|
/* networking probably not installed in kernel */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (ioctl(sock, SIOCGIFCONF, (char *)(&ifconf)) < 0) {
|
if (ioctl(sock, SIOCGIFCONF, (char *)(&ifconf)) < 0) {
|
||||||
/* networking probably not installed in kernel */
|
/* networking probably not installed in kernel */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif /* _ISC */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find out how many interfaces exist, skipping bogus ones.
|
* find out how many interfaces exist, skipping bogus ones.
|
||||||
@@ -642,25 +664,31 @@ static void load_interfaces()
|
|||||||
* check_sudoers()
|
* check_sudoers()
|
||||||
*
|
*
|
||||||
* This function check to see that the sudoers file is owned by
|
* This function check to see that the sudoers file is owned by
|
||||||
* root and not writable by anyone else.
|
* SUDOERS_OWNER and not writable by anyone else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void check_sudoers()
|
static void check_sudoers()
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
struct passwd *pw_ent;
|
||||||
|
|
||||||
|
if (!(pw_ent = getpwnam(SUDOERS_OWNER))) {
|
||||||
|
(void) fprintf(stderr, "%s: no passwd entry for sudoers file owner (%s)\n", Argv[0], SUDOERS_OWNER);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (lstat(_PATH_SUDO_SUDOERS, &statbuf)) {
|
if (lstat(_PATH_SUDO_SUDOERS, &statbuf)) {
|
||||||
(void) fprintf(stderr, "Can't stat %s: ", _PATH_SUDO_SUDOERS);
|
(void) fprintf(stderr, "%s: Can't stat %s: ", Argv[0], _PATH_SUDO_SUDOERS);
|
||||||
perror("");
|
perror("");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (!S_ISREG(statbuf.st_mode)) {
|
} else if (!S_ISREG(statbuf.st_mode)) {
|
||||||
(void) fprintf(stderr, "%s is not a regular file!\n", _PATH_SUDO_SUDOERS);
|
(void) fprintf(stderr, "%s: %s is not a regular file!\n", Argv[0], _PATH_SUDO_SUDOERS);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (statbuf.st_uid != 0) {
|
} else if (statbuf.st_uid != pw_ent -> pw_uid) {
|
||||||
(void) fprintf(stderr, "%s is not owned by root!\n", _PATH_SUDO_SUDOERS);
|
(void) fprintf(stderr, "%s: %s is not owned by %s!\n", Argv[0], _PATH_SUDO_SUDOERS, SUDOERS_OWNER);
|
||||||
exit(1);
|
exit(1);
|
||||||
} else if (statbuf.st_mode & (0000066)) {
|
} else if (statbuf.st_mode & (0000066)) {
|
||||||
(void) fprintf(stderr, "%s is readable or writeable by other than root!\n", _PATH_SUDO_SUDOERS);
|
(void) fprintf(stderr, "%s: %s is readable or writeable by other than %s!\n", Argv[0], _PATH_SUDO_SUDOERS, SUDOERS_OWNER);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -718,6 +746,21 @@ void set_perms(perm)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERM_SUDOERS :
|
||||||
|
if (setuid(0)) {
|
||||||
|
perror("setuid(0)");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(pw_ent = getpwnam(SUDOERS_OWNER))) {
|
||||||
|
(void) fprintf(stderr, "%s: no passwd entry for sudoers file owner (%s)\n", Argv[0], SUDOERS_OWNER);
|
||||||
|
exit(1);
|
||||||
|
} else if (seteuid(pw_ent->pw_uid)) {
|
||||||
|
perror("seteuid");
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user