Skip to content

Instantly share code, notes, and snippets.

@stbuehler
Created January 21, 2014 13:38
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stbuehler/8540197 to your computer and use it in GitHub Desktop.
Save stbuehler/8540197 to your computer and use it in GitHub Desktop.
Workaround sublime text 3 umask bug, always adding 0022 to the mask (deny write to group/others) with LD_PRELOAD hack.
/*
compile with:
gcc -shared -fPIC fix_umask.c -o fix_umask.so
edit /usr/bin/subl to include (fix the path to fix_umask.so if necessary):
#!/bin/sh
export LD_PRELOAD=/opt/sublime_text/fix_umask.so
exec /opt/sublime_text/sublime_text "$@"
*/
#include <sys/types.h>
#include <sys/stat.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <unistd.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
mode_t umask(mode_t mask) {
mask |= 0022;
return syscall(SYS_umask, mask);
}
@dvdvck
Copy link

dvdvck commented May 24, 2014

buddy, I am afraid this workaround is not working :( Still having unexpected permissions
linux mint 16 - sublime text build 3059

@spelufo
Copy link

spelufo commented Sep 1, 2015

Yes it does, at least for me. Thank you very much!

@dvdvck check that you are starting sublime from the command line for the first time. It might be that the .desktop file execs the binary and bypasses the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment