git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@2413 e7ae566f-a301-0410-adde-c780ea21d3b5
james authored on 2007/10/23 04:12:54... | ... |
@@ -2468,6 +2468,7 @@ open_management (struct context *c) |
2468 | 2468 |
c->options.management_echo_buffer_size, |
2469 | 2469 |
c->options.management_state_buffer_size, |
2470 | 2470 |
c->options.management_hold, |
2471 |
+ c->options.management_signal, |
|
2471 | 2472 |
c->options.management_client, |
2472 | 2473 |
c->options.management_write_peer_info_file, |
2473 | 2474 |
c->options.remap_sigusr1)) |
... | ... |
@@ -1080,6 +1080,15 @@ man_reset_client_socket (struct management *man, const bool exiting) |
1080 | 1080 |
} |
1081 | 1081 |
if (!exiting) |
1082 | 1082 |
{ |
1083 |
+ if (man->settings.signal_on_disconnect) { |
|
1084 |
+ int mysig = man_mod_signal (man, SIGUSR1); |
|
1085 |
+ if (mysig >= 0) |
|
1086 |
+ { |
|
1087 |
+ msg (D_MANAGEMENT, "MANAGEMENT: Triggering management signal"); |
|
1088 |
+ throw_signal_soft (mysig, "management-disconnect"); |
|
1089 |
+ } |
|
1090 |
+ } |
|
1091 |
+ |
|
1083 | 1092 |
if (man->settings.connect_as_client) |
1084 | 1093 |
{ |
1085 | 1094 |
msg (D_MANAGEMENT, "MANAGEMENT: Triggering management exit"); |
... | ... |
@@ -1323,6 +1332,7 @@ man_settings_init (struct man_settings *ms, |
1323 | 1323 |
const int echo_buffer_size, |
1324 | 1324 |
const int state_buffer_size, |
1325 | 1325 |
const bool hold, |
1326 |
+ const bool signal_on_disconnect, |
|
1326 | 1327 |
const bool connect_as_client, |
1327 | 1328 |
const char *write_peer_info_file, |
1328 | 1329 |
const int remap_sigusr1) |
... | ... |
@@ -1355,6 +1365,12 @@ man_settings_init (struct man_settings *ms, |
1355 | 1355 |
ms->hold = hold; |
1356 | 1356 |
|
1357 | 1357 |
/* |
1358 |
+ * Should OpenVPN be signaled if management |
|
1359 |
+ * disconnects? |
|
1360 |
+ */ |
|
1361 |
+ ms->signal_on_disconnect = signal_on_disconnect; |
|
1362 |
+ |
|
1363 |
+ /* |
|
1358 | 1364 |
* Should OpenVPN connect to management interface as a client |
1359 | 1365 |
* rather than a server? |
1360 | 1366 |
*/ |
... | ... |
@@ -1496,6 +1512,7 @@ management_open (struct management *man, |
1496 | 1496 |
const int echo_buffer_size, |
1497 | 1497 |
const int state_buffer_size, |
1498 | 1498 |
const bool hold, |
1499 |
+ const bool signal_on_disconnect, |
|
1499 | 1500 |
const bool connect_as_client, |
1500 | 1501 |
const char *write_peer_info_file, |
1501 | 1502 |
const int remap_sigusr1) |
... | ... |
@@ -1516,6 +1533,7 @@ management_open (struct management *man, |
1516 | 1516 |
echo_buffer_size, |
1517 | 1517 |
state_buffer_size, |
1518 | 1518 |
hold, |
1519 |
+ signal_on_disconnect, |
|
1519 | 1520 |
connect_as_client, |
1520 | 1521 |
write_peer_info_file, |
1521 | 1522 |
remap_sigusr1); |
... | ... |
@@ -205,6 +205,7 @@ struct man_settings { |
205 | 205 |
int state_buffer_size; |
206 | 206 |
bool server; |
207 | 207 |
bool hold; |
208 |
+ bool signal_on_disconnect; |
|
208 | 209 |
bool connect_as_client; |
209 | 210 |
char *write_peer_info_file; |
210 | 211 |
|
... | ... |
@@ -281,6 +282,7 @@ bool management_open (struct management *man, |
281 | 281 |
const int echo_buffer_size, |
282 | 282 |
const int state_buffer_size, |
283 | 283 |
const bool hold, |
284 |
+ const bool signal_on_disconnect, |
|
284 | 285 |
const bool connect_as_client, |
285 | 286 |
const char *write_peer_info_file, |
286 | 287 |
const int remap_sigusr1); |
... | ... |
@@ -178,6 +178,7 @@ openvpn \- secure IP tunnel daemon. |
178 | 178 |
[\ \fB\-\-lport\fR\ \fIport\fR\ ] |
179 | 179 |
[\ \fB\-\-management\-hold\fR\ ] |
180 | 180 |
[\ \fB\-\-management\-log\-cache\fR\ \fIn\fR\ ] |
181 |
+[\ \fB\-\-management\-signal\fR\ ] |
|
181 | 182 |
[\ \fB\-\-management\-query\-passwords\fR\ ] |
182 | 183 |
[\ \fB\-\-management\fR\ \fIIP\ port\ [pw\-file]\fR\ ] |
183 | 184 |
[\ \fB\-\-max\-clients\fR\ \fIn\fR\ ] |
... | ... |
@@ -2327,6 +2328,12 @@ with the |
2327 | 2327 |
command. |
2328 | 2328 |
.\"********************************************************* |
2329 | 2329 |
.TP |
2330 |
+.B --management-signal |
|
2331 |
+Send SIGUSR1 signal to OpenVPN if management session disconnects. |
|
2332 |
+This is useful when you wish to disconnect an OpenVPN session on |
|
2333 |
+user logoff. |
|
2334 |
+.\"********************************************************* |
|
2335 |
+.TP |
|
2330 | 2336 |
.B --management-log-cache n |
2331 | 2337 |
Cache the most recent |
2332 | 2338 |
.B n |
... | ... |
@@ -311,6 +311,7 @@ static const char usage_message[] = |
311 | 311 |
" and auth-user-pass passwords.\n" |
312 | 312 |
"--management-hold : Start " PACKAGE_NAME " in a hibernating state, until a client\n" |
313 | 313 |
" of the management interface explicitly starts it.\n" |
314 |
+ "--management-signal : Issue SIGUSR1 when management disconnect event occurs.\n" |
|
314 | 315 |
"--management-log-cache n : Cache n lines of log file history for usage\n" |
315 | 316 |
" by the management channel.\n" |
316 | 317 |
#endif |
... | ... |
@@ -1200,6 +1201,7 @@ show_settings (const struct options *o) |
1200 | 1200 |
SHOW_BOOL (management_query_passwords); |
1201 | 1201 |
SHOW_BOOL (management_hold); |
1202 | 1202 |
SHOW_BOOL (management_client); |
1203 |
+ SHOW_BOOL (management_signal); |
|
1203 | 1204 |
SHOW_STR (management_write_peer_info_file); |
1204 | 1205 |
#endif |
1205 | 1206 |
#ifdef ENABLE_PLUGIN |
... | ... |
@@ -1527,7 +1529,7 @@ options_postprocess (struct options *options, bool first_time) |
1527 | 1527 |
*/ |
1528 | 1528 |
#ifdef ENABLE_MANAGEMENT |
1529 | 1529 |
if (!options->management_addr && |
1530 |
- (options->management_query_passwords || options->management_hold |
|
1530 |
+ (options->management_query_passwords || options->management_hold || options->management_signal |
|
1531 | 1531 |
|| options->management_client || options->management_write_peer_info_file |
1532 | 1532 |
|| options->management_log_history_cache != defaults.management_log_history_cache)) |
1533 | 1533 |
msg (M_USAGE, "--management is not specified, however one or more options which modify the behavior of --management were specified"); |
... | ... |
@@ -3164,6 +3166,11 @@ add_option (struct options *options, |
3164 | 3164 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
3165 | 3165 |
options->management_hold = true; |
3166 | 3166 |
} |
3167 |
+ else if (streq (p[0], "management-signal")) |
|
3168 |
+ { |
|
3169 |
+ VERIFY_PERMISSION (OPT_P_GENERAL); |
|
3170 |
+ options->management_signal = true; |
|
3171 |
+ } |
|
3167 | 3172 |
else if (streq (p[0], "management-client")) |
3168 | 3173 |
{ |
3169 | 3174 |
VERIFY_PERMISSION (OPT_P_GENERAL); |