mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
Convert __OwningControllerFD to a 64-bit value
This lets us potentially use it for internal passing of windows sockets.
This commit is contained in:
parent
c77fe82155
commit
fe3bacf50a
@ -260,6 +260,9 @@ DUMMY_TYPECHECK_INSTANCE(or_options_t);
|
|||||||
VAR(#member, LINELIST_S, member ## _lines, NULL), \
|
VAR(#member, LINELIST_S, member ## _lines, NULL), \
|
||||||
VAR("__" #member, LINELIST_S, member ## _lines, NULL)
|
VAR("__" #member, LINELIST_S, member ## _lines, NULL)
|
||||||
|
|
||||||
|
/** UINT64_MAX as a decimal string */
|
||||||
|
#define UINT64_MAX_STRING "18446744073709551615"
|
||||||
|
|
||||||
/** Array of configuration options. Until we disallow nonstandard
|
/** Array of configuration options. Until we disallow nonstandard
|
||||||
* abbreviations, order is significant, since the first matching option will
|
* abbreviations, order is significant, since the first matching option will
|
||||||
* be chosen first.
|
* be chosen first.
|
||||||
@ -647,7 +650,7 @@ static config_var_t option_vars_[] = {
|
|||||||
VAR("__HashedControlSessionPassword", LINELIST, HashedControlSessionPassword,
|
VAR("__HashedControlSessionPassword", LINELIST, HashedControlSessionPassword,
|
||||||
NULL),
|
NULL),
|
||||||
VAR("__OwningControllerProcess",STRING,OwningControllerProcess, NULL),
|
VAR("__OwningControllerProcess",STRING,OwningControllerProcess, NULL),
|
||||||
VAR("__OwningControllerFD",INT,OwningControllerFD, "-1"),
|
VAR("__OwningControllerFD", UINT64, OwningControllerFD, UINT64_MAX_STRING),
|
||||||
V(MinUptimeHidServDirectoryV2, INTERVAL, "96 hours"),
|
V(MinUptimeHidServDirectoryV2, INTERVAL, "96 hours"),
|
||||||
V(TestingServerDownloadInitialDelay, CSV_INTERVAL, "0"),
|
V(TestingServerDownloadInitialDelay, CSV_INTERVAL, "0"),
|
||||||
V(TestingClientDownloadInitialDelay, CSV_INTERVAL, "0"),
|
V(TestingClientDownloadInitialDelay, CSV_INTERVAL, "0"),
|
||||||
@ -1948,12 +1951,8 @@ options_act(const or_options_t *old_options)
|
|||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (running_tor && !old_options && options->OwningControllerFD != -1) {
|
if (running_tor && !old_options &&
|
||||||
#ifdef _WIN32
|
options->OwningControllerFD != UINT64_MAX) {
|
||||||
log_warn(LD_CONFIG, "OwningControllerFD is not supported on Windows. "
|
|
||||||
"If you need it, tell the Tor developers.");
|
|
||||||
return -1;
|
|
||||||
#else
|
|
||||||
const unsigned ctrl_flags =
|
const unsigned ctrl_flags =
|
||||||
CC_LOCAL_FD_IS_OWNER |
|
CC_LOCAL_FD_IS_OWNER |
|
||||||
CC_LOCAL_FD_IS_AUTHENTICATED;
|
CC_LOCAL_FD_IS_AUTHENTICATED;
|
||||||
@ -1963,7 +1962,6 @@ options_act(const or_options_t *old_options)
|
|||||||
"given FD.");
|
"given FD.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif /* defined(_WIN32) */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load state */
|
/* Load state */
|
||||||
@ -8197,6 +8195,7 @@ getinfo_helper_config(control_connection_t *conn,
|
|||||||
case CONFIG_TYPE_STRING: type = "String"; break;
|
case CONFIG_TYPE_STRING: type = "String"; break;
|
||||||
case CONFIG_TYPE_FILENAME: type = "Filename"; break;
|
case CONFIG_TYPE_FILENAME: type = "Filename"; break;
|
||||||
case CONFIG_TYPE_UINT: type = "Integer"; break;
|
case CONFIG_TYPE_UINT: type = "Integer"; break;
|
||||||
|
case CONFIG_TYPE_UINT64: type = "Integer"; break;
|
||||||
case CONFIG_TYPE_INT: type = "SignedInteger"; break;
|
case CONFIG_TYPE_INT: type = "SignedInteger"; break;
|
||||||
case CONFIG_TYPE_PORT: type = "Port"; break;
|
case CONFIG_TYPE_PORT: type = "Port"; break;
|
||||||
case CONFIG_TYPE_INTERVAL: type = "TimeInterval"; break;
|
case CONFIG_TYPE_INTERVAL: type = "TimeInterval"; break;
|
||||||
|
@ -195,6 +195,19 @@ config_assign_value(const config_format_t *fmt, void *options,
|
|||||||
*(int *)lvalue = i;
|
*(int *)lvalue = i;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CONFIG_TYPE_UINT64: {
|
||||||
|
uint64_t u64 = tor_parse_uint64(c->value, 10,
|
||||||
|
0, UINT64_MAX, &ok, NULL);
|
||||||
|
if (!ok) {
|
||||||
|
tor_asprintf(msg,
|
||||||
|
"uint64 keyword '%s %s' is malformed or out of bounds.",
|
||||||
|
c->key, c->value);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*(uint64_t *)lvalue = u64;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case CONFIG_TYPE_CSV_INTERVAL: {
|
case CONFIG_TYPE_CSV_INTERVAL: {
|
||||||
/* We used to have entire smartlists here. But now that all of our
|
/* We used to have entire smartlists here. But now that all of our
|
||||||
* download schedules use exponential backoff, only the first part
|
* download schedules use exponential backoff, only the first part
|
||||||
@ -574,6 +587,7 @@ config_get_assigned_option(const config_format_t *fmt, const void *options,
|
|||||||
tor_asprintf(&result->value, "%d", *(int*)value);
|
tor_asprintf(&result->value, "%d", *(int*)value);
|
||||||
escape_val = 0; /* Can't need escape. */
|
escape_val = 0; /* Can't need escape. */
|
||||||
break;
|
break;
|
||||||
|
case CONFIG_TYPE_UINT64: /* Fall through */
|
||||||
case CONFIG_TYPE_MEMUNIT:
|
case CONFIG_TYPE_MEMUNIT:
|
||||||
tor_asprintf(&result->value, "%"PRIu64,
|
tor_asprintf(&result->value, "%"PRIu64,
|
||||||
(*(uint64_t*)value));
|
(*(uint64_t*)value));
|
||||||
@ -781,6 +795,7 @@ config_clear(const config_format_t *fmt, void *options,
|
|||||||
case CONFIG_TYPE_AUTOBOOL:
|
case CONFIG_TYPE_AUTOBOOL:
|
||||||
*(int*)lvalue = -1;
|
*(int*)lvalue = -1;
|
||||||
break;
|
break;
|
||||||
|
case CONFIG_TYPE_UINT64:
|
||||||
case CONFIG_TYPE_MEMUNIT:
|
case CONFIG_TYPE_MEMUNIT:
|
||||||
*(uint64_t*)lvalue = 0;
|
*(uint64_t*)lvalue = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -19,6 +19,7 @@ typedef enum config_type_t {
|
|||||||
CONFIG_TYPE_FILENAME, /**< A filename: some prefixes get expanded. */
|
CONFIG_TYPE_FILENAME, /**< A filename: some prefixes get expanded. */
|
||||||
CONFIG_TYPE_UINT, /**< A non-negative integer less than MAX_INT */
|
CONFIG_TYPE_UINT, /**< A non-negative integer less than MAX_INT */
|
||||||
CONFIG_TYPE_INT, /**< Any integer. */
|
CONFIG_TYPE_INT, /**< Any integer. */
|
||||||
|
CONFIG_TYPE_UINT64, /**< A value in range 0..UINT64_MAX */
|
||||||
CONFIG_TYPE_PORT, /**< A port from 1...65535, 0 for "not set", or
|
CONFIG_TYPE_PORT, /**< A port from 1...65535, 0 for "not set", or
|
||||||
* "auto". */
|
* "auto". */
|
||||||
CONFIG_TYPE_INTERVAL, /**< A number of seconds, with optional units*/
|
CONFIG_TYPE_INTERVAL, /**< A number of seconds, with optional units*/
|
||||||
@ -60,6 +61,7 @@ typedef union {
|
|||||||
* "UINT", it still uses the C int type -- it just enforces that
|
* "UINT", it still uses the C int type -- it just enforces that
|
||||||
* the values are in range [0,INT_MAX].
|
* the values are in range [0,INT_MAX].
|
||||||
*/
|
*/
|
||||||
|
uint64_t *UINT64;
|
||||||
int *INT;
|
int *INT;
|
||||||
int *PORT;
|
int *PORT;
|
||||||
int *INTERVAL;
|
int *INTERVAL;
|
||||||
|
@ -514,7 +514,7 @@ struct or_options_t {
|
|||||||
* instance. Tor will terminate if its owning controller does. */
|
* instance. Tor will terminate if its owning controller does. */
|
||||||
char *OwningControllerProcess;
|
char *OwningControllerProcess;
|
||||||
/** FD specifier for a controller that owns this Tor instance. */
|
/** FD specifier for a controller that owns this Tor instance. */
|
||||||
int OwningControllerFD;
|
uint64_t OwningControllerFD;
|
||||||
|
|
||||||
int ShutdownWaitLength; /**< When we get a SIGINT and we're a server, how
|
int ShutdownWaitLength; /**< When we get a SIGINT and we're a server, how
|
||||||
* long do we wait before exiting? */
|
* long do we wait before exiting? */
|
||||||
|
Loading…
Reference in New Issue
Block a user