Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sergi
Tor
Commits
6141097f
Commit
6141097f
authored
20 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in saving onion keys to disk when rotating; also survive short-term shutdowns better
svn:r2206
parent
e6c34ad0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/or/router.c
+17
-10
17 additions, 10 deletions
src/or/router.c
with
17 additions
and
10 deletions
src/or/router.c
+
17
−
10
View file @
6141097f
...
...
@@ -98,8 +98,11 @@ crypto_pk_env_t *get_identity_key(void) {
void
rotate_onion_key
(
void
)
{
char
fname
[
512
];
char
fname_prev
[
512
];
crypto_pk_env_t
*
prkey
;
sprintf
(
fname
,
"%s/keys/onion.key"
,
get_data_directory
(
&
options
));
sprintf
(
fname
,
"%s/keys/secret_onion_key"
,
get_data_directory
(
&
options
));
sprintf
(
fname_prev
,
"%s/keys/secret_onion_key.old"
,
get_data_directory
(
&
options
));
if
(
!
(
prkey
=
crypto_new_pk_env
()))
{
log
(
LOG_ERR
,
"Error creating crypto environment."
);
goto
error
;
...
...
@@ -108,6 +111,10 @@ void rotate_onion_key(void)
log
(
LOG_ERR
,
"Error generating onion key"
);
goto
error
;
}
if
(
file_status
(
fname
)
==
FN_FILE
)
{
if
(
replace_file
(
fname
,
fname_prev
))
goto
error
;
}
if
(
crypto_pk_write_private_key_to_filename
(
prkey
,
fname
))
{
log
(
LOG_ERR
,
"Couldn't write generated key to %s."
,
fname
);
goto
error
;
...
...
@@ -144,15 +151,9 @@ static crypto_pk_env_t *
init_key_from_file_name_changed
(
const
char
*
fname_old
,
const
char
*
fname_new
)
{
int
fs
;
fs
=
file_status
(
fname_new
);
if
(
fs
==
FN_FILE
)
/* The new filename is there. */
return
init_key_from_file
(
fname_new
);
fs
=
file_status
(
fname_old
);
if
(
fs
!=
FN_FILE
)
/* There is no key under either name. */
if
(
file_status
(
fname_new
)
==
FN_FILE
||
file_status
(
fname_old
)
!=
FN_FILE
)
/* The new filename is there, or both are, or neither is. */
return
init_key_from_file
(
fname_new
);
/* The old filename exists, and the new one doesn't. Rename and load. */
...
...
@@ -284,6 +285,12 @@ int init_keys(void) {
prkey
=
init_key_from_file_name_changed
(
keydir
,
keydir2
);
if
(
!
prkey
)
return
-
1
;
set_onion_key
(
prkey
);
sprintf
(
keydir
,
"%s/keys/secret_onion_key.old"
,
datadir
);
if
(
file_status
(
keydir
)
==
FN_FILE
)
{
prkey
=
init_key_from_file
(
keydir
);
if
(
prkey
)
lastonionkey
=
prkey
;
}
/* 3. Initialize link key and TLS context. */
if
(
tor_tls_context_new
(
get_identity_key
(),
1
,
options
.
Nickname
,
...
...
@@ -620,7 +627,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
/* How busy have we been? */
bandwidth_usage
=
rep_hist_get_bandwidth_lines
();
/* Generate the easy portion of the router descriptor. */
result
=
snprintf
(
s
,
maxlen
,
"router %s %s %d %d %d
\n
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment