Skip to content

Conversation

@mstemm
Copy link
Contributor

@mstemm mstemm commented May 17, 2017

Add the ability to open scap files or inspectors from a fd. Makes it
possible to open other objects that return a fd and treat those objects
as if they were a file.

  • Add new functions scap_open_offline_fd, scap_dump_open_fd that take
    all the same arguments as their filename versions but take a fd
    instead of a filename. scap_open_offline_int now takes a gzfile which
    has been opened by one of the top-level functions.
  • scap_open's args struct now contains a fd. If non-zero, it takes
    precedence over filename and the fd is used to open a gzfile via
    gzdopen().
  • New function scap_event_reset_count sets the read event count to
    0. Used when rewinding a scap file to start over.
  • Add some more useful error messages to
    scap_read_{proclist,userlist,fdlist} when reading more than expected.
  • also add fdopen variants to sinsp_dumper/sinsp. They call the
    appropriate scap fd variants. most of sinsp::open moves to sinsp::open_int().
  • Add is_open() and written_events() methods to sinsp_dumper(). Useful
    when writing files via fd to track progress.
  • In sinsp::init(), after rewinding the file also reset the event
    count.
  • Add a sinsp::fseek() which just uses scap_fseek().

mstemm added 3 commits May 18, 2017 15:47
Add the ability to open scap files or inspectors from a fd. Makes it
possible to open other objects that return a fd and treat those objects
as if they were a file.

 - Add new functions scap_open_offline_fd, scap_dump_open_fd that take
   all the same arguments as their filename versions but take a fd
   instead of a filename. scap_open_offline_int now takes a gzfile which
   has been opened by one of the top-level functions.
 - scap_open's args struct now contains a fd. If non-zero, it takes
   precedence over filename and the fd is used to open a gzfile via
   gzdopen().
 - New function scap_event_reset_count sets the read event count to
   0. Used when rewinding a scap file to start over.
 - Add some more useful error messages to
   scap_read_{proclist,userlist,fdlist} when reading more than expected.
 - also add fdopen variants to sinsp_dumper/sinsp. They call the
   appropriate scap fd variants. most of sinsp::open moves to sinsp::open_int().
 - Add is_open() and written_events() methods to sinsp_dumper(). Useful
   when writing files via fd to track progress.
 - In sinsp::init(), after rewinding the file also reset the event
   count.
 - Add a sinsp::fseek() which just uses scap_fseek().
Add scap_dump_ftell, which maps to gztell, and
sinsp_dumper::next_write_position, which uses scap_dump_ftell.
Add an argument to scap_dump_open_fd that controls whether or not to do
a scan of /proc when initializing the dump file.

In sinsp_dumper::fdopen, set this to false. Also write the thread table
to the file, following recent changes to sinsp_dumper::open.
@mstemm mstemm merged commit 186eefe into dev May 19, 2017
@mstemm mstemm deleted the scap-open-fd branch May 19, 2017 23:44
mstemm pushed a commit that referenced this pull request May 30, 2017
* Bline2 (#830)

* generate a dump file when a process different from docker accesses the docker oom files

* more debug info

* slightly better logging filtering

* better log filtering

* a bit more filtering

* minor changes

* reenable falcobl

* minor changes for better baseliner support

* reduce noisiness

* some baseline flags

* cleanups

* cleanups

* cleanup

* when dumping the sinsp thread table to disk, do it on a thread by thread basis to avoid excessive memory usage

* temporarily remove the falcobl project

* Fix parsing of cgroups with empty subsys

* Dumpermem (#839)

* when dumping the sinsp thread table to disk, do it on a thread by thread basis to avoid excessive memory usage

* make sure to free the structures allocated in sinsp_thread_manager::dump_threads_to_file

* fixed a buffer overflow in sinsp_threadinfo::args_to_scap

* more buffer overflow protection in sinsp_threadinfo::env_to_scap and sinsp_threadinfo::cgroups_to_scap

* make sure not to scan proc when crating a memory dumper

* sinsp-generate the process list when dumping to memory

* sinsp-generate the process list when dumping to memory

* warnings and compile errors

* cleanups

* some optimizations in the code that writes the sinsp thread table to file

* more thread table dump optimizations

* Adding ability to open trace files from fds (#838)

* Adding ability to open trace files from fds

Add the ability to open scap files or inspectors from a fd. Makes it
possible to open other objects that return a fd and treat those objects
as if they were a file.

 - Add new functions scap_open_offline_fd, scap_dump_open_fd that take
   all the same arguments as their filename versions but take a fd
   instead of a filename. scap_open_offline_int now takes a gzfile which
   has been opened by one of the top-level functions.
 - scap_open's args struct now contains a fd. If non-zero, it takes
   precedence over filename and the fd is used to open a gzfile via
   gzdopen().
 - New function scap_event_reset_count sets the read event count to
   0. Used when rewinding a scap file to start over.
 - Add some more useful error messages to
   scap_read_{proclist,userlist,fdlist} when reading more than expected.
 - also add fdopen variants to sinsp_dumper/sinsp. They call the
   appropriate scap fd variants. most of sinsp::open moves to sinsp::open_int().
 - Add is_open() and written_events() methods to sinsp_dumper(). Useful
   when writing files via fd to track progress.
 - In sinsp::init(), after rewinding the file also reset the event
   count.
 - Add a sinsp::fseek() which just uses scap_fseek().

* Add ftell/ability to read bytes written.

Add scap_dump_ftell, which maps to gztell, and
sinsp_dumper::next_write_position, which uses scap_dump_ftell.

* Add ability to skip proc scan for fd opens.

Add an argument to scap_dump_open_fd that controls whether or not to do
a scan of /proc when initializing the dump file.

In sinsp_dumper::fdopen, set this to false. Also write the thread table
to the file, following recent changes to sinsp_dumper::open.

* Add a filtercheck for process tty. (#847)

This allows it to be used in falco rules.

* Try changing the build environment (#849)

* Try changing the build environment

Adding sudo: required, as falco does, should allow the kernel driver to build.

* Run sysdig without -N

65ef7a6
got rid of -N, so don't add that option.

* Set close-on-exec flag for driver fds. (#851)

While debugging some agent unit tests, I noticed that after a fork +
exec the number of driver references was higher than expected. Some of
these problems can be fixed within the tests, but it's also useful to
set the close-on-exec flag for the driver fd so it's closed during an
exec.

Also fix some error messages that were referring to a hardcoded
sysdig_probe instead of PROBE_DEVICE_NAME.

* Use strtok_r instead of strtok. (#850)

Ensures thread safety.
mstemm pushed a commit that referenced this pull request Jun 6, 2017
* Adding ability to open trace files from fds

Add the ability to open scap files or inspectors from a fd. Makes it
possible to open other objects that return a fd and treat those objects
as if they were a file.

 - Add new functions scap_open_offline_fd, scap_dump_open_fd that take
   all the same arguments as their filename versions but take a fd
   instead of a filename. scap_open_offline_int now takes a gzfile which
   has been opened by one of the top-level functions.
 - scap_open's args struct now contains a fd. If non-zero, it takes
   precedence over filename and the fd is used to open a gzfile via
   gzdopen().
 - New function scap_event_reset_count sets the read event count to
   0. Used when rewinding a scap file to start over.
 - Add some more useful error messages to
   scap_read_{proclist,userlist,fdlist} when reading more than expected.
 - also add fdopen variants to sinsp_dumper/sinsp. They call the
   appropriate scap fd variants. most of sinsp::open moves to sinsp::open_int().
 - Add is_open() and written_events() methods to sinsp_dumper(). Useful
   when writing files via fd to track progress.
 - In sinsp::init(), after rewinding the file also reset the event
   count.
 - Add a sinsp::fseek() which just uses scap_fseek().

* Add ftell/ability to read bytes written.

Add scap_dump_ftell, which maps to gztell, and
sinsp_dumper::next_write_position, which uses scap_dump_ftell.

* Add ability to skip proc scan for fd opens.

Add an argument to scap_dump_open_fd that controls whether or not to do
a scan of /proc when initializing the dump file.

In sinsp_dumper::fdopen, set this to false. Also write the thread table
to the file, following recent changes to sinsp_dumper::open.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants