Commit Graph

2480 Commits

Author SHA1 Message Date
David Anderson be50103751 file upoad handler: if file is already there, don't upload again
Notes:
1) We still need to read all the data from socket (copy_socket_to_null());
otherwise the client will block on the send, and never get the success reply.
The previous approach (read-only file) didn't do this.
All we're saving is disk I/O on server.

2) The client reports a result only after it know that
all its output files have successfully been uploaded.
It won't re-upload anything if that's the case.
2016-02-02 11:51:45 -08:00
David Anderson d5f5918111 Replace strncpy() with strlcpy() various places.
Except for very specific cases, strncpy() should never be used.
It can result in a non-terminated string.

Also replace strncat() with strlcat(); the latter is simpler
because you don't have to calculate remaining buffer space.
2016-02-01 20:23:18 -08:00
David Anderson ab5526ea6f file upload handler: undo the change where we make uploaded files readonly
This broke other things (e.g. get_file_size on that file).
We would accomplish the same thing a cleaner way,
i.e. notice the file is already there and of the right size.
2016-02-01 20:21:27 -08:00
David Anderson 9daab7acb1 Scheduler: when matching host by CPID, make sure basic system params match
In handling a request without host ID, if we match a host record by CPID,
make sure the computers are not obviously different.
2016-01-15 15:48:12 -08:00
David Anderson cb6259ecf1 fix comment about output filename random part 2015-11-20 13:58:28 -08:00
David Anderson 4e55dbf0e0 fix typo 2015-11-19 19:29:30 -08:00
David Anderson f4c72320a3 file upload handler: improve check for filename validity
The file upload handler checked for ".." in the filename.
Also check for control chars and for starting with /.
Put this into a separate function, is_valid_filename().
2015-11-18 16:08:47 -08:00
David Anderson 6b81b0e63b server: provide access to output file names without random part
- add random substring as "_r123123"
- add function remove_random_from_filename() that removes
  the random substring from an output filename
2015-11-18 13:42:06 -08:00
David Anderson aa11256909 file upload handler: don't include full path in error msgs sent to client 2015-11-16 20:42:45 -08:00
David Anderson 153f6600d0 Server (assimilator): add random string to result file names
Otherwise, result file names can be inferred from result names.
An attacker with task A could find the name of the "wingman" task B,
upload fake files as B's output files,
upload the same files as A's output files,
report A as completed, and get unearned credit.
2015-11-16 19:28:30 -08:00
Rom Walton 56737cc002 Merge branch 'master' of https://github.com/BOINC/boinc 2015-11-16 15:39:46 -05:00
Rom Walton 914d9f0873 sched: Remove commit ecea18f.
We parse the stuff from xml_doc_in instead of xml_doc_out.  xml_doc_in cannot be modified by anything the BOINC client returns.
2015-11-16 15:39:30 -05:00
Christian Beer 3fc2d41f9a Server: fix sched/start to work with older python version
An issue with unicode strings in python 2.4 and 2.6 (and possibly 2.5) prevents shlex to split the command which leads to the daemon or task not starting. The unicode issue seems to be fixed in python 2.7. The exact error message is: "TypeError: execv() argument 1 must be (encoded string without NULL bytes), not str".

See: https://github.com/vinodc/gitlab-webhook-branch-deployer/issues/1
2015-11-16 13:27:15 +01:00
Rom Walton 8e11f75195 sched: Do not create a temp string object just to append a character to a string object. 2015-11-15 11:54:27 -05:00
Rom Walton 90f4e92e3e sched: fix compiler warnings 2015-11-14 12:29:42 -05:00
Rom Walton eec9f10460 sched: fix compiler warnings 2015-11-14 12:26:28 -05:00
Rom Walton ecea18f473 sched: Do not trust that the result name embedded within the result output file name is correctly reported by the client.
This opens the validator up to a result name spoofing attack where a bogus client can claim it processed the result reported by a different client for the same workunit.
2015-11-14 12:18:39 -05:00
Christian Beer 454bd634d9 File upload handler: return the lseek() error
If the printf() or close() calls change errno, the original lseek() error is lost. The logged error would differ from the message send to the client. This amends 005957a.
Suggested by Juha Sointusalo
2015-11-12 13:32:58 +01:00
Christian Beer 475fbbeb15 Merge pull request #1427 from BOINC/sched_start_shell
Server: fix behaviour of start script
2015-11-11 08:39:09 +01:00
Christian Beer 69c04cca8c Server: enhance shell encapsulation of daemons and tasks
- if a daemon or task should run in a shell, add <use_shell>1</use_shell> to the task entry in config.xml
  this will spawn a "sh -c cmd" process that propagates signals to the child process (see 881863d)
- if a daemon or task has to use a shell (pipe or redirection present in cmd) and <use_shell> is not enabled:
  don't execute the cmd and print an error message (other daemons and tasks are still started)
2015-11-10 10:16:30 +01:00
Christian Beer 4eec734bc4 Feeder: more efficient solution to memory leak fix
The for loop copies newly created objects into the vector and destroys the original objects. The resize() instantiates the objects directly in the vector. Suggested by Nicolás Alvarez.
2015-11-10 08:29:19 +01:00
Christian Beer 770fbf138f Feeder: prevent resource leak
I confirmed the leak using Valgrind and tested the fix with a simple program using the same workflow as the feeder.
fixes CID 27760 found by Coverity
2015-11-09 18:08:03 +01:00
Christian Beer fc142d75c8 Merge branch 'master' into fix_defects_server 2015-11-09 17:55:21 +01:00
David Anderson 5f075e9ada Merge branch 'master' of github.com:BOINC/boinc 2015-11-04 12:03:24 -08:00
David Anderson bae397cc54 scheduler: message tweak 2015-11-04 11:57:17 -08:00
Christian Beer 972c0b9a9f Server: ignore infinite loop defects
ignores CID 27886, 27830, 27766 found by Coverity
2015-11-04 08:20:30 +01:00
Christian Beer ff892afa23 Server: fix comment from last commit 2015-11-03 18:06:46 +01:00
Christian Beer 881863d8a2 Server: fix behaviour of start script
If the command of a task or daemon wants to use shell features like |, > or < the start script uses a shell encapsulation (sh -c) to start the process.
This had two problems:
1. It also started a shell if the command contained ' or " and didn't check if |, > or < where escaped or used within quotes (e.g. as part of a regular expression). The new mechanism uses the python module shlex to prepare the arguments for the execvp() call. It also detects if a shell encapsulation is needed and informs the user about it.
2. The actual daemon or task is a subprocess of the shell and was not terminated with the parent. The new signal propagation mechanism properly kills the daemon or task if the shell receives a signal to do so (e.g. by stop).
2015-11-03 15:58:20 +01:00
Rytis Slatkevièius f33c4ed1d6 Sched: use X-Forwarded-For as the client's IP address in case it is set (if the scheduler is behind a load balancer, environment's remote_addr will contain load balancer's IP). 2015-11-03 10:15:07 +02:00
Christian Beer 6cf316daf5 Merge pull request #1401 from BOINC/assimilator_enhancements
Daemons: enhance assimilator framework
2015-10-30 14:34:43 +01:00
Christian Beer d536505f7e Assimilator: remove --noinsert option
please implement this in the project specific part if needed
2015-10-30 14:20:21 +01:00
Christian Beer 37af0e8b90 check return vlaue of get_tag()
fixes CID 27720 found by Coverity
2015-10-29 17:41:52 +01:00
Christian Beer 7fbb11e557 Merge pull request #1415 from BOINC/fuh_logging
file upload handler: add logging and error checking
2015-10-29 11:50:41 +01:00
Christian Beer d160c7fab5 Assimilator: cosmetic changes to usage output 2015-10-29 09:18:18 +01:00
Christian Beer f27d676a14 sanitize nrequests option
fixes CID 27924 found by Coverity
2015-10-28 17:45:25 +01:00
Christian Beer 28e3c3740c test for null on all tokens to prevent null pointer dereference
fixes CID 27881 found by Coverity
2015-10-28 17:40:42 +01:00
Christian Beer 4127c98276 check return of scan_work_array()
This seems unnecessary but fixes the coverity message efficiently.
fixes CID 27678 found by Coverity
2015-10-28 17:28:35 +01:00
Christian Beer 90dd61b766 prevent resource leak in error case
fixes CID 27857 found by Coverity
2015-10-28 17:23:32 +01:00
Christian Beer 21fd1ac9e8 ignore time of check to time of use defect
fixes CID 27949 found by Coverity
2015-10-28 17:15:10 +01:00
Christian Beer 005957aab9 check return value of lseek()
fixes CID 27702 found by Coverity
2015-10-28 17:10:30 +01:00
Christian Beer 9951ffcea0 remove dead code
fixes CID 27849 found by Coverity
2015-10-28 16:54:07 +01:00
Christian Beer 6c10091740 check return value of host.update_diff_validator()
fixes CID 27961 found by Coverity
2015-10-28 14:41:09 +01:00
Christian Beer 788745db0b check return value of dup_element_contents()
If the time_stats_log can't be parsed, it will be ignored.
fixes CID 27715 found by Coverity
2015-10-28 14:22:21 +01:00
Christian Beer 553a2cde5b check return value of fopen()
fixes CID 27795 found by Coverity
2015-10-28 12:12:36 +01:00
Christian Beer 801cafd7e5 use strcpy() for fixed string
This was marked suspicious by Coverity because sizeof(buf) is always 8 when using strlcpy(). Since it is a fixed string we can assume that buf has enough space and use strcpy().
fixes CID 27756 found by Coverity
2015-10-28 11:25:21 +01:00
Christian Beer 4892976d90 use safe_strcat() to prevent buffer overflow
fixes CID 27828 found by Coverity
2015-10-28 11:15:21 +01:00
Christian Beer 88351bcbdc ignore unchecked return value
ignore CID 27729 found by Coverity
2015-10-28 11:11:55 +01:00
Christian Beer b031fff422 check return value of mkdir()
Also gives a more sensible error message where get_log_path() is used.
fixes CID 27696 found by Coverity
2015-10-28 10:50:15 +01:00
David Anderson 24b52bd4a9 scheduler: add result priority to job score 2015-10-25 23:34:45 -07:00
Christian Beer c19cb4675f initialize fields in constructor
fixes CID 28041 found by Coverity
2015-10-23 13:46:59 +02:00