Skip to content

Commit

Permalink
private-etc rework: file groups moved to src/include/etc_groups.h, ne…
Browse files Browse the repository at this point in the history
…w groups added
  • Loading branch information
netblue30 committed Jan 25, 2023
1 parent 01d3f4c commit 02d3768
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 64 deletions.
4 changes: 3 additions & 1 deletion src/firejail/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ MOD_HDRS = \
../include/seccomp.h \
../include/syscall_i386.h \
../include/syscall_x86_64.h \
../include/firejail_user.h
../include/firejail_user.h \
../include/etc_groups.h


MOD_OBJS = \
../lib/common.o \
Expand Down
72 changes: 9 additions & 63 deletions src/firejail/fs_etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,67 +25,9 @@
#include <time.h>
#include <unistd.h>
#include <glob.h>
#include "../include/etc_groups.h"

#define ETC_MAX 256
static int etc_cnt = 0;
static char *etc_list[ETC_MAX + 1] = { // plus 1 for ending NULL pointer
"alternatives",
"fonts",
"ld.so.cache",
"ld.so.conf",
"ld.so.conf.d",
"ld.so.preload",
"locale",
"locale.alias",
"locale.conf",
"locale.gen",
"localtime",
"nsswitch.conf",
"passwd",
NULL
};

static char*etc_group_network[] = {
"hostname",
"hosts",
"resolv.conf",
"protocols",
NULL
};

static char *etc_group_gnome[] = {
"xdg",
"drirc",
"dconf",
"gtk-2.0",
"gtk-3.0",
NULL
};

static char *etc_group_kde[] = {
"xdg",
"drirc",
"kde4rc",
"kde5rc",
NULL
};

static char *etc_group_sound[] = {
"alsa",
"asound.conf",
"machine-id", // required by PulseAudio
"pulse",
NULL
};

static char *etc_group_tls_ca[] = {
"ca-certificates",
"ca-certificates.conf",
"crypto-policies",
"pki",
"ssl",
NULL
};

static void etc_copy_group(char **pptr) {
assert(pptr);
Expand Down Expand Up @@ -137,10 +79,14 @@ char *fs_etc_build(char *str) {
// look for standard groups
if (strcmp(ptr, "TLS-CA") == 0)
etc_copy_group(&etc_group_tls_ca[0]);
if (strcmp(ptr, "GNOME") == 0)
etc_copy_group(&etc_group_gnome[0]);
if (strcmp(ptr, "KDE") == 0)
etc_copy_group(&etc_group_kde[0]);
if (strcmp(ptr, "GUI") == 0)
etc_copy_group(&etc_group_gui[0]);
if (strcmp(ptr, "SOUND") == 0)
etc_copy_group(&etc_group_sound[0]);
if (strcmp(ptr, "NETWORK") == 0)
etc_copy_group(&etc_group_network[0]);
if (strcmp(ptr, "GAMES") == 0)
etc_copy_group(&etc_group_games[0]);
else
etc_add(ptr);
ptr = strtok(NULL, ",");
Expand Down
90 changes: 90 additions & 0 deletions src/include/etc_groups.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2014-2022 Firejail Authors
*
* This file is part of firejail project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef ETC_GROUPS_H
#define ETC_GROUPS_H

#define ETC_MAX 256

// DEFAULT
static char *etc_list[ETC_MAX + 1] = { // plus 1 for ending NULL pointer
"alternatives",
"fonts",
"ld.so.cache",
"ld.so.conf",
"ld.so.conf.d",
"ld.so.preload",
"locale",
"locale.alias",
"locale.conf",
"localtime",
"nsswitch.conf",
"passwd",
NULL
};

// SOUND
static char *etc_group_sound[] = {
"alsa",
"asound.conf",
"machine-id", // required by PulseAudio
"pulse",
NULL
};

// NETWORK
static char*etc_group_network[] = {
"hostname",
"hosts",
"resolv.conf",
"protocols",
NULL
};

// TLS-CA
static char *etc_group_tls_ca[] = {
"ca-certificates",
"crypto-policies",
"gcrypt",
"pki",
"ssl",
NULL
};

// GUI
static char *etc_group_gui[] = {
"xdg",
"drirc",
"dconf",
"gtk-2.0",
"gtk-3.0",
"kde4rc",
"kde5rc",
NULL
};

// GAMES
static char *etc_group_games[] = {
"timidity", // MIDI
"timidity.cfg",
"openal", // 3D sound
};

#endif

0 comments on commit 02d3768

Please sign in to comment.