Disappearing files, created from /etc/X11/Xclients
Hi, I'm running several diskless boxes. They connect to the same server with xdmpc (gdm). When a user logs in, the WM is started by script /etc/X11/Xclients: #!/bin/sh xmodmap /etc/X11/xmodmap.hun exec /etc/X11/startwm.py You can find the startwm.py script at the end of this e-mail. Most importantly, I wanted to save client IP addresses and the date of the login into different files. These files are located under /tmp/disklessips/*. Rights for /tmp/diskless is octal 42777: drwxrwsrwx 2 root users 512 Mar 20 14:41 disklessips The strange thing is that, if I login with user 'gandalf' who is in 'wheel', the files are created and saved into /tmp/disklessips/gandalf.txt and /tmp/disklessips/gandalf.history.txt. But if I login with any other user (they are in group 'users'), no files are created, but the window manager IS started. The startwm.py program creates these files BEFORE starting gnome, and it does throw an error. So they must have been created, but I do not see them anywhere. They simply disappear. Never existed? Any thoughts? Thanks, Laszlo #!/usr/local/bin/python import os import datetime WM = exec dbus-launch --exit-with-session gnome-session # Extract client IP display = os.environ['DISPLAY'] idx = display.find(':') remotehost = display[:idx] os.environ['REMOTEHOST'] = remotehost # Save client IP ddir = '/tmp/disklessips' fout = file('%s/%s.txt'%(ddir,os.getlogin()),'wb+') fout.write(remotehost) fout.close() # Save history fout = file('%s/%s.history.txt'%(ddir,os.getlogin()),'ab+') fout.write( datetime.datetime.now().isoformat()[:19] + '\t' + remotehost + '\n' ) fout.close() os.system(WM) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Disappearing files, created from /etc/X11/Xclients
Laszlo Nagy wrote: The strange thing is that, if I login with user 'gandalf' who is in 'wheel', the files are created and saved into /tmp/disklessips/gandalf.txt and /tmp/disklessips/gandalf.history.txt. But if I login with any other user (they are in group 'users'), no files are created, but the window manager IS started. The startwm.py program creates these files BEFORE starting gnome, and it does throw an error. So they must have been created, but I do not see them anywhere. They simply disappear. Never existed? Any thoughts? [...] fout = file('%s/%s.txt'%(ddir,os.getlogin()),'wb+') If os.getlogin() failed non-fatally and returned, say, and empty string, then you'd be creating a file called .txt, if I read correctly. What does ls -lsa /tmp/disklessips show? Do you in fact have .txt and .history.txt files (which a simple ls won't show you). Failing that, you'll just need to include some debugging. Open a file in /tmp to write stuff to, and print *all* the various variables you use to that file. (Or just print them to stdout if that will show up on the console). Then try as some other user and check that everything really does have the value you think it does. Since python doesn't crash, my belief is that it really has written the stuff somewhere. hth, --Alex ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Disappearing files, created from /etc/X11/Xclients
Please include freebsd-questions on any replies. Laszlo Nagy wrote: If os.getlogin() failed non-fatally and returned, say, and empty string, then you'd be creating a file called .txt, if I read correctly. What does ls -lsa /tmp/disklessips show? Do you in fact have .txt and .history.txt files (which a simple ls won't show you). There are no '.txt' and '.history.txt' files. :-( Failing that, you'll just need to include some debugging. Open a file in /tmp to write stuff to, and print *all* the various variables you use to that file. (Or just print them to stdout if that will show up on the console). Then try as some other user and check that everything really does have the value you think it does. Unfortunately, I cannot debug this way. The error is that no files are created by normal users, so I cannot use files for logging. Also there is no console because this is the /etcX11/Xclients script, e.g. it is executed by gdm after logging in to X window system through xdmpc. Well, I might setup an xml rpc server for logging, but hey, if I cannot write into a wicked file then I should not start with complex protocols and networking. Humour me. Try opening a fixed filename in a location which you double-check is world-writeable. E.g. /tmp/FOO and print all your relevant variables there. If it works as gandalf, then delete that trace file and try as a non-working user. If that fails, then try opening the file in the home directory of the user who you are testing as. If that fails then you can try logging them with syslog. If *that* fails then make your console world-writeable for a little while and print directly to that (/dev/console) (assuming there is a console which you can sit in front of). One way or another you need to get debugging info to figure out what is not working. I asked this on the FreeBSD questions list because I thought that there is some OS specific stuff that I don't know of. There's no FreeBSD specific feature which makes file mysteriously vanish, that I'm aware of ;-) Are you sure that if say the file() fails, that a window manager won't start anyway? You can test that by making the filename something clearly non-existent. --Alex ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Disappearing files, created from /etc/X11/Xclients
Unfortunately, I cannot debug this way. The error is that no files are created by normal users, so I cannot use files for logging. Also there is no console because this is the /etcX11/Xclients script, e.g. it is executed by gdm after logging in to X window system through xdmpc. Well, I might setup an xml rpc server for logging, but hey, if I cannot write into a wicked file then I should not start with complex protocols and networking. Humour me. Try opening a fixed filename in a location which you double-check is world-writeable. E.g. /tmp/FOO and print all your relevant variables there. If it works as gandalf, then delete that trace file and try as a non-working user. If that fails, then try opening the file in the home directory of the user who you are testing as. I tried this before I wrote to this list. It does not work. No 'normal' users can create these files from /etc/X11/Xclients. But after gnome starts up, they can create these files. If I login with a normal user and I try to re-run /etc/X11/Xclients then the files gets created, and finally I get an error message telling that gnome is already running. If that fails then you can try logging them with syslog. How can I do that from Python? :-) I tried this: from syslog import * syslog(|LOG_INFO | LOG_USER, 'test') No exception raised but I found nothing under /var/log.| Are you sure that if say the file() fails, that a window manager won't start anyway? You can test that by making the filename something clearly non-existent. To your request, I changed the ddir variable to '/nonexistent', and gnome was started! So you found the problem! Thanks! :-) It was that gdm started /usr/local/etc/gdm/Xsession. That script started /etc/X11/Xclients but ONLY for user gandalf. It is because I selected 'use system default session' in gdm before logging in. It was months ago, and I forgot it. Other users were using the default gnome session, e.g. they were NOT executing the Xclients script. Thank you again! Laszlo ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]