All of lore.kernel.org
 help / color / mirror / Atom feed
From: lhh@sourceware.org <lhh@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/fence/agents/manual Makefile ack.c
Date: 17 Dec 2007 20:04:13 -0000	[thread overview]
Message-ID: <20071217200413.17220.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at sourceware.org	2007-12-17 20:04:12

Modified files:
	fence/agents/manual: Makefile ack.c 

Log message:
	Fix #418541

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/manual/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/manual/ack.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3&r2=1.3.16.1

--- cluster/fence/agents/manual/Makefile	2006/08/11 15:18:08	1.7
+++ cluster/fence/agents/manual/Makefile	2007/12/17 20:04:04	1.7.2.1
@@ -16,7 +16,8 @@
 top_srcdir=../..
 
 
-INCLUDE= -I${top_srcdir}/include -I${top_srcdir}/config -I${incdir} -I../../../cman/lib -I../../../group/lib
+INCLUDE= -I${top_srcdir}/include -I${top_srcdir}/config -I${incdir} -I../../../cman/lib -I../../../group/lib \
+	 -I../../../ccs/lib -I../../fenced
 
 
 include ${top_srcdir}/make/defines.mk
@@ -31,10 +32,10 @@
 	$(CC) $(LDFLAGS) -o $@ $^ -lcman
 
 manual.o: manual.c
-	$(CC) $(CFLAGS) -c -o $@ $<
+	$(CC) $(CFLAGS) -c -o $@ $< 
 
 fence_ack_manual: ack.o
-	${CC} -o $@ $^
+	${CC} -o $@ $^ ../../../ccs/lib/libccs.a
 
 ack.o: ack.c
 	$(CC) $(CFLAGS) -c -o $@ $<
--- cluster/fence/agents/manual/Attic/ack.c	2004/11/24 03:46:32	1.3
+++ cluster/fence/agents/manual/Attic/ack.c	2007/12/17 20:04:04	1.3.16.1
@@ -11,6 +11,9 @@
 *******************************************************************************
 ******************************************************************************/
 
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -19,8 +22,9 @@
 #include <errno.h>
 #include <ctype.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/wait.h>
+#include <ccs.h>
+#include <fd.h>
 
 #include "copyright.cf"
 
@@ -30,6 +34,7 @@
 char fname[256];
 int quiet_flag = 0;
 int override_flag = 0;
+int emergency_flag = 0;
 
 
 void print_usage(void)
@@ -43,9 +48,78 @@
 	 "  -O               override\n"
 	 "  -n <nodename>    Name of node that was manually fenced\n"
 	 "  -s <ip>          IP address of machine that was manually fenced (deprecated)\n"
+	 "  -e               Emergency Override (use if fencing has failed)\n"
          "  -V               Version information\n", pname);
 }
 
+int do_emergency_override(char *ipaddr)
+{
+  int fd;
+  int cd, tries = 0, error = 0;
+  char buf[PATH_MAX], path[PATH_MAX], *str = NULL;
+  struct stat st_buf;
+
+  cd = ccs_force_connect(NULL, 1);
+  if (cd >= 0) {
+    memset(buf, 0, sizeof(buf));
+    snprintf(buf, sizeof(buf)-1, "/cluster/fence_daemon/@override_path");
+    error = ccs_get(cd, buf, &str);
+    ccs_disconnect(cd);
+  }
+
+  if (error != 0)
+    str = DEFAULT_OVERRIDE_PATH;
+
+  memset(path, 0, sizeof(path));
+  snprintf(path, sizeof(path)-1, "%s", str);
+
+  if (error == 0)
+    free(str);
+
+  while (1) {
+    if (tries) {
+      if (tries == 1)
+        printf("Waiting for %s to become available...\n", path);
+      sleep(1);
+    }
+    ++tries;
+
+    fd = open(path, O_WRONLY);
+    if (fd < 0) {
+      switch(errno) {
+      case ENOENT:
+	continue;
+      default:
+        perror("open");
+        return 1;
+      }
+    }
+
+    error = fstat(fd, &st_buf);
+    if (error < 0) {
+      close(fd);
+      switch(errno) {
+      case ENOENT:
+	continue;
+      default:
+        perror("fstat");
+        return 1;
+      }
+    }
+
+    if (!S_ISFIFO(st_buf.st_mode)) {
+      printf("WARNING: %s is not a named pipe\n", str);
+    }
+
+    snprintf(buf, sizeof(buf)-1, "%s\n", ipaddr);
+    write(fd, buf, strlen(buf));
+    close(fd);
+    break;
+  }
+
+  return 0;
+}
+
 int main(int argc, char **argv)
 {
   int error, fd;
@@ -58,7 +132,7 @@
 
   pname = argv[0];
     
-  while ((c = getopt(argc, argv, "hOs:n:qV")) != -1)
+  while ((c = getopt(argc, argv, "ehOs:n:qV")) != -1)
   {
     switch(c)
     {
@@ -70,6 +144,10 @@
       override_flag = 1;
       break;
 
+    case 'e':
+      emergency_flag = 1;
+      break;
+
     case 's':
       ipaddr = optarg;
       break;
@@ -128,6 +206,10 @@
     }
   }
 
+  if (emergency_flag) {
+    return do_emergency_override(ipaddr);
+  }
+
   memset(fname, 0, 256);
   sprintf(fname, "%s/fence_manual.fifo", FIFO_DIR);
 



                 reply	other threads:[~2007-12-17 20:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071217200413.17220.qmail@sourceware.org \
    --to=lhh@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.