summaryrefslogtreecommitdiff
path: root/src/common/util.h
AgeCommit message (Collapse)Author
2011-10-07Merge remote-tracking branch 'asn2/bug3656'Nick Mathewson
Conflicts: src/common/util.c src/common/util.h src/or/config.h src/or/main.c src/test/test_util.c
2011-09-11Enforce transport names being C identifiers.George Kadianakis
Introduce string_is_C_identifier() and use it to enforce transport names according to the 180 spec.
2011-09-11Introduce tor_terminate_process() function.George Kadianakis
2011-09-01Fix double-closing a stdio streamSteven Murdoch
After a stream reached eof, we fclose it, but then test_util_spawn_background_partial_read() reads from it again, which causes an error and thus another fclose(). Some platforms are fine with this, others (e.g. debian-sid-i386) trigger a double-free() error. The actual code used by Tor (log_from_pipe() and tor_check_port_forwarding()) handle this case correctly.
2011-09-01Make a version of tor_read_all_handle() for non-Windows platformsSteven Murdoch
Mainly used for testing reading from subprocesses. To be more generic we now pass in a pointer to a process_handle_t rather than a Windows- specific HANDLE.
2011-08-30Rename tor_join_cmdline to tor_join_win_cmdline; tweak doxygenNick Mathewson
2011-08-30Factor out and re-write code for splitting lines from a handleSteven Murdoch
Now handles non-printable characters and will not output a spurious new-line if given a partial line.
2011-08-29Refactor out command line formattingSteven Murdoch
Now correctly handles whitespace, quotes and backslashes. Passes all unit tests.
2011-08-29Replace two magic tristates with #define'd namesSteven Murdoch
- process_handle_t.status - return value of tor_get_exit_code()
2011-08-28Make signature of tor_spawn_background more conventionalSteven Murdoch
Conventionally in Tor, structs are returned as pointers, so change tor_spawn_background() to return the process handle in a pointer rather than as return value.
2011-08-24Appease "make check-spaces"Steven Murdoch
2011-08-24Improve comments and fix one bugSteven Murdoch
2011-08-23Fix compilation errors under *nixSteven Murdoch
2011-08-22Tidy up subprocess codeSteven Murdoch
- Better error handling - Write description of functions - Don't assume non-negative process return values
2011-08-18Merge remote branch 'origin/master' into bug2046Steven Murdoch
2011-08-18Complete logging of output from port forwarding helperSteven Murdoch
2011-08-15Improve the code a tad.George Kadianakis
* Use strcmpstart() instead of strcmp(x,y,strlen(y)). * Warn the user if the managed proxy failed to launch. * Improve function documentation. * Use smartlist_len() instead of n_unconfigured_proxies. * Split managed_proxy_destroy() to managed_proxy_destroy() and managed_proxy_destroy_with_transports(). * Constification.
2011-08-10Add smartlist_[v]asprintf_addRobert Ransom
I should have added this before implementing #2411.
2011-07-25Test case for reading the partial output of a background processSteven Murdoch
2011-07-21Add Windows version of tor_spawn_background and ancillary functionsSteven Murdoch
2011-07-21Generalize process spawning so its test compiles (but fails) in WindowsSteven Murdoch
- pid, stdout/stderr_pipe now encapsulated in process_handle - read_all replaced by tor_read_all_from_process_stdin/stderr - waitpid replaced by tor_get_exit_code Untested on *nix
2011-07-19Turn streq_opt into a generic strcmp_opt.Nick Mathewson
2011-07-19Implement stream isolationNick Mathewson
This is the meat of proposal 171: we change circuit_is_acceptable() to require that the connection is compatible with every connection that has been linked to the circuit; we update circuit_is_better to prefer attaching streams to circuits in the way that decreases the circuits' usefulness the least; and we update link_apconn_to_circ() to do the appropriate bookkeeping.
2011-07-18Replaced ST_* enum prefix for stream status with IO_STREAM_*.George Kadianakis
2011-07-13Make some utility functions.George Kadianakis
* Create a function that will get input from a stream, so that we can communicate with the managed proxy. * Hackish change to tor_spawn_background() so that we can specify an environ for our spawn.
2011-06-14Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
2011-06-14Make ControlSocketsGroupWritable work with User.Jérémy Bobbio
Original message from bug3393: check_private_dir() to ensure that ControlSocketsGroupWritable is safe to use. Unfortunately, check_private_dir() only checks against the currently running user… which can be root until privileges are dropped to the user and group configured by the User config option. The attached patch fixes the issue by adding a new effective_user argument to check_private_dir() and updating the callers. It might not be the best way to fix the issue, but it did in my tests. (Code by lunar; changelog by nickm)
2011-05-30Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
The conflicts were mainly caused by the routerinfo->node transition. Conflicts: src/or/circuitbuild.c src/or/command.c src/or/connection_edge.c src/or/directory.c src/or/dirserv.c src/or/relay.c src/or/rendservice.c src/or/routerlist.c
2011-05-30whitespace fixesNick Mathewson
2011-05-30Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
Conflicts: src/common/compat.c src/or/main.c
2011-05-23Use a 64-bit type to hold sockets on win64.Nick Mathewson
On win64, sockets are of type UINT_PTR; on win32 they're u_int; elsewhere they're int. The correct windows way to check a socket for being set is to compare it with INVALID_SOCKET; elsewhere you see if it is negative. On Libevent 2, all callbacks take sockets as evutil_socket_t; we've been passing them int. This patch should fix compilation and correctness when built for 64-bit windows. Fixes bug 3270.
2011-05-15Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
2011-05-15Add a new flag to check_private_dir to make it _not_ change permissionsNick Mathewson
We'll need this for checking permissions on the directories that hold control sockets: if somebody says "ControlSocket ~/foo", it would be pretty rude to do a chmod 700 on their homedir.
2011-05-15Make check_private_dir accept g+rx dirs if told to do so.Nick Mathewson
2011-05-11Merge remote-tracking branch 'public/bug3122_memcmp_022' into bug3122_memcmp_023Nick Mathewson
Conflicts in various places, mainly node-related. Resolved them in favor of HEAD, with copying of tor_mem* operations from bug3122_memcmp_022. src/common/Makefile.am src/or/circuitlist.c src/or/connection_edge.c src/or/directory.c src/or/microdesc.c src/or/networkstatus.c src/or/router.c src/or/routerlist.c src/test/test_util.c
2011-05-11Merge remote-tracking branch 'public/3122_memcmp_squashed' into ↵Nick Mathewson
bug3122_memcmp_022 Conflicts throughout. All resolved in favor of taking HEAD and adding tor_mem* or fast_mem* ops as appropriate. src/common/Makefile.am src/or/circuitbuild.c src/or/directory.c src/or/dirserv.c src/or/dirvote.c src/or/networkstatus.c src/or/rendclient.c src/or/rendservice.c src/or/router.c src/or/routerlist.c src/or/routerparse.c src/or/test.c
2011-05-11Hand-conversion and audit phase of memcmp transitionNick Mathewson
Here I looked at the results of the automated conversion and cleaned them up as follows: If there was a tor_memcmp or tor_memeq that was in fact "safe"[*] I changed it to a fast_memcmp or fast_memeq. Otherwise if there was a tor_memcmp that could turn into a tor_memneq or tor_memeq, I converted it. This wants close attention. [*] I'm erring on the side of caution here, and leaving some things as tor_memcmp that could in my opinion use the data-dependent fast_memcmp variant.
2011-05-11Add a "di_ops.h" include to util.hNick Mathewson
2011-04-07Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
Conflicts: src/common/address.c src/common/compat_libevent.c src/common/memarea.c src/common/util.h src/or/buffers.c src/or/circuitbuild.c src/or/circuituse.c src/or/connection.c src/or/directory.c src/or/networkstatus.c src/or/or.h src/or/routerlist.c
2011-03-25Remove the "fuzzy time" codeNick Mathewson
It was the start of a neat idea, but it only got used in 3 places, none of which really needed it.
2011-01-03Merge remote branch 'origin/maint-0.2.2'Nick Mathewson
2011-01-03Merge remote branch 'origin/maint-0.2.1' into maint-0.2.2Nick Mathewson
Conflicts: src/common/test.h src/or/test.c
2011-01-03Bump copyright statements to 2011Nick Mathewson
2010-10-15Remove the unused old fuzzy-time codeNick Mathewson
2010-10-10Add a unit test for tor_spawn_backgroundSteven Murdoch
- Test sucessfully starting a process - Test failing to find the executable
2010-09-30Start tor-fw-helper in the background, and log whatever it outputsSteven Murdoch
2010-09-21New function to load windows system librariesNick Mathewson
This function uses GetSystemDirectory() to make sure we load the version of the library from c:\windows\system32 (or local equivalent) rather than whatever version lives in the cwd.
2010-09-14Add a simple integer-ceiling-division macro before we get it wrongNick Mathewson
2010-08-31Fix some issues in rate-limiting noticed by SebastianNick Mathewson
2010-08-18Add a generic rate-limited log mechanism, and use it in a few placesNick Mathewson
Incidentally fixes bug 1042.