config.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. /* Copyright 2001,2002,2003 Roger Dingledine, Matej Pfajfar. */
  2. /* See LICENSE for licensing information */
  3. /* $Id$ */
  4. /**
  5. * /file config.c
  6. *
  7. * /brief Code to parse and interpret configuration files.
  8. *
  9. **/
  10. #include "or.h"
  11. #ifdef MS_WINDOWS
  12. #include <shlobj.h>
  13. #endif
  14. /** Enumeration of types which option values can take */
  15. typedef enum config_type_t {
  16. CONFIG_TYPE_STRING = 0, /**< An arbitrary string. */
  17. CONFIG_TYPE_INT, /**< An integer */
  18. CONFIG_TYPE_DOUBLE, /**< A floating-point value */
  19. CONFIG_TYPE_BOOL, /**< A boolean value, expressed as 0 or 1. */
  20. CONFIG_TYPE_CSV, /**< A list of strings, separated by commas and optional
  21. * whitespace. */
  22. CONFIG_TYPE_LINELIST, /**< Uninterpreted config lines */
  23. } config_type_t;
  24. /** Largest allowed config line */
  25. #define CONFIG_LINE_T_MAXLEN 4096
  26. static struct config_line_t *config_get_commandlines(int argc, char **argv);
  27. static struct config_line_t *config_get_lines(FILE *f);
  28. static void config_free_lines(struct config_line_t *front);
  29. static int config_compare(struct config_line_t *c, const char *key, config_type_t type, void *arg);
  30. static int config_assign(or_options_t *options, struct config_line_t *list);
  31. /** Helper: Read a list of configuration options from the command line. */
  32. static struct config_line_t *config_get_commandlines(int argc, char **argv) {
  33. struct config_line_t *new;
  34. struct config_line_t *front = NULL;
  35. char *s;
  36. int i = 1;
  37. while(i < argc-1) {
  38. if(!strcmp(argv[i],"-f")) {
  39. // log(LOG_DEBUG,"Commandline: skipping over -f.");
  40. i+=2; /* this is the config file option. ignore it. */
  41. continue;
  42. }
  43. new = tor_malloc(sizeof(struct config_line_t));
  44. s = argv[i];
  45. while(*s == '-')
  46. s++;
  47. new->key = tor_strdup(s);
  48. new->value = tor_strdup(argv[i+1]);
  49. log(LOG_DEBUG,"Commandline: parsed keyword '%s', value '%s'",
  50. new->key, new->value);
  51. new->next = front;
  52. front = new;
  53. i += 2;
  54. }
  55. return front;
  56. }
  57. /** Helper: allocate a new configuration option mapping 'key' to 'val',
  58. * prepend it to 'front', and return the newly allocated config_line_t */
  59. static struct config_line_t *
  60. config_line_prepend(struct config_line_t *front,
  61. const char *key,
  62. const char *val)
  63. {
  64. struct config_line_t *newline;
  65. newline = tor_malloc(sizeof(struct config_line_t));
  66. newline->key = tor_strdup(key);
  67. newline->value = tor_strdup(val);
  68. newline->next = front;
  69. return newline;
  70. }
  71. /** Helper: parse the config file and strdup into key/value
  72. * strings. Return list, or NULL if parsing the file failed. Warn and
  73. * ignore any misformatted lines. */
  74. static struct config_line_t *config_get_lines(FILE *f) {
  75. struct config_line_t *front = NULL;
  76. char line[CONFIG_LINE_T_MAXLEN];
  77. int result;
  78. char *key, *value;
  79. while( (result=parse_line_from_file(line,sizeof(line),f,&key,&value)) > 0) {
  80. front = config_line_prepend(front, key, value);
  81. }
  82. if(result < 0)
  83. return NULL;
  84. return front;
  85. }
  86. /**
  87. * Free all the configuration lines on the linked list <b>front</b>.
  88. */
  89. static void config_free_lines(struct config_line_t *front) {
  90. struct config_line_t *tmp;
  91. while(front) {
  92. tmp = front;
  93. front = tmp->next;
  94. free(tmp->key);
  95. free(tmp->value);
  96. free(tmp);
  97. }
  98. }
  99. /** Search the linked list <b>c</b> for any option whose key is <b>key</b>.
  100. * If such an option is found, interpret it as of type <b>type</b>, and store
  101. * the result in <b>arg</b>. If the option is misformatted, log a warning and
  102. * skip it.
  103. */
  104. static int config_compare(struct config_line_t *c, const char *key, config_type_t type, void *arg) {
  105. int i;
  106. if(strncasecmp(c->key,key,strlen(c->key)))
  107. return 0;
  108. if(strcasecmp(c->key,key)) {
  109. tor_free(c->key);
  110. c->key = tor_strdup(key);
  111. }
  112. /* it's a match. cast and assign. */
  113. log_fn(LOG_DEBUG,"Recognized keyword '%s' as %s, using value '%s'.",c->key,key,c->value);
  114. switch(type) {
  115. case CONFIG_TYPE_INT:
  116. *(int *)arg = atoi(c->value);
  117. break;
  118. case CONFIG_TYPE_BOOL:
  119. i = atoi(c->value);
  120. if (i != 0 && i != 1) {
  121. log(LOG_WARN, "Boolean keyword '%s' expects 0 or 1", c->key);
  122. return 0;
  123. }
  124. *(int *)arg = i;
  125. break;
  126. case CONFIG_TYPE_STRING:
  127. tor_free(*(char **)arg);
  128. *(char **)arg = tor_strdup(c->value);
  129. break;
  130. case CONFIG_TYPE_DOUBLE:
  131. *(double *)arg = atof(c->value);
  132. break;
  133. case CONFIG_TYPE_CSV:
  134. if(*(smartlist_t**)arg == NULL)
  135. *(smartlist_t**)arg = smartlist_create();
  136. smartlist_split_string(*(smartlist_t**)arg, c->value, ",", 1);
  137. break;
  138. case CONFIG_TYPE_LINELIST:
  139. /* Note: this reverses the order that the lines appear in. That's
  140. * just fine, since we build up the list of lines reversed in the
  141. * first place. */
  142. *(struct config_line_t**)arg =
  143. config_line_prepend(*(struct config_line_t**)arg, c->key, c->value);
  144. break;
  145. }
  146. return 1;
  147. }
  148. /** Iterate through the linked list of options <b>list</b>.
  149. * For each item, convert as appropriate and assign to <b>options</b>.
  150. * If an item is unrecognized, return -1 immediately,
  151. * else return 0 for success. */
  152. static int config_assign(or_options_t *options, struct config_line_t *list) {
  153. while(list) {
  154. if(
  155. /* order matters here! abbreviated arguments use the first match. */
  156. /* string options */
  157. config_compare(list, "Address", CONFIG_TYPE_STRING, &options->Address) ||
  158. config_compare(list, "AllowUnverifiedNodes", CONFIG_TYPE_CSV, &options->AllowUnverifiedNodes) ||
  159. config_compare(list, "AuthoritativeDirectory",CONFIG_TYPE_BOOL, &options->AuthoritativeDir) ||
  160. config_compare(list, "BandwidthRate", CONFIG_TYPE_INT, &options->BandwidthRate) ||
  161. config_compare(list, "BandwidthBurst", CONFIG_TYPE_INT, &options->BandwidthBurst) ||
  162. config_compare(list, "ClientOnly", CONFIG_TYPE_BOOL, &options->ClientOnly) ||
  163. config_compare(list, "ContactInfo", CONFIG_TYPE_STRING, &options->ContactInfo) ||
  164. config_compare(list, "DebugLogFile", CONFIG_TYPE_STRING, &options->DebugLogFile) ||
  165. config_compare(list, "DataDirectory", CONFIG_TYPE_STRING, &options->DataDirectory) ||
  166. config_compare(list, "DirPort", CONFIG_TYPE_INT, &options->DirPort) ||
  167. config_compare(list, "DirBindAddress", CONFIG_TYPE_LINELIST, &options->DirBindAddress) ||
  168. config_compare(list, "DirFetchPostPeriod",CONFIG_TYPE_INT, &options->DirFetchPostPeriod) ||
  169. config_compare(list, "ExitNodes", CONFIG_TYPE_STRING, &options->ExitNodes) ||
  170. config_compare(list, "EntryNodes", CONFIG_TYPE_STRING, &options->EntryNodes) ||
  171. config_compare(list, "StrictExitNodes", CONFIG_TYPE_BOOL, &options->StrictExitNodes) ||
  172. config_compare(list, "StrictEntryNodes", CONFIG_TYPE_BOOL, &options->StrictEntryNodes) ||
  173. config_compare(list, "ExitPolicy", CONFIG_TYPE_LINELIST, &options->ExitPolicy) ||
  174. config_compare(list, "ExcludeNodes", CONFIG_TYPE_STRING, &options->ExcludeNodes) ||
  175. config_compare(list, "FascistFirewall",CONFIG_TYPE_BOOL, &options->FascistFirewall) ||
  176. config_compare(list, "FirewallPorts",CONFIG_TYPE_CSV, &options->FirewallPorts) ||
  177. config_compare(list, "Group", CONFIG_TYPE_STRING, &options->Group) ||
  178. config_compare(list, "HiddenServiceDir", CONFIG_TYPE_LINELIST, &options->RendConfigLines)||
  179. config_compare(list, "HiddenServicePort", CONFIG_TYPE_LINELIST, &options->RendConfigLines)||
  180. config_compare(list, "HiddenServiceNodes", CONFIG_TYPE_LINELIST, &options->RendConfigLines)||
  181. config_compare(list, "HiddenServiceExcludeNodes", CONFIG_TYPE_LINELIST, &options->RendConfigLines)||
  182. config_compare(list, "IgnoreVersion", CONFIG_TYPE_BOOL, &options->IgnoreVersion) ||
  183. config_compare(list, "KeepalivePeriod",CONFIG_TYPE_INT, &options->KeepalivePeriod) ||
  184. config_compare(list, "LogLevel", CONFIG_TYPE_LINELIST, &options->LogOptions) ||
  185. config_compare(list, "LogFile", CONFIG_TYPE_LINELIST, &options->LogOptions) ||
  186. config_compare(list, "LinkPadding", CONFIG_TYPE_BOOL, &options->LinkPadding) ||
  187. config_compare(list, "MaxConn", CONFIG_TYPE_INT, &options->MaxConn) ||
  188. config_compare(list, "MaxOnionsPending",CONFIG_TYPE_INT, &options->MaxOnionsPending) ||
  189. config_compare(list, "Nickname", CONFIG_TYPE_STRING, &options->Nickname) ||
  190. config_compare(list, "NewCircuitPeriod",CONFIG_TYPE_INT, &options->NewCircuitPeriod) ||
  191. config_compare(list, "NumCpus", CONFIG_TYPE_INT, &options->NumCpus) ||
  192. config_compare(list, "ORPort", CONFIG_TYPE_INT, &options->ORPort) ||
  193. config_compare(list, "ORBindAddress", CONFIG_TYPE_LINELIST, &options->ORBindAddress) ||
  194. config_compare(list, "OutboundBindAddress",CONFIG_TYPE_STRING, &options->OutboundBindAddress) ||
  195. config_compare(list, "PidFile", CONFIG_TYPE_STRING, &options->PidFile) ||
  196. config_compare(list, "PathlenCoinWeight",CONFIG_TYPE_DOUBLE, &options->PathlenCoinWeight) ||
  197. config_compare(list, "RouterFile", CONFIG_TYPE_STRING, &options->RouterFile) ||
  198. config_compare(list, "RunAsDaemon", CONFIG_TYPE_BOOL, &options->RunAsDaemon) ||
  199. config_compare(list, "RunTesting", CONFIG_TYPE_BOOL, &options->RunTesting) ||
  200. config_compare(list, "RecommendedVersions",CONFIG_TYPE_STRING, &options->RecommendedVersions) ||
  201. config_compare(list, "RendNodes", CONFIG_TYPE_STRING, &options->RendNodes) ||
  202. config_compare(list, "RendExcludeNodes",CONFIG_TYPE_STRING, &options->RendExcludeNodes) ||
  203. config_compare(list, "SocksPort", CONFIG_TYPE_INT, &options->SocksPort) ||
  204. config_compare(list, "SocksBindAddress",CONFIG_TYPE_LINELIST,&options->SocksBindAddress) ||
  205. config_compare(list, "SocksPolicy", CONFIG_TYPE_LINELIST,&options->SocksPolicy) ||
  206. config_compare(list, "TrafficShaping", CONFIG_TYPE_BOOL, &options->TrafficShaping) ||
  207. config_compare(list, "User", CONFIG_TYPE_STRING, &options->User)
  208. ) {
  209. /* then we're ok. it matched something. */
  210. } else {
  211. log_fn(LOG_WARN,"Unknown keyword '%s'. Failing.",list->key);
  212. return -1;
  213. }
  214. list = list->next;
  215. }
  216. return 0;
  217. }
  218. const char default_dirservers_string[] =
  219. "router moria1 18.244.0.188 9001 9021 9031\n"
  220. "platform Tor 0.0.6rc1 on Linux moria.mit.edu i686\n"
  221. "published 2004-04-25 21:54:28\n"
  222. "bandwidth 800000 10000000\n"
  223. "onion-key\n"
  224. "-----BEGIN RSA PUBLIC KEY-----\n"
  225. "MIGJAoGBANoIvHieyHUTzIacbnWOnyTyzGrLOdXqbcjz2GGMxyHEd5K1bO1ZBNHP\n"
  226. "9i5qLQpN5viFk2K2rEGuG8tFgDEzSWZEtBqv3NVfUdiumdERWMBwlaQ0MVK4C+jf\n"
  227. "y5gZ8KI3o9ZictgPS1AQF+Kk932/vIHTuRIUKb4ILTnQilNvID0NAgMBAAE=\n"
  228. "-----END RSA PUBLIC KEY-----\n"
  229. "signing-key\n"
  230. "-----BEGIN RSA PUBLIC KEY-----\n"
  231. "MIGJAoGBAMHa0ZC/jo2Q2DrwKYF/6ZbmZ27PFYG91u4gUzzmZ/VXLpZ8wNzEV3oW\n"
  232. "nt+I61048fBiC1frT1/DZ351n2bLSk9zJbB6jyGZJn0380FPRX3+cXyXS0Gq8Ril\n"
  233. "xkhMQf5XuNFUb8UmYPSOH4WErjvYjKvU+gfjbK/82Jo9SuHpYz+BAgMBAAE=\n"
  234. "-----END RSA PUBLIC KEY-----\n"
  235. "reject 0.0.0.0/255.0.0.0:*\n"
  236. "reject 169.254.0.0/255.255.0.0:*\n"
  237. "reject 127.0.0.0/255.0.0.0:*\n"
  238. "reject 192.168.0.0/255.255.0.0:*\n"
  239. "reject 10.0.0.0/255.0.0.0:*\n"
  240. "reject 172.16.0.0/255.240.0.0:*\n"
  241. "accept *:20-22\n"
  242. "accept *:53\n"
  243. "accept *:79-80\n"
  244. "accept *:110\n"
  245. "accept *:143\n"
  246. "accept *:443\n"
  247. "accept *:873\n"
  248. "accept *:993\n"
  249. "accept *:995\n"
  250. "accept *:1024-65535\n"
  251. "reject *:*\n"
  252. "router-signature\n"
  253. "-----BEGIN SIGNATURE-----\n"
  254. "o1eAoRHDAEAXsnh5wN++vIwrupd+DbAJ2p3wxHDrmqxTpygzxxCnyQyhMfX03ua2\n"
  255. "4iplyNlwyFwzWcw0sk31otlO2HBYXT1V9G0YxGtKMOeOBMHjfGbUjGvEALHzWi4z\n"
  256. "8DXGJp13zgnUyP4ZA6xaGROwcT6oB5e7UlztvvpGxTg=\n"
  257. "-----END SIGNATURE-----\n"
  258. "\n"
  259. "router moria2 18.244.0.188 9002 9022 9032\n"
  260. "platform Tor 0.0.6rc1 on Linux moria.mit.edu i686\n"
  261. "published 2004-04-25 21:54:30\n"
  262. "bandwidth 800000 10000000\n"
  263. "onion-key\n"
  264. "-----BEGIN RSA PUBLIC KEY-----\n"
  265. "MIGJAoGBAM4Cc/npgYC54XrYLC+grVxJp7PDmNO2DRRJOxKttBBtvLpnR1UaueTi\n"
  266. "kyknT5kmlx+ihgZF/jmye//2dDUp2+kK/kSkpRV4xnDLXZmed+sNSQxqmm9TtZQ9\n"
  267. "/hjpxhp5J9HmUTYhntBs+4E4CUKokmrI6oRLoln4SA39AX9QLPcnAgMBAAE=\n"
  268. "-----END RSA PUBLIC KEY-----\n"
  269. "signing-key\n"
  270. "-----BEGIN RSA PUBLIC KEY-----\n"
  271. "MIGJAoGBAOcrht/y5rkaahfX7sMe2qnpqoPibsjTSJaDvsUtaNP/Bq0MgNDGOR48\n"
  272. "rtwfqTRff275Edkp/UYw3G3vSgKCJr76/bqOHCmkiZrnPV1zxNfrK18gNw2Cxre0\n"
  273. "nTA+fD8JQqpPtb8b0SnG9kwy75eS//sRu7TErie2PzGMxrf9LH0LAgMBAAE=\n"
  274. "-----END RSA PUBLIC KEY-----\n"
  275. "reject 0.0.0.0/255.0.0.0:*\n"
  276. "reject 169.254.0.0/255.255.0.0:*\n"
  277. "reject 127.0.0.0/255.0.0.0:*\n"
  278. "reject 192.168.0.0/255.255.0.0:*\n"
  279. "reject 10.0.0.0/255.0.0.0:*\n"
  280. "reject 172.16.0.0/255.240.0.0:*\n"
  281. "accept *:20-22\n"
  282. "accept *:53\n"
  283. "accept *:79-80\n"
  284. "accept *:110\n"
  285. "accept *:143\n"
  286. "accept *:443\n"
  287. "accept *:873\n"
  288. "accept *:993\n"
  289. "accept *:995\n"
  290. "accept *:1024-65535\n"
  291. "reject *:*\n"
  292. "router-signature\n"
  293. "-----BEGIN SIGNATURE-----\n"
  294. "RKROLwP1ExjTZeg6wuN0pzYqed9IJUd5lAe9hp4ritbnmJAgS6qfww6jgx61CfUR\n"
  295. "6SElhOLE7Q77jAdoL45Ji5pn/Y+Q+E+5lJm1E/ed9ha+YsOPaOc7z6GQ7E4mihCL\n"
  296. "gI1vsw92+P1Ty4RHj6fyD9DhbV19nh2Qs+pvGJOS2FY=\n"
  297. "-----END SIGNATURE-----\n"
  298. "\n"
  299. "router tor26 62.116.124.106 9001 9050 9030\n"
  300. "platform Tor 0.0.6 on Linux seppia i686\n"
  301. "published 2004-05-06 21:33:23\n"
  302. "bandwidth 500000 10000000\n"
  303. "onion-key\n"
  304. "-----BEGIN RSA PUBLIC KEY-----\n"
  305. "MIGJAoGBAMEHdDnpj3ik1AF1xe/VqjoguH2DbANifYqXXfempu0fS+tU9FGo6dU/\n"
  306. "fnVHAZwL9Ek9k2rMzumShi1RduK9p035R/Gk+PBBcLfvwYJ/Nat+ZO/L8jn/3bZe\n"
  307. "ieQd9CKj2LjNGKpRNry37vkwMGIOIlegwK+2us8aXJ7sIvlNts0TAgMBAAE=\n"
  308. "-----END RSA PUBLIC KEY-----\n"
  309. "signing-key\n"
  310. "-----BEGIN RSA PUBLIC KEY-----\n"
  311. "MIGJAoGBAMQgV2gXLbXgesWgeAsj8P1Uvm/zibrFXqwDq27lLKNgWGYGX2ax3LyT\n"
  312. "3nzI1Y5oLs4kPKTsMM5ft9aokwf417lKoCRlZc9ptfRbgxDx90c9GtWVmkrmDvCK\n"
  313. "ae59TMoXIiGfZiwWT6KKq5Zm9/Fu2Il3B2vHGkKJYKixmiBJRKp/AgMBAAE=\n"
  314. "-----END RSA PUBLIC KEY-----\n"
  315. "accept 62.245.184.24:25\n"
  316. "accept 62.116.124.106:6666-6670\n"
  317. "accept *:48099\n"
  318. "reject *:*\n"
  319. "router-signature\n"
  320. "-----BEGIN SIGNATURE-----\n"
  321. "qh/xRoqfLNFzPaB8VdpbdMAwRyuk5qjx4LeLVQ2pDwTZ55PqmG99+VKUNte2WTTD\n"
  322. "7dZEA7um2rueohGe4nYmvbhJWr20/I0ZxmWDRDvFy0b5nwzDMGvLvDw95Zu/XJQ2\n"
  323. "md32NE3y9VZCfbCN+GlvETX3fdR3Svzcm8Kzesg2/s4=\n"
  324. "-----END SIGNATURE-----\n"
  325. ;
  326. int config_assign_default_dirservers(void) {
  327. if(router_load_routerlist_from_string(default_dirservers_string, 1) < 0) {
  328. log_fn(LOG_WARN,"Bug: the default dirservers internal string is corrupt.");
  329. return -1;
  330. }
  331. return 0;
  332. }
  333. /** Set <b>options</b> to a reasonable default.
  334. *
  335. * Call this function when we can't find any torrc config file.
  336. */
  337. static int config_assign_defaults(or_options_t *options) {
  338. /* set them up as a client only */
  339. options->SocksPort = 9050;
  340. options->AllowUnverifiedNodes = smartlist_create();
  341. smartlist_add(options->AllowUnverifiedNodes, "middle");
  342. smartlist_add(options->AllowUnverifiedNodes, "rendezvous");
  343. config_free_lines(options->ExitPolicy);
  344. options->ExitPolicy = config_line_prepend(NULL, "ExitPolicy", "reject *:*");
  345. /* plus give them a dirservers file */
  346. if(config_assign_default_dirservers() < 0)
  347. return -1;
  348. return 0;
  349. }
  350. /** Print a usage message for tor. */
  351. static void print_usage(void) {
  352. printf("tor -f <torrc> [args]\n"
  353. "See man page for more options. This -h is probably obsolete.\n\n"
  354. "-b <bandwidth>\t\tbytes/second rate limiting\n"
  355. "-d <file>\t\tDebug file\n"
  356. // "-m <max>\t\tMax number of connections\n"
  357. "-l <level>\t\tLog level\n"
  358. "-r <file>\t\tList of known routers\n");
  359. printf("\nClient options:\n"
  360. "-e \"nick1 nick2 ...\"\t\tExit nodes\n"
  361. "-s <IP>\t\t\tPort to bind to for Socks\n"
  362. );
  363. printf("\nServer options:\n"
  364. "-n <nick>\t\tNickname of router\n"
  365. "-o <port>\t\tOR port to bind to\n"
  366. "-p <file>\t\tPID file\n"
  367. );
  368. }
  369. /**
  370. * Adjust <b>options</b> to contain a reasonable value for Address.
  371. */
  372. int resolve_my_address(const char *address, uint32_t *addr) {
  373. struct in_addr in;
  374. struct hostent *rent;
  375. char hostname[256];
  376. int explicit_ip=1;
  377. tor_assert(addr);
  378. if(address) {
  379. strlcpy(hostname,address,sizeof(hostname));
  380. } else { /* then we need to guess our address */
  381. explicit_ip = 0; /* it's implicit */
  382. if(gethostname(hostname,sizeof(hostname)) < 0) {
  383. log_fn(LOG_WARN,"Error obtaining local hostname");
  384. return -1;
  385. }
  386. log_fn(LOG_DEBUG,"Guessed local host name as '%s'",hostname);
  387. }
  388. /* now we know hostname. resolve it and keep only the IP */
  389. if(tor_inet_aton(hostname, &in) == 0) {
  390. /* then we have to resolve it */
  391. explicit_ip = 0;
  392. rent = (struct hostent *)gethostbyname(hostname);
  393. if (!rent) {
  394. log_fn(LOG_WARN,"Could not resolve local Address %s. Failing.", hostname);
  395. return -1;
  396. }
  397. tor_assert(rent->h_length == 4);
  398. memcpy(&in.s_addr, rent->h_addr,rent->h_length);
  399. }
  400. if(!explicit_ip && is_internal_IP(htonl(in.s_addr))) {
  401. log_fn(LOG_WARN,"Address '%s' resolves to private IP '%s'. "
  402. "Please set the Address config option to be the IP you want to use.",
  403. hostname, inet_ntoa(in));
  404. return -1;
  405. }
  406. log_fn(LOG_DEBUG,"Resolved Address to %s.", inet_ntoa(in));
  407. *addr = ntohl(in.s_addr);
  408. return 0;
  409. }
  410. static char *get_default_nickname(void)
  411. {
  412. char localhostname[256];
  413. char *cp, *out, *outp;
  414. if(gethostname(localhostname,sizeof(localhostname)) < 0) {
  415. log_fn(LOG_WARN,"Error obtaining local hostname");
  416. return NULL;
  417. }
  418. /* Put it in lowercase; stop at the first dot. */
  419. for(cp = localhostname; *cp; ++cp) {
  420. if (*cp == '.') {
  421. *cp = '\0';
  422. break;
  423. }
  424. *cp = tolower(*cp);
  425. }
  426. /* Strip invalid characters. */
  427. cp = localhostname;
  428. out = outp = tor_malloc(strlen(localhostname)+1);
  429. while (*cp) {
  430. if (strchr(LEGAL_NICKNAME_CHARACTERS, *cp))
  431. *outp++ = *cp++;
  432. else
  433. cp++;
  434. }
  435. *outp = '\0';
  436. /* Enforce length. */
  437. if (strlen(out) > MAX_NICKNAME_LEN)
  438. out[MAX_NICKNAME_LEN]='\0';
  439. return out;
  440. }
  441. /** Release storage held by <b>options</b> */
  442. static void free_options(or_options_t *options) {
  443. config_free_lines(options->LogOptions);
  444. tor_free(options->ContactInfo);
  445. tor_free(options->DebugLogFile);
  446. tor_free(options->DataDirectory);
  447. tor_free(options->RouterFile);
  448. tor_free(options->Nickname);
  449. tor_free(options->Address);
  450. tor_free(options->PidFile);
  451. tor_free(options->ExitNodes);
  452. tor_free(options->EntryNodes);
  453. tor_free(options->ExcludeNodes);
  454. tor_free(options->RendNodes);
  455. tor_free(options->RendExcludeNodes);
  456. tor_free(options->OutboundBindAddress);
  457. tor_free(options->RecommendedVersions);
  458. tor_free(options->User);
  459. tor_free(options->Group);
  460. config_free_lines(options->RendConfigLines);
  461. config_free_lines(options->SocksBindAddress);
  462. config_free_lines(options->ORBindAddress);
  463. config_free_lines(options->DirBindAddress);
  464. config_free_lines(options->ExitPolicy);
  465. config_free_lines(options->SocksPolicy);
  466. if (options->FirewallPorts) {
  467. SMARTLIST_FOREACH(options->FirewallPorts, char *, cp, tor_free(cp));
  468. smartlist_free(options->FirewallPorts);
  469. options->FirewallPorts = NULL;
  470. }
  471. }
  472. /** Set <b>options</b> to hold reasonable defaults for most options. */
  473. static void init_options(or_options_t *options) {
  474. /* give reasonable values for each option. Defaults to zero. */
  475. memset(options,0,sizeof(or_options_t));
  476. options->LogOptions = NULL;
  477. options->ExitNodes = tor_strdup("");
  478. options->EntryNodes = tor_strdup("");
  479. options->StrictEntryNodes = options->StrictExitNodes = 0;
  480. options->ExcludeNodes = tor_strdup("");
  481. options->RendNodes = tor_strdup("");
  482. options->RendExcludeNodes = tor_strdup("");
  483. options->ExitPolicy = NULL;
  484. options->SocksPolicy = NULL;
  485. options->SocksBindAddress = NULL;
  486. options->ORBindAddress = NULL;
  487. options->DirBindAddress = NULL;
  488. options->OutboundBindAddress = NULL;
  489. options->RecommendedVersions = NULL;
  490. options->PidFile = NULL; // tor_strdup("tor.pid");
  491. options->DataDirectory = NULL;
  492. options->PathlenCoinWeight = 0.3;
  493. options->MaxConn = 900;
  494. options->DirFetchPostPeriod = 600;
  495. options->KeepalivePeriod = 300;
  496. options->MaxOnionsPending = 100;
  497. options->NewCircuitPeriod = 30; /* twice a minute */
  498. options->BandwidthRate = 800000; /* at most 800kB/s total sustained incoming */
  499. options->BandwidthBurst = 10000000; /* max burst on the token bucket */
  500. options->NumCpus = 1;
  501. options->RendConfigLines = NULL;
  502. options->FirewallPorts = NULL;
  503. }
  504. static char *get_default_conf_file(void)
  505. {
  506. #ifdef MS_WINDOWS
  507. char *path = tor_malloc(MAX_PATH);
  508. if (!SUCCEEDED(SHGetSpecialFolderPath(NULL, path, CSIDL_APPDATA, 1))) {
  509. tor_free(path);
  510. return NULL;
  511. }
  512. strlcat(path,"\\tor\\torrc",MAX_PATH);
  513. return path;
  514. #else
  515. return tor_strdup(CONFDIR "/torrc");
  516. #endif
  517. }
  518. /** Read a configuration file into <b>options</b>, finding the configuration
  519. * file location based on the command line. After loading the options,
  520. * validate them for consistency. Return 0 if success, <0 if failure. */
  521. int getconfig(int argc, char **argv, or_options_t *options) {
  522. struct config_line_t *cl;
  523. FILE *cf;
  524. char *fname;
  525. int i;
  526. int result = 0;
  527. static int first_load = 1;
  528. static char **backup_argv;
  529. static int backup_argc;
  530. char *previous_pidfile = NULL;
  531. int previous_runasdaemon = 0;
  532. int previous_orport = -1;
  533. int using_default_torrc;
  534. if(first_load) { /* first time we're called. save commandline args */
  535. backup_argv = argv;
  536. backup_argc = argc;
  537. first_load = 0;
  538. } else { /* we're reloading. need to clean up old ones first. */
  539. argv = backup_argv;
  540. argc = backup_argc;
  541. /* record some previous values, so we can fail if they change */
  542. if(options->PidFile)
  543. previous_pidfile = tor_strdup(options->PidFile);
  544. previous_runasdaemon = options->RunAsDaemon;
  545. previous_orport = options->ORPort;
  546. free_options(options);
  547. }
  548. init_options(options);
  549. if(argc > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1],"--help"))) {
  550. print_usage();
  551. exit(0);
  552. }
  553. if(argc > 1 && (!strcmp(argv[1],"--version"))) {
  554. printf("Tor version %s.\n",VERSION);
  555. exit(0);
  556. }
  557. /* learn config file name, get config lines, assign them */
  558. i = 1;
  559. while(i < argc-1 && strcmp(argv[i],"-f")) {
  560. i++;
  561. }
  562. if(i < argc-1) { /* we found one */
  563. fname = tor_strdup(argv[i+1]);
  564. using_default_torrc = 0;
  565. } else {
  566. /* didn't find one, try CONFDIR */
  567. char *fn;
  568. using_default_torrc = 1;
  569. fn = get_default_conf_file();
  570. if (fn && file_status(fn)==FN_FILE) {
  571. fname = fn;
  572. } else {
  573. tor_free(fn);
  574. fn = expand_filename("~/.torrc");
  575. if (fn && file_status(fn)==FN_FILE) {
  576. fname = fn;
  577. } else {
  578. tor_free(fn);
  579. fname = get_default_conf_file();
  580. }
  581. }
  582. }
  583. tor_assert(fname);
  584. log(LOG_DEBUG,"Opening config file '%s'",fname);
  585. cf = fopen(fname, "r");
  586. if(!cf) {
  587. if(using_default_torrc == 1) {
  588. log(LOG_NOTICE, "Configuration file '%s' not present, using reasonable defaults.",fname);
  589. tor_free(fname);
  590. if(config_assign_defaults(options) < 0) {
  591. return -1;
  592. }
  593. } else {
  594. log(LOG_WARN, "Unable to open configuration file '%s'.",fname);
  595. tor_free(fname);
  596. return -1;
  597. }
  598. } else { /* it opened successfully. use it. */
  599. tor_free(fname);
  600. cl = config_get_lines(cf);
  601. if(!cl) return -1;
  602. if(config_assign(options,cl) < 0)
  603. return -1;
  604. config_free_lines(cl);
  605. fclose(cf);
  606. }
  607. /* go through command-line variables too */
  608. cl = config_get_commandlines(argc,argv);
  609. if(config_assign(options,cl) < 0)
  610. return -1;
  611. config_free_lines(cl);
  612. /* Validate options */
  613. /* first check if any of the previous options have changed but aren't allowed to */
  614. if(previous_pidfile && strcmp(previous_pidfile,options->PidFile)) {
  615. log_fn(LOG_WARN,"During reload, PidFile changed from %s to %s. Failing.",
  616. previous_pidfile, options->PidFile);
  617. return -1;
  618. }
  619. tor_free(previous_pidfile);
  620. if(previous_runasdaemon && !options->RunAsDaemon) {
  621. log_fn(LOG_WARN,"During reload, change from RunAsDaemon=1 to =0 not allowed. Failing.");
  622. return -1;
  623. }
  624. if(previous_orport == 0 && options->ORPort > 0) {
  625. log_fn(LOG_WARN,"During reload, change from ORPort=0 to >0 not allowed. Failing.");
  626. return -1;
  627. }
  628. if(options->ORPort < 0) {
  629. log(LOG_WARN,"ORPort option can't be negative.");
  630. result = -1;
  631. }
  632. if (options->Nickname == NULL) {
  633. if(server_mode()) {
  634. if (!(options->Nickname = get_default_nickname()))
  635. return -1;
  636. log_fn(LOG_NOTICE, "Choosing default nickname %s", options->Nickname);
  637. }
  638. } else {
  639. if (strspn(options->Nickname, LEGAL_NICKNAME_CHARACTERS) !=
  640. strlen(options->Nickname)) {
  641. log_fn(LOG_WARN, "Nickname '%s' contains illegal characters.", options->Nickname);
  642. result = -1;
  643. }
  644. if (strlen(options->Nickname) == 0) {
  645. log_fn(LOG_WARN, "Nickname must have at least one character");
  646. result = -1;
  647. }
  648. if (strlen(options->Nickname) > MAX_NICKNAME_LEN) {
  649. log_fn(LOG_WARN, "Nickname '%s' has more than %d characters.",
  650. options->Nickname, MAX_NICKNAME_LEN);
  651. result = -1;
  652. }
  653. }
  654. if(server_mode()) {
  655. /* confirm that our address isn't broken, so we can complain now */
  656. uint32_t tmp;
  657. if(resolve_my_address(options->Address, &tmp) < 0)
  658. result = -1;
  659. }
  660. if(options->SocksPort < 0) {
  661. log(LOG_WARN,"SocksPort option can't be negative.");
  662. result = -1;
  663. }
  664. if(options->SocksPort == 0 && options->ORPort == 0) {
  665. log(LOG_WARN,"SocksPort and ORPort are both undefined? Quitting.");
  666. result = -1;
  667. }
  668. if(options->DirPort < 0) {
  669. log(LOG_WARN,"DirPort option can't be negative.");
  670. result = -1;
  671. }
  672. if(options->StrictExitNodes && !strlen(options->ExitNodes)) {
  673. log(LOG_WARN,"StrictExitNodes set, but no ExitNodes listed.");
  674. }
  675. if(options->StrictEntryNodes && !strlen(options->EntryNodes)) {
  676. log(LOG_WARN,"StrictEntryNodes set, but no EntryNodes listed.");
  677. }
  678. if(options->AuthoritativeDir && options->RecommendedVersions == NULL) {
  679. log(LOG_WARN,"Directory servers must configure RecommendedVersions.");
  680. result = -1;
  681. }
  682. if(options->AuthoritativeDir && !options->DirPort) {
  683. log(LOG_WARN,"Running as authoritative directory, but no DirPort set.");
  684. result = -1;
  685. }
  686. if(options->AuthoritativeDir && !options->ORPort) {
  687. log(LOG_WARN,"Running as authoritative directory, but no ORPort set.");
  688. result = -1;
  689. }
  690. if(options->AuthoritativeDir && options->ClientOnly) {
  691. log(LOG_WARN,"Running as authoritative directory, but ClientOnly also set.");
  692. result = -1;
  693. }
  694. if(options->FascistFirewall && !options->FirewallPorts) {
  695. options->FirewallPorts = smartlist_create();
  696. smartlist_add(options->FirewallPorts, tor_strdup("80"));
  697. smartlist_add(options->FirewallPorts, tor_strdup("443"));
  698. }
  699. if(options->FirewallPorts) {
  700. SMARTLIST_FOREACH(options->FirewallPorts, const char *, cp,
  701. { i = atoi(cp);
  702. if (i < 1 || i > 65535) {
  703. log(LOG_WARN, "Port '%s' out of range in FirewallPorts", cp);
  704. result=-1;
  705. }
  706. });
  707. }
  708. options->_AllowUnverified = 0;
  709. if(options->AllowUnverifiedNodes) {
  710. SMARTLIST_FOREACH(options->AllowUnverifiedNodes, const char *, cp,
  711. { if (!strcasecmp(cp, "entry"))
  712. options->_AllowUnverified |= ALLOW_UNVERIFIED_ENTRY;
  713. else if (!strcasecmp(cp, "exit"))
  714. options->_AllowUnverified |= ALLOW_UNVERIFIED_EXIT;
  715. else if (!strcasecmp(cp, "middle"))
  716. options->_AllowUnverified |= ALLOW_UNVERIFIED_MIDDLE;
  717. else if (!strcasecmp(cp, "introduction"))
  718. options->_AllowUnverified |= ALLOW_UNVERIFIED_INTRODUCTION;
  719. else if (!strcasecmp(cp, "rendezvous"))
  720. options->_AllowUnverified |= ALLOW_UNVERIFIED_RENDEZVOUS;
  721. else {
  722. log(LOG_WARN, "Unrecognized value '%s' in AllowUnverifiedNodes",
  723. cp);
  724. result=-1;
  725. }
  726. });
  727. }
  728. if(options->SocksPort >= 1 &&
  729. (options->PathlenCoinWeight < 0.0 || options->PathlenCoinWeight >= 1.0)) {
  730. log(LOG_WARN,"PathlenCoinWeight option must be >=0.0 and <1.0.");
  731. result = -1;
  732. }
  733. if(options->MaxConn < 1) {
  734. log(LOG_WARN,"MaxConn option must be a non-zero positive integer.");
  735. result = -1;
  736. }
  737. if(options->MaxConn >= MAXCONNECTIONS) {
  738. log(LOG_WARN,"MaxConn option must be less than %d.", MAXCONNECTIONS);
  739. result = -1;
  740. }
  741. if(options->DirFetchPostPeriod < 1) {
  742. log(LOG_WARN,"DirFetchPostPeriod option must be positive.");
  743. result = -1;
  744. }
  745. if(options->DirFetchPostPeriod > MIN_ONION_KEY_LIFETIME/2) {
  746. log(LOG_WARN,"DirFetchPostPeriod is too large; clipping.");
  747. options->DirFetchPostPeriod = MIN_ONION_KEY_LIFETIME/2;
  748. }
  749. if(options->KeepalivePeriod < 1) {
  750. log(LOG_WARN,"KeepalivePeriod option must be positive.");
  751. result = -1;
  752. }
  753. /* XXX look at the various nicknamelists and make sure they're
  754. * valid and don't have hostnames that are too long.
  755. */
  756. if (rend_config_services(options) < 0) {
  757. result = -1;
  758. }
  759. return result;
  760. }
  761. static int add_single_log(struct config_line_t *level_opt,
  762. struct config_line_t *file_opt,
  763. int isDaemon)
  764. {
  765. int levelMin=-1, levelMax=-1;
  766. char *cp, *tmp_sev;
  767. if (level_opt) {
  768. cp = strchr(level_opt->value, '-');
  769. if (cp) {
  770. tmp_sev = tor_strndup(level_opt->value, cp - level_opt->value);
  771. levelMin = parse_log_level(tmp_sev);
  772. if (levelMin<0) {
  773. log_fn(LOG_WARN, "Unrecognized log severity '%s': must be one of err|warn|notice|info|debug", tmp_sev);
  774. return -1;
  775. }
  776. tor_free(tmp_sev);
  777. levelMax = parse_log_level(cp+1);
  778. if (levelMax<0) {
  779. log_fn(LOG_WARN, "Unrecognized log severity '%s': must be one of err|warn|notice|info|debug", cp+1);
  780. return -1;
  781. }
  782. } else {
  783. levelMin = parse_log_level(level_opt->value);
  784. if (levelMin<0) {
  785. log_fn(LOG_WARN, "Unrecognized log severity '%s': must be one of err|warn|notice|info|debug", level_opt->value);
  786. return -1;
  787. }
  788. }
  789. }
  790. if (levelMin < 0 && levelMax < 0) {
  791. levelMin = LOG_NOTICE;
  792. levelMax = LOG_ERR;
  793. } else if (levelMin < 0) {
  794. levelMin = levelMax;
  795. } else {
  796. levelMax = LOG_ERR;
  797. }
  798. if (file_opt) {
  799. if (add_file_log(levelMin, levelMax, file_opt->value) < 0) {
  800. log_fn(LOG_WARN, "Cannot write to LogFile '%s': %s.", file_opt->value,
  801. strerror(errno));
  802. return -1;
  803. }
  804. log_fn(LOG_NOTICE, "Successfully opened LogFile '%s', redirecting output.",
  805. file_opt->value);
  806. } else if (!isDaemon) {
  807. add_stream_log(levelMin, levelMax, "<stdout>", stdout);
  808. close_temp_logs();
  809. }
  810. return 0;
  811. }
  812. /**
  813. * Initialize the logs based on the configuration file.
  814. */
  815. int config_init_logs(or_options_t *options)
  816. {
  817. /* The order of options is: Level? (File Level?)+
  818. */
  819. struct config_line_t *opt = options->LogOptions;
  820. /* Special case if no options are given. */
  821. if (!opt) {
  822. add_stream_log(LOG_NOTICE, LOG_ERR, "<stdout>", stdout);
  823. close_temp_logs();
  824. /* don't return yet, in case we want to do a debuglogfile below */
  825. }
  826. /* Special case for if first option is LogLevel. */
  827. if (opt && !strcasecmp(opt->key, "LogLevel")) {
  828. if (opt->next && !strcasecmp(opt->next->key, "LogFile")) {
  829. if (add_single_log(opt, opt->next, options->RunAsDaemon)<0)
  830. return -1;
  831. opt = opt->next->next;
  832. } else if (!opt->next) {
  833. if (add_single_log(opt, NULL, options->RunAsDaemon)<0)
  834. return -1;
  835. opt = opt->next;
  836. } else {
  837. ; /* give warning below */
  838. }
  839. }
  840. while (opt) {
  841. if (!strcasecmp(opt->key, "LogLevel")) {
  842. log_fn(LOG_WARN, "Two LogLevel options in a row without intervening LogFile");
  843. opt = opt->next;
  844. } else {
  845. tor_assert(!strcasecmp(opt->key, "LogFile"));
  846. if (opt->next && !strcasecmp(opt->next->key, "LogLevel")) {
  847. /* LogFile followed by LogLevel */
  848. if (add_single_log(opt->next, opt, options->RunAsDaemon)<0)
  849. return -1;
  850. opt = opt->next->next;
  851. } else {
  852. /* LogFile followed by LogFile or end of list. */
  853. if (add_single_log(NULL, opt, options->RunAsDaemon)<0)
  854. return -1;
  855. opt = opt->next;
  856. }
  857. }
  858. }
  859. if (options->DebugLogFile) {
  860. log_fn(LOG_WARN, "DebugLogFile is deprecated; use LogFile and LogLevel instead");
  861. if (add_file_log(LOG_DEBUG, LOG_ERR, options->DebugLogFile)<0)
  862. return -1;
  863. }
  864. return 0;
  865. }
  866. /**
  867. * Given a linked list of config lines containing "allow" and "deny" tokens,
  868. * parse them and place the result in <b>dest</b>. Skip malformed lines.
  869. */
  870. void
  871. config_parse_exit_policy(struct config_line_t *cfg,
  872. struct exit_policy_t **dest)
  873. {
  874. struct exit_policy_t **nextp;
  875. char *e, *s;
  876. int last=0;
  877. char line[1024];
  878. if (!cfg)
  879. return;
  880. nextp = dest;
  881. while (*nextp)
  882. nextp = &((*nextp)->next);
  883. for (; cfg; cfg = cfg->next) {
  884. s = cfg->value;
  885. for (;;) {
  886. e = strchr(s,',');
  887. if(!e) {
  888. last = 1;
  889. strncpy(line,s,1023);
  890. } else {
  891. memcpy(line,s, ((e-s)<1023)?(e-s):1023);
  892. line[e-s] = 0;
  893. }
  894. line[1023]=0;
  895. log_fn(LOG_DEBUG,"Adding new entry '%s'",line);
  896. *nextp = router_parse_exit_policy_from_string(line);
  897. if(*nextp) {
  898. nextp = &((*nextp)->next);
  899. } else {
  900. log_fn(LOG_WARN,"Malformed exit policy %s; skipping.", line);
  901. }
  902. if (last)
  903. break;
  904. s = e+1;
  905. }
  906. }
  907. }
  908. void exit_policy_free(struct exit_policy_t *p) {
  909. struct exit_policy_t *e;
  910. while (p) {
  911. e = p;
  912. p = p->next;
  913. tor_free(e->string);
  914. tor_free(e);
  915. }
  916. }
  917. const char *get_data_directory(or_options_t *options) {
  918. const char *d;
  919. if (options->DataDirectory)
  920. d = options->DataDirectory;
  921. else if (server_mode()) {
  922. #ifdef MS_WINDOWS
  923. char *p;
  924. p = tor_malloc(MAX_PATH);
  925. if (!SUCCEEDED(SHGetSpecialFolderPath(NULL, p, CSIDL_APPDATA, 1))) {
  926. strlcpy(p,CONFDIR, MAX_PATH);
  927. }
  928. strlcat(p,"\\tor",MAX_PATH);
  929. options->DataDirectory = p;
  930. return p;
  931. #else
  932. d = "~/.tor";
  933. #endif
  934. } else
  935. d = NULL; /* XXX008 don't create datadir until we have something
  936. we'll be putting in it */
  937. if (d && strncmp(d,"~/",2)==0) {
  938. char *fn = expand_filename(d);
  939. tor_free(options->DataDirectory);
  940. options->DataDirectory = fn;
  941. }
  942. return options->DataDirectory;
  943. }
  944. /*
  945. Local Variables:
  946. mode:c
  947. indent-tabs-mode:nil
  948. c-basic-offset:2
  949. End:
  950. */