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
Container Registry
Model registry
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
The Tor Project
Core
Tor
Commits
ecf414f0
Commit
ecf414f0
authored
20 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Stop using separate defaults for no-config-file and empty-config-file
svn:r2329
parent
d6e47bec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/or/config.c
+20
-17
20 additions, 17 deletions
src/or/config.c
src/or/main.c
+4
-1
4 additions, 1 deletion
src/or/main.c
with
24 additions
and
18 deletions
src/or/config.c
+
20
−
17
View file @
ecf414f0
...
...
@@ -29,7 +29,7 @@ typedef enum config_type_t {
#define CONFIG_LINE_T_MAXLEN 4096
static
struct
config_line_t
*
config_get_commandlines
(
int
argc
,
char
**
argv
);
static
struc
t
config_
line_
t
*
config_
get_lines
(
FILE
*
f
);
static
in
t
config_
get_lines
(
FILE
*
f
,
struc
t
config_
line_t
**
result
);
static
void
config_free_lines
(
struct
config_line_t
*
front
);
static
int
config_compare
(
struct
config_line_t
*
c
,
const
char
*
key
,
config_type_t
type
,
void
*
arg
);
static
int
config_assign
(
or_options_t
*
options
,
struct
config_line_t
*
list
);
...
...
@@ -80,21 +80,27 @@ config_line_prepend(struct config_line_t *front,
}
/** Helper: parse the config file and strdup into key/value
* strings. Return list, or NULL if parsing the file failed. Warn and
* ignore any misformatted lines. */
static
struct
config_line_t
*
config_get_lines
(
FILE
*
f
)
{
* strings. Set *result to the list, or NULL if parsing the file
* failed. Return 0 on success, -1 on failure. Warn and ignore any
* misformatted lines. */
static
int
config_get_lines
(
FILE
*
f
,
struct
config_line_t
**
result
)
{
struct
config_line_t
*
front
=
NULL
;
char
line
[
CONFIG_LINE_T_MAXLEN
];
int
r
esult
;
int
r
;
char
*
key
,
*
value
;
while
(
(
r
esult
=
parse_line_from_file
(
line
,
sizeof
(
line
),
f
,
&
key
,
&
value
))
>
0
)
{
while
(
(
r
=
parse_line_from_file
(
line
,
sizeof
(
line
),
f
,
&
key
,
&
value
))
>
0
)
{
front
=
config_line_prepend
(
front
,
key
,
value
);
}
if
(
result
<
0
)
return
NULL
;
return
front
;
if
(
r
<
0
)
{
*
result
=
NULL
;
return
-
1
;
}
else
{
*
result
=
front
;
return
0
;
}
}
/**
...
...
@@ -396,9 +402,6 @@ static int config_assign_defaults(or_options_t *options) {
config_free_lines
(
options
->
ExitPolicy
);
options
->
ExitPolicy
=
config_line_prepend
(
NULL
,
"ExitPolicy"
,
"reject *:*"
);
/* plus give them a dirservers file */
if
(
config_assign_default_dirservers
()
<
0
)
return
-
1
;
return
0
;
}
...
...
@@ -656,14 +659,14 @@ int getconfig(int argc, char **argv, or_options_t *options) {
tor_assert
(
fname
);
log
(
LOG_DEBUG
,
"Opening config file '%s'"
,
fname
);
if
(
config_assign_defaults
(
options
)
<
0
)
{
return
-
1
;
}
cf
=
fopen
(
fname
,
"r"
);
if
(
!
cf
)
{
if
(
using_default_torrc
==
1
)
{
log
(
LOG_NOTICE
,
"Configuration file '%s' not present, using reasonable defaults."
,
fname
);
tor_free
(
fname
);
if
(
config_assign_defaults
(
options
)
<
0
)
{
return
-
1
;
}
}
else
{
log
(
LOG_WARN
,
"Unable to open configuration file '%s'."
,
fname
);
tor_free
(
fname
);
...
...
@@ -671,8 +674,8 @@ int getconfig(int argc, char **argv, or_options_t *options) {
}
}
else
{
/* it opened successfully. use it. */
tor_free
(
fname
);
cl
=
config_get_lines
(
cf
)
;
if
(
!
cl
)
return
-
1
;
if
(
config_get_lines
(
cf
,
&
cl
)
<
0
)
return
-
1
;
if
(
config_assign
(
options
,
cl
)
<
0
)
return
-
1
;
config_free_lines
(
cl
);
...
...
This diff is collapsed.
Click to expand it.
src/or/main.c
+
4
−
1
View file @
ecf414f0
...
...
@@ -781,13 +781,16 @@ static int do_main_loop(void) {
return
-
1
;
}
/* load the routers file */
/* load the routers file
, or assign the defaults.
*/
if
(
options
.
RouterFile
)
{
routerlist_clear_trusted_directories
();
if
(
router_load_routerlist_from_file
(
options
.
RouterFile
,
1
)
<
0
)
{
log_fn
(
LOG_ERR
,
"Error loading router list."
);
return
-
1
;
}
}
else
{
if
(
config_assign_default_dirservers
()
<
0
)
return
-
1
;
}
if
(
authdir_mode
())
{
...
...
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