From 0cea20a6522ed0d84d39c550e46f1d755176adcc Mon Sep 17 00:00:00 2001 From: Demin Dmitriy Date: Sat, 24 Oct 2015 18:04:33 +0300 Subject: [PATCH 1/3] libredirect: add __xlib64 and posix_spawn --- pkgs/build-support/libredirect/libredirect.c | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c index 4e0a8245ac1d..c24560a1a493 100644 --- a/pkgs/build-support/libredirect/libredirect.c +++ b/pkgs/build-support/libredirect/libredirect.c @@ -8,6 +8,7 @@ #include #include #include +#include #define MAX_REDIRECTS 128 @@ -103,9 +104,29 @@ int __xstat(int ver, const char * path, struct stat * st) return __xstat_real(ver, rewrite(path, buf), st); } +int __xstat64(int ver, const char * path, struct stat64 * st) +{ + int (*__xstat64_real) (int ver, const char *, struct stat64 *) = dlsym(RTLD_NEXT, "__xstat64"); + char buf[PATH_MAX]; + return __xstat64_real(ver, rewrite(path, buf), st); +} + int * access(const char * path, int mode) { int * (*access_real) (const char *, int mode) = dlsym(RTLD_NEXT, "access"); char buf[PATH_MAX]; return access_real(rewrite(path, buf), mode); } + +int posix_spawn(pid_t * pid, const char * path, + const posix_spawn_file_actions_t * file_actions, + const posix_spawnattr_t * attrp, + char * const argv[], char * const envp[]) +{ + int (*posix_spawn_real) (pid_t *, const char *, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t *, + char * const argv[], char * const envp[]) = dlsym(RTLD_NEXT, "posix_spawn"); + char buf[PATH_MAX]; + return posix_spawn_real(pid, rewrite(path, buf), file_actions, attrp, argv, envp); +} From c66f8b293b873e07d0b2de49d9741ffc035baa03 Mon Sep 17 00:00:00 2001 From: Demin Dmitriy Date: Sat, 24 Oct 2015 18:14:59 +0300 Subject: [PATCH 2/3] sublime3: add pkexec and gksudo support --- pkgs/applications/editors/sublime3/default.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/editors/sublime3/default.nix b/pkgs/applications/editors/sublime3/default.nix index b26d27a8bc51..aa5492dbe7ad 100644 --- a/pkgs/applications/editors/sublime3/default.nix +++ b/pkgs/applications/editors/sublime3/default.nix @@ -1,10 +1,15 @@ -{ fetchurl, stdenv, glib, xorg, cairo, gtk, pango, makeWrapper, openssl, bzip2 }: +{ fetchurl, stdenv, glib, xorg, cairo, gtk, pango, makeWrapper, openssl, bzip2, + pkexecPath ? "/var/setuid-wrappers/pkexec", libredirect, + gksuSupport ? false, gksu}: assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"; +assert gksuSupport -> gksu != null; let build = "3083"; libPath = stdenv.lib.makeLibraryPath [glib xorg.libX11 gtk cairo pango]; + redirects = [ "/usr/bin/pkexec=${pkexecPath}" ] + ++ stdenv.lib.optional gksuSupport "/usr/bin/gksudo=${gksu}/bin/gksudo"; in let # package with just the binaries sublime = stdenv.mkDerivation { @@ -35,6 +40,9 @@ in let --set-rpath ${libPath}:${stdenv.cc.cc}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \ $i done + + # Rewrite pkexec|gksudo argument. Note that we can't delete bytes in binary. + sed -i -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g' sublime_text ''; installPhase = '' @@ -44,6 +52,10 @@ in let mkdir -p $out cp -prvd * $out/ + wrapProgram $out/sublime_text \ + --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \ + --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects} + # Without this, plugin_host crashes, even though it has the rpath 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 ''; From 8a1e5d9a27f8ff6f4c2f245fa3ffddc573fee341 Mon Sep 17 00:00:00 2001 From: Demin Dmitriy Date: Sat, 24 Oct 2015 00:30:55 +0300 Subject: [PATCH 3/3] sublime3: add myself as a maintainer --- lib/maintainers.nix | 1 + pkgs/applications/editors/sublime3/default.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/maintainers.nix b/lib/maintainers.nix index b64c236bde35..6589f2ef35fd 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -76,6 +76,7 @@ dbohdan = "Danyil Bohdan "; DerGuteMoritz = "Moritz Heidkamp "; deepfire = "Kosyrev Serge <_deepfire@feelingofgreen.ru>"; + demin-dmitriy = "Dmitriy Demin "; desiderius = "Didier J. Devroye "; devhell = "devhell <\"^\"@regexmail.net>"; dezgeg = "Tuomas Tynkkynen "; diff --git a/pkgs/applications/editors/sublime3/default.nix b/pkgs/applications/editors/sublime3/default.nix index aa5492dbe7ad..49c30a1f6d60 100644 --- a/pkgs/applications/editors/sublime3/default.nix +++ b/pkgs/applications/editors/sublime3/default.nix @@ -76,7 +76,7 @@ in stdenv.mkDerivation { meta = with stdenv.lib; { description = "Sophisticated text editor for code, markup and prose"; homepage = https://www.sublimetext.com/; - maintainers = with maintainers; [ wmertens ]; + maintainers = with maintainers; [ wmertens demin-dmitriy ]; license = licenses.unfree; platforms = platforms.linux; };