2010-07-28 17:35:01 +02:00
|
|
|
{ stdenv, xorgserver }:
|
2009-10-28 15:06:56 +01:00
|
|
|
|
|
|
|
# !!! What does this package do, and does it belong in Nixpkgs?
|
|
|
|
|
2007-12-31 09:49:41 +01:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "xlaunch";
|
|
|
|
inherit xorgserver;
|
|
|
|
buildCommand = "
|
2008-01-01 22:01:58 +01:00
|
|
|
cat << EOF > realizeuid.c
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char ** argv, char ** envp)
|
|
|
|
{
|
|
|
|
uid_t a,b,c;
|
|
|
|
int i;
|
|
|
|
char *nargv[10000];
|
|
|
|
char arg1 [10];
|
|
|
|
nargv[0]=argv[0];
|
|
|
|
for (i=1; i<=argc; i++){
|
|
|
|
nargv[i+1]=argv[i];
|
|
|
|
}
|
|
|
|
nargv[1]=arg1;
|
|
|
|
getresuid (&a,&b,&c);
|
|
|
|
snprintf(arg1,8,\"%d\",a);
|
|
|
|
setresuid(c,c,c);
|
|
|
|
execve(\"\$out/libexec/xlaunch\", nargv, envp);
|
|
|
|
}
|
|
|
|
EOF
|
2007-12-31 09:49:41 +01:00
|
|
|
mkdir -p \$out/bin
|
2008-01-01 22:01:58 +01:00
|
|
|
mkdir -p \$out/libexec
|
|
|
|
gcc realizeuid.c -o \$out/bin/xlaunch
|
|
|
|
echo '#! ${stdenv.shell}
|
|
|
|
USER=\$(egrep '\\''^[-a-z0-9A-Z_]*:[^:]*:'\\''\$1'\\'':'\\'' /etc/passwd | sed -e '\\''s/:.*//'\\'' )
|
|
|
|
shift
|
2008-01-02 17:43:36 +01:00
|
|
|
case \"\$1\" in
|
|
|
|
:*) export _display=\"\$1\";
|
|
|
|
shift
|
|
|
|
esac
|
|
|
|
_display=\${_display:-:0}
|
|
|
|
_display=\${_display#:}
|
|
|
|
echo Using :\$_display
|
2009-08-04 12:14:29 +02:00
|
|
|
if [ -n \"\$DO_X_RESET\" ]; then
|
|
|
|
RESET_OPTION=\"-once\"
|
|
|
|
else
|
|
|
|
RESET_OPTION=\"-noreset\"
|
|
|
|
fi;
|
2013-02-05 14:21:41 +01:00
|
|
|
XCMD=\"\$(egrep \"^Environment=\" /etc/systemd/system/display-manager.service | sed -e \"s/Environment=/ export /\" | sed -e '\\''s/#.*//'\\'' ; echo export _XARGS_=\\\$\\( grep xserver_arguments \\\$SLIM_CFGFILE \\| sed -e s/xserver_arguments// \\| sed -e s/:0/:\${_display}/ \\| sed -e s/vt7/vt\$((7+_display))/ \\) ; echo ${xorgserver}/bin/X \\\$_XARGS_ \$RESET_OPTION )\"
|
2013-05-23 22:43:31 +02:00
|
|
|
PRE_XCMD=\"\$(egrep \"^ExecStartPre=\" /etc/systemd/system/display-manager.service | sed -e \"\s/ExecStartPre=//\")\"
|
|
|
|
echo \"\$PRE_XCMD\"
|
|
|
|
echo \"\$PRE_XCMD\" | bash
|
2008-01-04 18:02:12 +01:00
|
|
|
echo \"\$XCMD\"
|
|
|
|
echo \"\$XCMD\" | bash &
|
2008-01-02 17:43:36 +01:00
|
|
|
while ! test -e /tmp/.X11-unix/X\$_display &>/dev/null ; do sleep 0.5; done
|
|
|
|
su -l \${USER:-identityless-shelter} -c \"DISPLAY=:\$_display \$*\";
|
2008-01-01 22:01:58 +01:00
|
|
|
' >\$out/libexec/xlaunch
|
|
|
|
chmod a+x \$out/libexec/xlaunch
|
2007-12-31 09:49:41 +01:00
|
|
|
";
|
|
|
|
}
|