mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
IBus support
This commit is contained in:
parent
dbb15d0067
commit
cc29de3777
5 changed files with 95 additions and 18 deletions
1
RELNOTES
1
RELNOTES
|
|
@ -2,6 +2,7 @@ firejail (0.9.34-rc1) baseline; urgency=low
|
|||
* added --ignore option
|
||||
* added --protocol option
|
||||
* support dual i386/amd64 seccomp filters
|
||||
* IBus support
|
||||
* added Steam, Skype, Wine and Conkeror profiles
|
||||
* bugfixes
|
||||
-- netblue30 <netblue30@yahoo.com> Thu, 29 Oct 2015 08:00:00 -0500
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
*/
|
||||
#include "firejail.h"
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// converts a numeric cpu value in the corresponding bit mask
|
||||
static void set_cpu(const char *str) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#include "firejail.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
|
||||
typedef struct env_t {
|
||||
struct env_t *next;
|
||||
|
|
@ -31,6 +35,85 @@ static void env_add(Env *env) {
|
|||
envlist = env;
|
||||
}
|
||||
|
||||
// load IBUS env variables
|
||||
void env_ibus_load(void) {
|
||||
// check ~/.config/ibus/bus directory
|
||||
char *dirname;
|
||||
if (asprintf(&dirname, "%s/.config/ibus/bus", cfg.homedir) == -1)
|
||||
errExit("asprintf");
|
||||
|
||||
struct stat s;
|
||||
if (stat(dirname, &s) == -1)
|
||||
return;
|
||||
|
||||
// find the file
|
||||
DIR *dir = opendir(dirname);
|
||||
if (!dir) {
|
||||
free(dirname);
|
||||
return;
|
||||
}
|
||||
|
||||
struct dirent *entry;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
// check the file name ends in "unix-0"
|
||||
char *ptr = strstr(entry->d_name, "unix-0");
|
||||
if (!ptr)
|
||||
continue;
|
||||
if (strlen(ptr) != 6)
|
||||
continue;
|
||||
|
||||
// open the file
|
||||
char *fname;
|
||||
if (asprintf(&fname, "%s/%s", dirname, entry->d_name) == -1)
|
||||
errExit("asprintf");
|
||||
FILE *fp = fopen(fname, "r");
|
||||
free(fname);
|
||||
if (!fp)
|
||||
continue;
|
||||
|
||||
// read the file
|
||||
const int maxline = 4096;
|
||||
char buf[maxline];
|
||||
while (fgets(buf, maxline, fp)) {
|
||||
if (strncmp(buf, "IBUS_", 5) != 0)
|
||||
continue;
|
||||
char *ptr = strchr(buf, '=');
|
||||
if (!ptr)
|
||||
continue;
|
||||
ptr = strchr(buf, '\n');
|
||||
if (ptr)
|
||||
*ptr = '\0';
|
||||
if (arg_debug)
|
||||
printf("%s\n", buf);
|
||||
env_store(buf);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
free(dirname);
|
||||
}
|
||||
|
||||
|
||||
// default sandbox env variables
|
||||
void env_defaults(void) {
|
||||
// fix qt 4.8
|
||||
if (setenv("QT_X11_NO_MITSHM", "1", 1) < 0)
|
||||
errExit("setenv");
|
||||
if (setenv("container", "firejail", 1) < 0) // LXC sets container=lxc,
|
||||
errExit("setenv");
|
||||
if (arg_zsh && setenv("SHELL", "/usr/bin/zsh", 1) < 0)
|
||||
errExit("setenv");
|
||||
if (arg_csh && setenv("SHELL", "/bin/csh", 1) < 0)
|
||||
errExit("setenv");
|
||||
if (cfg.shell && setenv("SHELL", cfg.shell, 1) < 0)
|
||||
errExit("setenv");
|
||||
// set prompt color to green
|
||||
//export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '
|
||||
if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0)
|
||||
errExit("setenv");
|
||||
}
|
||||
|
||||
// parse and store the environment setting
|
||||
void env_store(const char *str) {
|
||||
assert(str);
|
||||
|
|
|
|||
|
|
@ -424,6 +424,8 @@ void run_no_sandbox(int argc, char **argv);
|
|||
// env.c
|
||||
void env_store(const char *str);
|
||||
void env_apply(void);
|
||||
void env_defaults(void);
|
||||
void env_ibus_load(void);
|
||||
|
||||
// fs_whitelist.c
|
||||
void fs_whitelist(void);
|
||||
|
|
|
|||
|
|
@ -159,17 +159,19 @@ int sandbox(void* sandbox_arg) {
|
|||
}
|
||||
|
||||
//****************************
|
||||
// netfilter
|
||||
// netfilter etc.
|
||||
//****************************
|
||||
if (arg_netfilter && any_bridge_configured()) { // assuming by default the client filter
|
||||
netfilter(arg_netfilter_file);
|
||||
}
|
||||
|
||||
// load IBUS env variables
|
||||
env_ibus_load();
|
||||
|
||||
// grab a copy of cp command
|
||||
fs_build_cp_command();
|
||||
|
||||
//****************************
|
||||
// trace pre-install
|
||||
//****************************
|
||||
if (arg_trace)
|
||||
fs_trace_preload();
|
||||
|
||||
|
|
@ -396,21 +398,8 @@ int sandbox(void* sandbox_arg) {
|
|||
}
|
||||
|
||||
// set environment
|
||||
// fix qt 4.8
|
||||
if (setenv("QT_X11_NO_MITSHM", "1", 1) < 0)
|
||||
errExit("setenv");
|
||||
if (setenv("container", "firejail", 1) < 0) // LXC sets container=lxc,
|
||||
errExit("setenv");
|
||||
if (arg_zsh && setenv("SHELL", "/usr/bin/zsh", 1) < 0)
|
||||
errExit("setenv");
|
||||
if (arg_csh && setenv("SHELL", "/bin/csh", 1) < 0)
|
||||
errExit("setenv");
|
||||
if (cfg.shell && setenv("SHELL", cfg.shell, 1) < 0)
|
||||
errExit("setenv");
|
||||
// set prompt color to green
|
||||
//export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '
|
||||
if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0)
|
||||
errExit("setenv");
|
||||
env_defaults();
|
||||
|
||||
// set user-supplied environment variables
|
||||
env_apply();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue