aboutsummaryrefslogtreecommitdiff
path: root/sysutils/mcelog/files/patch-server.c
diff options
context:
space:
mode:
authorRyan Steinmetz <zi@FreeBSD.org>2011-10-15 02:53:31 +0000
committerRyan Steinmetz <zi@FreeBSD.org>2011-10-15 02:53:31 +0000
commit6e9151ca055629e8cb7a9bb13be28967ebcf2c61 (patch)
tree63c7b2a3e84449a8af4085b00a4c91e88ef541ac /sysutils/mcelog/files/patch-server.c
parent2e567b748dfc85a433ba5880fe1d9394453600c8 (diff)
downloadports-6e9151ca055629e8cb7a9bb13be28967ebcf2c61.tar.gz
ports-6e9151ca055629e8cb7a9bb13be28967ebcf2c61.zip
Notes
Diffstat (limited to 'sysutils/mcelog/files/patch-server.c')
-rw-r--r--sysutils/mcelog/files/patch-server.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/sysutils/mcelog/files/patch-server.c b/sysutils/mcelog/files/patch-server.c
new file mode 100644
index 000000000000..372265eb3282
--- /dev/null
+++ b/sysutils/mcelog/files/patch-server.c
@@ -0,0 +1,79 @@
+--- ./server.c.orig 2009-12-15 07:18:40.000000000 -0500
++++ ./server.c 2011-10-14 22:36:47.000000000 -0400
+@@ -101,7 +101,9 @@
+
+ static void dispatch_pages(FILE *fh)
+ {
++#ifdef __Linux__
+ dump_page_errors(fh);
++#endif
+ fprintf(fh, "done\n");
+ }
+
+@@ -137,6 +139,7 @@
+ Enomem();
+ }
+
++#ifdef __Linux__
+ /* check if client is allowed to access */
+ static int access_check(int fd, struct msghdr *msg)
+ {
+@@ -162,6 +165,35 @@
+ sendstring(fd, "permission denied\n");
+ return -1;
+ }
++#endif
++
++#ifdef __FreeBSD__
++/* check if client is allowed to access */
++static int access_check(int fd, struct msghdr *msg)
++{
++ struct cmsghdr *cmsg;
++ struct cmsgcred *cr;
++
++ /* check credentials */
++ cmsg = CMSG_FIRSTHDR(msg);
++ if (cmsg == NULL ||
++ cmsg->cmsg_level != SOL_SOCKET ||
++ cmsg->cmsg_type != SCM_CREDS) {
++ Eprintf("Did not receive credentials over client unix socket %p\n",
++ cmsg);
++ return -1;
++ }
++ cr = (struct cmsgcred *)CMSG_DATA(cmsg);
++ if (cr->cmcred_uid == 0 ||
++ (acc.uid != -1U && cr->cmcred_uid == acc.uid) ||
++ (acc.gid != -1U && cr->cmcred_gid == acc.gid))
++ return 0;
++ Eprintf("rejected client access from pid:%u uid:%u gid:%u\n",
++ cr->cmcred_pid, cr->cmcred_uid, cr->cmcred_gid);
++ sendstring(fd, "permission denied\n");
++ return -1;
++}
++#endif
+
+ /* retrieve commands from client */
+ static int client_input(int fd, struct clientcon *cc)
+@@ -242,18 +274,22 @@
+ {
+ struct clientcon *cc = NULL;
+ int nfd = accept(pfd->fd, NULL, 0);
++#ifdef __Linux__
+ int on;
++#endif
+
+ if (nfd < 0) {
+ SYSERRprintf("accept failed on client socket");
+ return;
+ }
+
++#ifdef __Linux__
+ on = 1;
+ if (setsockopt(nfd, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) {
+ SYSERRprintf("Cannot enable credentials passing on client socket");
+ goto cleanup;
+ }
++#endif
+
+ cc = xalloc(sizeof(struct clientcon));
+ if (register_pollcb(nfd, POLLIN, client_event, cc) < 0) {