summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-12 19:17:48 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-13 10:41:29 -0400
commit7f654a6a6fb5e956b996eece36ff95e590a6ad63 (patch)
treec9545f5af482e1380261a2fe7ba2e73b175b3b66 /src
parentdad12188a6ca957f6fde1eb602fd98b2fa93b1a4 (diff)
downloadtor-7f654a6a6fb5e956b996eece36ff95e590a6ad63.tar.gz
tor-7f654a6a6fb5e956b996eece36ff95e590a6ad63.zip
Add a ControlPortFileGroupWritable option
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c1
-rw-r--r--src/or/control.c8
-rw-r--r--src/or/or.h2
3 files changed, 11 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 5eb62291bc..a7ff28f462 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -206,6 +206,7 @@ static config_var_t _option_vars[] = {
V(ContactInfo, STRING, NULL),
V(ControlListenAddress, LINELIST, NULL),
V(ControlPort, PORT, "0"),
+ V(ControlPortFileGroupReadable,BOOL, "0"),
V(ControlPortWriteToFile, FILENAME, NULL),
V(ControlSocket, LINELIST, NULL),
V(CookieAuthentication, BOOL, "0"),
diff --git a/src/or/control.c b/src/or/control.c
index 634674233c..384e579f93 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -542,6 +542,14 @@ control_ports_write_to_file(void)
log_warn(LD_CONTROL, "Writing %s failed: %s",
options->ControlPortWriteToFile, strerror(errno));
}
+#ifndef MS_WINDOWS
+ if (options->ControlPortFileGroupReadable) {
+ if (chmod(options->ControlPortWriteToFile, 0640)) {
+ log_warn(LD_FS,"Unable to make %s group-readable.",
+ options->ControlPortWriteToFile);
+ }
+ }
+#endif
tor_free(joined);
SMARTLIST_FOREACH(lines, char *, cp, tor_free(cp));
smartlist_free(lines);
diff --git a/src/or/or.h b/src/or/or.h
index 412aac9822..a73d98ab74 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2876,6 +2876,8 @@ typedef struct {
/** File where we should write the ControlPort. */
char *ControlPortWriteToFile;
+ /** Should that file be group-readable? */
+ int ControlPortFileGroupReadable;
} or_options_t;