/usr/include/nuxwdog/WatchdogClient.h is in libnuxwdog-dev 1.0.3-3+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | /* --- BEGIN COPYRIGHT BLOCK ---
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Copyright (C) 2009 Red Hat, Inc.
* All rights reserved.
* --- END COPYRIGHT BLOCK ---
*/
#ifndef _WatchdogClient_h_
#define _WatchdogClient_h_
#include <nspr/nspr.h> // NSPR declarations
#include "wdservermessage.h" // wdServerMessage class
/**
* This class encapsulates the client-side communication of the watchdog
* process that runs on Unix platforms.
*
* @author $Author: chrisk $
* @version $Revision: 1.1.2.13.4.1 $ $Date: 2002/03/08 16:27:04 $
* @since iWS5.0
*/
#ifdef __cplusplus
class WatchdogClient
{
public:
/**
* Creates a listen socket binding it to the address specified in
* the configuration. The watchdog process creates the listen sockets
* on behalf of this method and passes the file descriptors to this
* process.
*
* @returns <code>PR_SUCCESS</code> if the initialization/creation
* of the socket was successful. <code>PR_FAILURE</code>
* if there was an error.
*/
static PRStatus init(void);
/**
* Closes the watchdog connection.
*
* @returns <code>PR_SUCCESS</code> if the close
* of the socket was successful. <code>PR_FAILURE</code>
* if there was an error.
*/
static PRStatus close(void);
/**
* Reconnects to the watchdog (in a child process).
*
* @returns <code>PR_SUCCESS</code> if the reconnect was successful.
* <code>PR_FAILURE</code> if there was an error.
*/
static PRStatus reconnect(void);
/**
* Sends the pathname of the PID file for this process to the watchdog.
*
* @param pidPath The pathname of the file containing the process ID
* @returns <code>PR_SUCCESS</code> if the path could be sent to
* the watchdog. <code>PR_FAILURE</code> if there was
* an error.
*/
static PRStatus sendPIDPath(const char* pidPath);
/**
* Asks the watchdog to create a listen socket on the specified IP
* and port and return the file descriptor for the newly created
* socket.
*
* @param lsName The ID of the listen socket in the configuration
* @param ip The address to which the listen socket should bind to
* or <code>NULL</code> if an <code>INADDR_ANY</code>
* socket is to be created
* @param port The port on which the newly created socket must listen
* for requests on.
* @param family The address family, e.g. PR_AF_INET
* @returns A valid file descriptor corresponding to the listen
* socket. A negative value indicates that there was
* an error.
*/
/* This does not compile on 64-bit. Its currently unused so commenting
out for now - alee
static PRInt32 getLS(const char* lsName, const char* ip,
const PRUint16 port, const PRUint16 family);
*/
/**
* Asks the watchdog to close the listen socket on the specified IP
* and port.
*
* @param lsName The ID of the listen socket in the configuration
* @param ip The address to which the listen socket was bound to
* or <code>NULL</code> if an <code>INADDR_ANY</code>
* socket was created
* @param port The port on which the socket was listening for
* requests on.
* @param family The address family, e.g. PR_AF_INET
* @returns <code>PR_SUCCESS</code> if the socket could be
* closed. <code>PR_FAILURE</code> indicates that there
* was an error.
*/
static PRStatus closeLS(const char* lsName, const char* ip,
const PRUint16 port, const PRUint16 family);
/**
* Sends a message to the watchdog indicating that the server process
* has completed its initialization.
*/
static PRStatus sendEndInit(PRInt32 numprocs);
/**
* Requests a SSL module password from the watchdog.
*
* @param prompt The prompt to use when asking for the password. Also
* serves as an index in case the same password must be
* retrieved multiple times (multiprocess mode/restart).
* @param serial Serial number of the password - the watchdog will
* reprompt if serial is greater than the one from the
* last one it stored
* @param password Pointer to a string containing the password.
* @returns <code>PR_SUCCESS</code> if the password was received.
* <code>PR_FAILURE</code> indicates that there was an
* error.
*/
static PRStatus getPassword(const char *prompt, const PRInt32 serial,
char **password);
/**
* Tell the watchdog that the server is finished with its business.
*
* @returns <code>PR_SUCCESS</code> if that watchdog acknowledged the
* terminate message. <code>PR_FAILURE</code> indicates that
* there was an error.
*/
static PRStatus sendTerminate(void);
/**
* Returns whether or not the watchdog process is running.
*/
static PRBool isWDRunning(void);
/**
* Sends status from the reconfigure process to admin server via
* watchdog
*/
static PRStatus sendReconfigureStatus(char *statusmsg);
/**
* Indicates server has finished reconfigure process to watchdog
*/
static PRStatus sendReconfigureStatusDone();
/**
* Receive a message from the watchdog and return its message
* type.
*/
static WDMessages getAdminMessage(void);
/**
* Return the native file descriptor of the channel
*/
static int getFD(void);
/**
* Print message on terminal
*/
static PRStatus printMessage(const char *msg);
private:
/**
* The communication channel to the watchdog process over which
* commands are sent and responses received.
*/
static wdServerMessage* wdMsg_;
/**
* Indicates whether the watchdog process is running or not.
*/
static PRBool bIsWDRunning_;
/**
* Indicates whether the watchdog process is running or not.
*/
static PRInt32 wdPID_;
/**
* Unix domain socket to connect to
*/
static char* udsName_;
/**
* Connects to the watchdog process via the Unix domain socket.
*
* This method assumes that the watchdog process is listening on
* the Unix socket specified by <code>WDSOCKETNAME</code>.
*
* @returns <code>PR_SUCCESS</code> if the creation was successful.
* <code>PR_FAILURE</code> if an error occurred while
* connecting to the watchdog.
*/
static PRStatus connectToWD(const PRInt32 pid);
// Closes the specified connection to the watchdog
static PRStatus closeWDConnection(wdServerMessage* wdConnection);
};
inline
PRBool
WatchdogClient::isWDRunning(void)
{
return WatchdogClient::bIsWDRunning_;
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern PRStatus cpp_call_WatchdogClient_init();
extern PRStatus cpp_call_WatchdogClient_sendEndInit(int numProcs);
extern char * cpp_call_WatchdogClient_getPassword(char *prompt, int serial);
extern PRStatus cpp_call_WatchdogClient_printMessage(char *msg);
extern PRStatus call_WatchdogClient_init();
extern PRStatus call_WatchdogClient_sendEndInit(int numProcs);
extern char * call_WatchdogClient_getPassword(char *prompt, int serial);
extern PRStatus call_WatchdogClient_printMessage(char *msg);
#ifdef __cplusplus
}
#endif
#endif /* _WatchdogClient_h_ */
|