summaryrefslogtreecommitdiff
path: root/lib/open.c
diff options
context:
space:
mode:
authorMartin Baulig <martin@home-of-linux.org>1999-02-19 22:30:34 +0000
committerMartin Baulig <martin@src.gnome.org>1999-02-19 22:30:34 +0000
commit35995577ca5f42fb8ee6d38501c34c9d5ad588f1 (patch)
treeafd1b93ca10ef58e67f80723d10587ad2872e11f /lib/open.c
parenteaf527d66a295891440c2ff612f5a13503f514f5 (diff)
downloadlibgtop-35995577ca5f42fb8ee6d38501c34c9d5ad588f1.tar.gz
For suid/sgid servers the operating system version must match the one the
1999-02-19 Martin Baulig <martin@home-of-linux.org> * lib/open.c, src/daemon/version.c: For suid/sgid servers the operating system version must match the one the server was compiled on.
Diffstat (limited to 'lib/open.c')
-rw-r--r--lib/open.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/open.c b/lib/open.c
index 4d46b528..a6a22d37 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -28,6 +28,8 @@
#include <glibtop/gnuserv.h>
+#include <sys/utsname.h>
+
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
void
@@ -126,18 +128,23 @@ glibtop_open_l (glibtop *server, const char *program_name,
/* If the server has been started, ask it for its features. */
if (server->flags & _GLIBTOP_INIT_STATE_SERVER) {
- char version [BUFSIZ], buffer [BUFSIZ];
+ char version [BUFSIZ+10], buffer [BUFSIZ+10];
glibtop_sysdeps sysdeps;
size_t size, nbytes;
+ struct utsname uts;
/* First check whether the server version is correct. */
- sprintf (version, LIBGTOP_VERSION_STRING,
- LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
- sizeof (glibtop_command),
- sizeof (glibtop_response),
- sizeof (glibtop_union),
- sizeof (glibtop_sysdeps));
+ if (uname (&uts))
+ glibtop_error_io_r (server, "uname");
+
+ snprintf (version, BUFSIZ, LIBGTOP_VERSION_STRING,
+ LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
+ sizeof (glibtop_command),
+ sizeof (glibtop_response),
+ sizeof (glibtop_union),
+ sizeof (glibtop_sysdeps),
+ uts.sysname, uts.release, uts.machine);
size = strlen (version) + 1;
@@ -151,8 +158,12 @@ glibtop_open_l (glibtop *server, const char *program_name,
glibtop_read_l (server, nbytes, buffer);
if (memcmp (version, buffer, size))
- glibtop_error_r (server, "server version is not %s",
- LIBGTOP_VERSION);
+ glibtop_error_r
+ (server,
+ "server version is not %s / %d "
+ "compiled for %s %s %s",
+ LIBGTOP_VERSION, LIBGTOP_SERVER_VERSION,
+ uts.sysname, uts.release, uts.machine);
/* Now ask it for its features. */