From f17c5ac01f9198a033f6c1cb97ee54676121453e Mon Sep 17 00:00:00 2001 From: Sake Blok Date: Sat, 28 Aug 2010 11:05:51 +0000 Subject: As mentioned on the users-mailinglist[1], it could be useful to have groups read access to the ringbuffer that dumpcap creates. That way, a group of people can access the capture files without having to use root access. [1] http://www.wireshark.org/lists/wireshark-users/201008/msg00235.html svn path=/trunk/; revision=33978 --- ringbuffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ringbuffer.c') diff --git a/ringbuffer.c b/ringbuffer.c index ca94655438..541f009469 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -86,6 +86,7 @@ typedef struct _ringbuf_data { int fd; /* Current ringbuffer file descriptor */ FILE *pdh; + gboolean group_read_access; /* TRUE if files need to be opened with group read access */ } ringbuf_data; static ringbuf_data rb_data; @@ -123,7 +124,8 @@ static int ringbuf_open_file(rb_file *rfile, int *err) return -1; } - rb_data.fd = ws_open(rfile->name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT, 0600); + rb_data.fd = ws_open(rfile->name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT, + rb_data.group_read_access ? 0640 : 0600); if (rb_data.fd == -1 && err != NULL) { *err = errno; @@ -136,7 +138,7 @@ static int ringbuf_open_file(rb_file *rfile, int *err) * Initialize the ringbuffer data structures */ int -ringbuf_init(const char *capfile_name, guint num_files) +ringbuf_init(const char *capfile_name, guint num_files, gboolean group_read_access) { unsigned int i; char *pfx, *last_pathsep; @@ -149,6 +151,7 @@ ringbuf_init(const char *capfile_name, guint num_files) rb_data.unlimited = FALSE; rb_data.fd = -1; rb_data.pdh = NULL; + rb_data.group_read_access = group_read_access; /* just to be sure ... */ if (num_files <= RINGBUFFER_MAX_NUM_FILES) { -- cgit v1.2.3