Hardcoded system name. (LIBGTOP_COMPILE_RELEASE): Hardcoded system
1999-02-19 Martin Baulig <martin@home-of-linux.org> * Makefile.am (LIBGTOP_COMPILE_SYSTEM): Hardcoded system name. (LIBGTOP_COMPILE_RELEASE): Hardcoded system release. (LIBGTOP_COMPILE_MACHINE): Hardcoded machine type. * server.c (main): Abort if not running on the system the server was compiled on.
This commit is contained in:
committed by
Martin Baulig
parent
3c9b2e3d9f
commit
72a3f5aaa1
@@ -28,6 +28,8 @@ glibtop *glibtop_global_server = &_glibtop_global_server;
|
||||
#include <glibtop/union.h>
|
||||
#include <glibtop/sysdeps.h>
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
const unsigned long glibtop_server_features =
|
||||
GLIBTOP_SUID_CPU +
|
||||
GLIBTOP_SUID_MEM +
|
||||
@@ -56,13 +58,26 @@ GLIBTOP_SUID_PPP;
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
|
||||
|
||||
struct utsname uts;
|
||||
int uid, euid, gid, egid;
|
||||
|
||||
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
|
||||
|
||||
uid = getuid (); euid = geteuid ();
|
||||
gid = getgid (); egid = getegid ();
|
||||
|
||||
if (uname (&uts)) _exit (1);
|
||||
|
||||
if (strcmp (uts.sysname, LIBGTOP_COMPILE_SYSTEM) ||
|
||||
strcmp (uts.release, LIBGTOP_COMPILE_RELEASE) ||
|
||||
strcmp (uts.machine, LIBGTOP_COMPILE_MACHINE)) {
|
||||
fprintf (stderr, "Can only run on %s %s %s\n",
|
||||
LIBGTOP_COMPILE_SYSTEM,
|
||||
LIBGTOP_COMPILE_RELEASE,
|
||||
LIBGTOP_COMPILE_MACHINE);
|
||||
_exit (1);
|
||||
}
|
||||
|
||||
glibtop_init_p (glibtop_global_server, 0, 0);
|
||||
|
||||
if (setreuid (euid, uid)) _exit (1);
|
||||
|
||||
Reference in New Issue
Block a user