Skip to content

Commit

Permalink
Forgot to add the umask wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlesage committed Jul 4, 2017
1 parent 9451677 commit f034d04
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions makemkv-builder/builder/umask_wrapper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

static void init(void) __attribute__((constructor));

static int (*orig_open)(const char *path, int flags, mode_t mode);

/*
* Constructor.
*
* Save pointer to the original open function.
*/
static void init(void) {
orig_open = dlsym(RTLD_NEXT, "open");
}

/*
* Wrapper for the open function.
*
* If we are opening an MKV file, override the mode.
*/
int open(const char *path, int flags, mode_t mode) {
char *dot = strrchr(path, '.');
if (dot && strcmp(dot, ".mkv") == 0) {
return orig_open(path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
}
else {
return orig_open(path, flags, mode);
}
}

0 comments on commit f034d04

Please sign in to comment.