Merge pull request #10517 from demin-dmitriy/sublime3

sublime3: make sublime text work with pkexec and gksudo

+36 -2
+1
lib/maintainers.nix
··· 76 dbohdan = "Danyil Bohdan <danyil.bohdan@gmail.com>"; 77 DerGuteMoritz = "Moritz Heidkamp <moritz@twoticketsplease.de>"; 78 deepfire = "Kosyrev Serge <_deepfire@feelingofgreen.ru>"; 79 desiderius = "Didier J. Devroye <didier@devroye.name>"; 80 devhell = "devhell <\"^\"@regexmail.net>"; 81 dezgeg = "Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>";
··· 76 dbohdan = "Danyil Bohdan <danyil.bohdan@gmail.com>"; 77 DerGuteMoritz = "Moritz Heidkamp <moritz@twoticketsplease.de>"; 78 deepfire = "Kosyrev Serge <_deepfire@feelingofgreen.ru>"; 79 + demin-dmitriy = "Dmitriy Demin <demindf@gmail.com>"; 80 desiderius = "Didier J. Devroye <didier@devroye.name>"; 81 devhell = "devhell <\"^\"@regexmail.net>"; 82 dezgeg = "Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>";
+14 -2
pkgs/applications/editors/sublime3/default.nix
··· 1 - { fetchurl, stdenv, glib, xorg, cairo, gtk, pango, makeWrapper, openssl, bzip2 }: 2 3 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"; 4 5 let 6 build = "3083"; 7 libPath = stdenv.lib.makeLibraryPath [glib xorg.libX11 gtk cairo pango]; 8 in let 9 # package with just the binaries 10 sublime = stdenv.mkDerivation { ··· 35 --set-rpath ${libPath}:${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \ 36 $i 37 done 38 ''; 39 40 installPhase = '' ··· 43 44 mkdir -p $out 45 cp -prvd * $out/ 46 47 # Without this, plugin_host crashes, even though it has the rpath 48 wrapProgram $out/plugin_host --prefix LD_PRELOAD : ${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"}/libgcc_s.so.1:${openssl}/lib/libssl.so:${bzip2}/lib/libbz2.so ··· 64 meta = with stdenv.lib; { 65 description = "Sophisticated text editor for code, markup and prose"; 66 homepage = https://www.sublimetext.com/; 67 - maintainers = with maintainers; [ wmertens ]; 68 license = licenses.unfree; 69 platforms = platforms.linux; 70 };
··· 1 + { fetchurl, stdenv, glib, xorg, cairo, gtk, pango, makeWrapper, openssl, bzip2, 2 + pkexecPath ? "/var/setuid-wrappers/pkexec", libredirect, 3 + gksuSupport ? false, gksu}: 4 5 assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"; 6 + assert gksuSupport -> gksu != null; 7 8 let 9 build = "3083"; 10 libPath = stdenv.lib.makeLibraryPath [glib xorg.libX11 gtk cairo pango]; 11 + redirects = [ "/usr/bin/pkexec=${pkexecPath}" ] 12 + ++ stdenv.lib.optional gksuSupport "/usr/bin/gksudo=${gksu}/bin/gksudo"; 13 in let 14 # package with just the binaries 15 sublime = stdenv.mkDerivation { ··· 40 --set-rpath ${libPath}:${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \ 41 $i 42 done 43 + 44 + # Rewrite pkexec|gksudo argument. Note that we can't delete bytes in binary. 45 + sed -i -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g' sublime_text 46 ''; 47 48 installPhase = '' ··· 51 52 mkdir -p $out 53 cp -prvd * $out/ 54 + 55 + wrapProgram $out/sublime_text \ 56 + --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \ 57 + --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects} 58 59 # Without this, plugin_host crashes, even though it has the rpath 60 wrapProgram $out/plugin_host --prefix LD_PRELOAD : ${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"}/libgcc_s.so.1:${openssl}/lib/libssl.so:${bzip2}/lib/libbz2.so ··· 76 meta = with stdenv.lib; { 77 description = "Sophisticated text editor for code, markup and prose"; 78 homepage = https://www.sublimetext.com/; 79 + maintainers = with maintainers; [ wmertens demin-dmitriy ]; 80 license = licenses.unfree; 81 platforms = platforms.linux; 82 };
+21
pkgs/build-support/libredirect/libredirect.c
··· 8 #include <fcntl.h> 9 #include <limits.h> 10 #include <string.h> 11 12 #define MAX_REDIRECTS 128 13 ··· 103 return __xstat_real(ver, rewrite(path, buf), st); 104 } 105 106 int * access(const char * path, int mode) 107 { 108 int * (*access_real) (const char *, int mode) = dlsym(RTLD_NEXT, "access"); 109 char buf[PATH_MAX]; 110 return access_real(rewrite(path, buf), mode); 111 }
··· 8 #include <fcntl.h> 9 #include <limits.h> 10 #include <string.h> 11 + #include <spawn.h> 12 13 #define MAX_REDIRECTS 128 14 ··· 104 return __xstat_real(ver, rewrite(path, buf), st); 105 } 106 107 + int __xstat64(int ver, const char * path, struct stat64 * st) 108 + { 109 + int (*__xstat64_real) (int ver, const char *, struct stat64 *) = dlsym(RTLD_NEXT, "__xstat64"); 110 + char buf[PATH_MAX]; 111 + return __xstat64_real(ver, rewrite(path, buf), st); 112 + } 113 + 114 int * access(const char * path, int mode) 115 { 116 int * (*access_real) (const char *, int mode) = dlsym(RTLD_NEXT, "access"); 117 char buf[PATH_MAX]; 118 return access_real(rewrite(path, buf), mode); 119 } 120 + 121 + int posix_spawn(pid_t * pid, const char * path, 122 + const posix_spawn_file_actions_t * file_actions, 123 + const posix_spawnattr_t * attrp, 124 + char * const argv[], char * const envp[]) 125 + { 126 + int (*posix_spawn_real) (pid_t *, const char *, 127 + const posix_spawn_file_actions_t *, 128 + const posix_spawnattr_t *, 129 + char * const argv[], char * const envp[]) = dlsym(RTLD_NEXT, "posix_spawn"); 130 + char buf[PATH_MAX]; 131 + return posix_spawn_real(pid, rewrite(path, buf), file_actions, attrp, argv, envp); 132 + }