[linux-l] X-AutoLogin
Schlomo Schapiro
belug at schapiro.org
Di Mai 27 15:17:39 CEST 2003
Hello Oliver,
ich benutze folgendes script, um Xvnc und eine Session dadrin für einen
user zu starten. Wenn Du statt Xvnc den normalen X server startest, dann
sollte das auch funktionieren (vielleicht mit ein paar kleinen Änderungen
am script).
Anregungen sind natürlich willkommen.
-----------------------------------------------
#!/usr/bin/perl -w
#
#
# Created by Schlomo Schapiro schlomo at schapiro.org
#
# Initial Version: 2003-02-18
# 2003-02-19: Converted to Perl, drop permissions
#
# Drop uid
$user="someuser"; # set username to run
@pwentry=getpwnam($user);
$(="$pwentry[3]";
$)="$pwentry[3] $pwentry[3] 10 17 33";
$>=$pwentry[2];
$<=$pwentry[2];
$home=$pwentry[7];
chdir($home);
rename("runvnc.log","runvnc.log.old") if (-e "runvnc.log");
open(STDOUT,">","runvnc.log");
open(STDERR,">&STDOUT");
select(STDERR); $| = 1; # make unbuffered
select(STDOUT); $| = 1; # make unbuffered
$ENV{"PATH"}="/usr/local/bin:/usr/X11/bin:/usr/bin:/bin";
# create X Authority file
$xauth=$home."/.Xauthority";
$ENV{"XAUTHORITY"}=$xauth;
unlink($xauth) if (-e $xauth);
# Make an X server cookie - use as the seed the sum of the current time, our
# PID and part of the encrypted form of the password. Ideally we'd use
# /dev/urandom, but that's only available on Linux.
srand(time+$$);
$cookie = "";
for (1..16) {
$cookie .= sprintf("%02x", int(rand(256)));
}
system("xauth -f ".$xauth." add `hostname`/unix:10 MIT-MAGIC-COOKIE-1 ".$cookie);
system("xauth -f ".$xauth." add `hostname -f`:10 MIT-MAGIC-COOKIE-1 ".$cookie);
$ENV{"DISPLAY"}=":10";
$ENV{"HOME"}=$home;
$ENV{"USER"}=$user;
$ENV{"LOGNAME"}=$user;
if (fork()) {
# This is the parent
# start VNC Server
exec("Xvnc $ENV{"DISPLAY"} -desktop \"remote\" ".
"-httpport 0 ".
"-auth ".$xauth." ".
"-geometry 1000x700 ".
"-depth 8 ".
"-rfbauth ".$home."/vncpasswd ".
"-rfbport 5910 ".
"-terminate -once ".
"-fp tcp/yard:7100" );
die("Could not exec Xvnc: $!");
} else {
# fork == 0, this is the child
sleep(2); # give Xvnc time to startup
exec $home."/.xsession";
die("Could not exec .xsession: $!");
}
----------------------------------------------------------
Schlomo
Tuesday, May 27, 2003, 11:52:03 AM, you wrote:
> Hi,
> ist jemanden ein Programm bekannt, das automatisch einen User am XServer
> anmeldet? KDM und GDM fallen aus, da diese zu viele Abhängigkeite haben,
> die ich installieren müsste. In der Manpage zu XDM konnte ich nicht zu
> dem Thema finden, woraus ich schliesse, das es nicht unterstützt wird.
> Es wäre von Vorteil, wenn das Programm so wenig Abhängigkeiten wie
> möglich hat. Nun, GTK1, GLIB1, Lib{JPEG,PNG,GIF} und das LFS-System sind
> installiert. Sachen, die GTK2, GLIB2 und QT benötigen möchte ich nicht
> wirklich aufspielen.
> Mfg Oliver
--
Best regards,
Schlomo
Mehr Informationen über die Mailingliste linux-l