]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
bozo: report bosserver -rxbind address
authorMichael Meffie <mmeffie@sinenomine.net>
Thu, 22 Sep 2011 13:13:18 +0000 (09:13 -0400)
committerDerrick Brashear <shadow@dementix.org>
Fri, 7 Oct 2011 17:32:37 +0000 (10:32 -0700)
Create a file on bosserver startup called bosserver.rxbind in the
server local directory which contains an address local scripts may
use to contact the bosserver.

When bosserver is started with the -rxbind option, write the address
selected from the intersection of the interfaces, NetInfo, and
NetRestrict configuration to the bosserver.rxbind file, otherwise
write the loopback address 127.0.0.1.

Update the RedHat init script to use the new bosserver.rxbind file.

Reviewed-on: http://gerrit.openafs.org/5488
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit 9133aa6ed3a7fe2ae55b2d3242366ae277c7f726)

Change-Id: I44f6f28d750aa0e463093655a64df8099b8d2cd4
Reviewed-on: http://gerrit.openafs.org/5539
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/bozo/bosserver.c
src/packaging/RedHat/openafs-server.init
src/util/dirpath.c
src/util/dirpath.hin
src/util/dirpath_nt.h

index dca7ec65234da260c381b6e575a6c6090614ab70..100bd694aed19861223d1f0bebd6ff024c777708 100644 (file)
@@ -173,6 +173,8 @@ bozo_ReBozo(void)
        close(i);
     }
 
+    unlink(AFSDIR_SERVER_BOZRXBIND_FILEPATH);
+
     execv(argv[0], argv);      /* should not return */
     _exit(1);
 #endif /* AFS_NT40_ENV */
@@ -812,6 +814,34 @@ bozo_DeletePidFile(char *ainst, char *aname)
     return 0;
 }
 
+/**
+ * Create the rxbind file of this bosserver.
+ *
+ * @param host  bind address of this server
+ *
+ * @returns status
+ */
+void
+bozo_CreateRxBindFile(afs_uint32 host)
+{
+    char buffer[16];
+    FILE *fp;
+
+    if (host == htonl(INADDR_ANY)) {
+       host = htonl(0x7f000001);
+    }
+
+    afs_inet_ntoa_r(host, buffer);
+    bozo_Log("Listening on %s:%d\n", buffer, AFSCONF_NANNYPORT);
+    if ((fp = fopen(AFSDIR_SERVER_BOZRXBIND_FILEPATH, "w")) == NULL) {
+       bozo_Log("Unable to open rxbind address file: %s, code=%d\n",
+                AFSDIR_SERVER_BOZRXBIND_FILEPATH, errno);
+    } else {
+       fprintf(fp, "%s\n", buffer);
+       fclose(fp);
+    }
+}
+
 /* start a process and monitor it */
 
 #include "AFS_component_version_number.c"
@@ -1135,6 +1165,8 @@ main(int argc, char **argv, char **envp)
        exit(code);
     }
 
+    bozo_CreateRxBindFile(host);       /* for local scripts */
+
     /* opened the cell databse */
     bozo_confdir = tdir;
 
index 3cb62e9b922a9e60329a5a23bd70b121b283ac81..69179df3f5c27c98cb472f3c1fd811784903019c 100644 (file)
@@ -34,7 +34,14 @@ stop() {
                echo
                return 1
        fi
-       /usr/bin/bos shutdown localhost -wait -localauth
+       if [ "x$BOSSERVER_HOST" = "x" ] ; then
+               if [ -f /usr/afs/local/bosserver.rxbind ] ; then
+                       BOSSERVER_HOST=`cat /usr/afs/local/bosserver.rxbind`
+               else
+                       BOSSERVER_HOST="localhost"
+               fi
+       fi
+       /usr/bin/bos shutdown $BOSSERVER_HOST -wait -localauth
        RETVAL=$?
        if [ $RETVAL -ne 0 ] ; then
                echo -n $"failed to shutdown OpenAFS"
@@ -46,6 +53,7 @@ stop() {
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/openafs-server
+       [ $RETVAL -eq 0 ] && rm -f /usr/afs/local/bosserver.rxbind
        return $RETVAL
 }
 
index 7469b64af351aed16dfa5c09bd19a2cb526feff2..212b8f5cde4f6267cc85b90495c25497fbbf004c 100644 (file)
@@ -333,6 +333,9 @@ initDirPathArray(void)
     pathp = dirPathArray[AFSDIR_SERVER_BOZINIT_FILEPATH_ID];
     AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BOSCONFIG_DIR, AFSDIR_BOZINIT_FILE);
 
+    pathp = dirPathArray[AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID];
+    AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BOSCONFIG_DIR, AFSDIR_BOZRXBIND_FILE);
+
     pathp = dirPathArray[AFSDIR_SERVER_BOSVR_FILEPATH_ID];
     AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BOSSERVER_DIR, AFSDIR_BOSVR_FILE);
 
index 805bf442c61f5c7f903d01bb5f59e87ddd5e109c..c649c6ad441ffc31f6a887e283755a6f5315c714 100644 (file)
@@ -144,6 +144,7 @@ ConstructLocalLogPath(const char *cpath,
 #define AFSDIR_BOZCONFNEW_FILE  "BosConfig.new"
 #define AFSDIR_BOZINIT_FILE     "BozoInit"
 #define AFSDIR_BOZLOG_FILE      "BosLog"
+#define AFSDIR_BOZRXBIND_FILE   "bosserver.rxbind"
 #define AFSDIR_BOSVR_FILE       "bosserver"
 #define AFSDIR_VOLSERLOG_FILE   "VolserLog"
 #define AFSDIR_AUDIT_FILE       "Audit"
@@ -253,6 +254,7 @@ typedef enum afsdir_id {
       AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID,
       AFSDIR_SERVER_BOZINIT_FILEPATH_ID,
       AFSDIR_SERVER_BOZLOG_FILEPATH_ID,
+      AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID,
       AFSDIR_SERVER_BOSVR_FILEPATH_ID,
       AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID,
       AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID,
@@ -334,6 +336,7 @@ const char *getDirPath(afsdir_id_t string_id);
 #define AFSDIR_SERVER_BOZCONFNEW_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID)
 #define AFSDIR_SERVER_BOZINIT_FILEPATH getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID)
 #define AFSDIR_SERVER_BOZLOG_FILEPATH getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZRXBIND_FILEPATH getDirPath(AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID)
 #define AFSDIR_SERVER_BOSVR_FILEPATH getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID)
 #define AFSDIR_SERVER_SLVGLOCK_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID)
 #define AFSDIR_SERVER_VOLSERLOG_FILEPATH getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID)
index e4d37a2106e863d5a3f77362a7df0f9508d03391..6b8210fea1a4910ad3055afc65cb2bac72bd59f9 100644 (file)
@@ -134,6 +134,7 @@ extern int
 #define AFSDIR_BOZCONFNEW_FILE  "BosConfig.new"
 #define AFSDIR_BOZINIT_FILE     "BozoInit"
 #define AFSDIR_BOZLOG_FILE      "BosLog"
+#define AFSDIR_BOZRXBIND_FILE   "bosserver.rxbind"
 #define AFSDIR_BOSVR_FILE       "bosserver"
 #define AFSDIR_VOLSERLOG_FILE   "VolserLog"
 #define AFSDIR_AUDIT_FILE       "Audit"
@@ -245,6 +246,7 @@ typedef enum afsdir_id {
     AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID,
     AFSDIR_SERVER_BOZINIT_FILEPATH_ID,
     AFSDIR_SERVER_BOZLOG_FILEPATH_ID,
+    AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID,
     AFSDIR_SERVER_BOSVR_FILEPATH_ID,
     AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID,
     AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID,
@@ -326,6 +328,7 @@ const char *getDirPath(afsdir_id_t string_id);
 #define AFSDIR_SERVER_BOZCONFNEW_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID)
 #define AFSDIR_SERVER_BOZINIT_FILEPATH getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID)
 #define AFSDIR_SERVER_BOZLOG_FILEPATH getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZRXBIND_FILEPATH getDirPath(AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID)
 #define AFSDIR_SERVER_BOSVR_FILEPATH getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID)
 #define AFSDIR_SERVER_SLVGLOCK_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID)
 #define AFSDIR_SERVER_VOLSERLOG_FILEPATH getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID)