capture_opts->linktype = -1; /* the default linktype */
capture_opts->saving_to_file = FALSE;
capture_opts->save_file = NULL;
+ capture_opts->group_read_access = FALSE;
capture_opts->use_pcapng = FALSE; /* the default is pcap */
capture_opts->real_time_mode = TRUE;
capture_opts->show_info = TRUE;
g_log(log_domain, log_level, "LinkType : %d", capture_opts->linktype);
g_log(log_domain, log_level, "SavingToFile : %u", capture_opts->saving_to_file);
g_log(log_domain, log_level, "SaveFile : %s", (capture_opts->save_file) ? capture_opts->save_file : "");
+ g_log(log_domain, log_level, "GroupReadAccess : %u", capture_opts->group_read_access);
g_log(log_domain, log_level, "Fileformat : %s", (capture_opts->use_pcapng) ? "PCAPNG" : "PCAP");
g_log(log_domain, log_level, "RealTimeMode : %u", capture_opts->real_time_mode);
g_log(log_domain, log_level, "ShowInfo : %u", capture_opts->show_info);
#endif
status = capture_opts_output_to_pipe(capture_opts->save_file, &capture_opts->output_to_pipe);
return status;
+ case 'g': /* enable group read access on the capture file(s) */
+ capture_opts->group_read_access = TRUE;
+ break;
case 'y': /* Set the pcap data link type */
capture_opts->linktype = linktype_name_to_val(optarg_str_p);
if (capture_opts->linktype == -1) {
gboolean monitor_mode; /**< Capture in monitor mode, if available */
gboolean saving_to_file; /**< TRUE if capture is writing to a file */
gchar *save_file; /**< the capture file name */
+ gboolean group_read_access; /**< TRUE is group read permission needs to be set */
gboolean use_pcapng; /**< TRUE if file format is pcapng */
/* GUI related */
/*fprintf(output, "\n");*/
fprintf(output, "Output (files):\n");
fprintf(output, " -w <filename> name of file to save (def: tempfile)\n");
+ fprintf(output, " -g enable group read access on the output file(s)\n");
fprintf(output, " -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs\n");
fprintf(output, " filesize:NUM - switch to next file after NUM KB\n");
fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n");
if (capture_opts->multi_files_on) {
/* ringbuffer is enabled */
*save_file_fd = ringbuf_init(capfile_name,
- (capture_opts->has_ring_num_files) ? capture_opts->ring_num_files : 0);
+ (capture_opts->has_ring_num_files) ? capture_opts->ring_num_files : 0,
+ capture_opts->group_read_access);
/* we need the ringbuf name */
if(*save_file_fd != -1) {
} else {
/* Try to open/create the specified file for use as a capture buffer. */
*save_file_fd = ws_open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT,
- 0600);
+ (capture_opts->group_read_access) ? 0640 : 0600);
}
}
is_tempfile = FALSE;
#define OPTSTRING_d ""
#endif
-#define OPTSTRING "a:" OPTSTRING_A "b:" OPTSTRING_B "c:" OPTSTRING_d "Df:hi:" OPTSTRING_I "L" OPTSTRING_m "Mnpq" OPTSTRING_r "Ss:" OPTSTRING_u "vw:y:Z:"
+#define OPTSTRING "a:" OPTSTRING_A "b:" OPTSTRING_B "c:" OPTSTRING_d "Df:ghi:" OPTSTRING_I "L" OPTSTRING_m "Mnpq" OPTSTRING_r "Ss:" OPTSTRING_u "vw:y:Z:"
#ifdef DEBUG_CHILD_DUMPCAP
if ((debug_log = ws_fopen("dumpcap_debug_log.tmp","w")) == NULL) {
case 'p': /* Don't capture in promiscuous mode */
case 's': /* Set the snapshot (capture) length */
case 'w': /* Write to capture file x */
+ case 'g': /* enable group read accesson file(s) */
case 'y': /* Set the pcap data link type */
#ifdef HAVE_PCAP_REMOTE
case 'u': /* Use UDP for data transfer */
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;
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;
* 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;
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) {
/* Maximum number for FAT filesystems */
#define RINGBUFFER_WARN_NUM_FILES 65535
-int ringbuf_init(const char *capture_name, guint num_files);
+int ringbuf_init(const char *capture_name, guint num_files, gboolean group_read_access);
const gchar *ringbuf_current_filename(void);
FILE *ringbuf_init_libpcap_fdopen(int *err);
gboolean ringbuf_switch_file(FILE **pdh, gchar **save_file, int *save_file_fd,