site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hi, #import <Foundation/Foundation.h> #import <utmp.h> #import <stdlib.h> #import <stdio.h> extern int errno; int main (int argc, const char * argv[]) { NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; FILE *utmp_file; struct utmp *utmp_store; [Session started at 2005-12-13 15:32:15 +0000.] That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on cons. That fool , over way, was responsible. It was at 0 on ole. That fool , over way, was responsible. It was at 0 on leeg. That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on . That fool , over way, was responsible. It was at 0 on \242\213\305X. How should I read struct utmp records from the utmp file? Thanks, Graham. -- Graham Lee GPG Key ID: 01D5B9D8 UNIX Systems Manager, Oxford Physics Practical Course http://users.ox.ac.uk/~wadh1342 01865 273450 _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... I want to get login information for users (basically my goal is a Bonjour-enabled equivalent to the old GNU or ICSI distributed finger server[*], where any systems on the local network register themselves with the server so I can find out if a user has logged in anywhere on the local network) and as neither of the distributed fingers come anywhere near close to compiling on Darwin (8.3.0) have tried to start from scratch. Having observed that /var/run/utmpx is empty, and that there's no getutent on Darwin, I'm doing it the same way that programs like w(1) do and reading struct utmps from the appropriate file. However, what I get back doesn't seem consistent with the idea that utmp(5) [or indeed wtmp(5)] is just a bunch of struct utmps stored back to back. Here's my code: errno=0; if((utmp_file=fopen(_PATH_UTMP,"rb"))==NULL) { perror("csalutd: couldn't open utmp"); exit(EXIT_FAILURE); } if((utmp_store=(struct utmp *)malloc(sizeof(utmp_store)))==NULL) { perror("csalutd: couldn't malloc struct"); exit(EXIT_FAILURE); } while(fread(utmp_store,sizeof(utmp_store),1,utmp_file)==1) { printf("That fool %s, over %s way, was responsible.\nIt was at %d on %s.\n",utmp_store->ut_name,utmp_store->ut_host,utmp_store-
ut_time,utmp_store->ut_line);
} fclose(utmp_file); [pool release]; return 0; } The first few lines of output: So there's a lot of 0 going on, and what look like valid data (e.g. leeg is currently logged in on console). I get similar output if I use _PATH_WTMP, by the way. But the data don't seem aligned in the same way that <utmp.h> suggests they would be, especially as there seem to be so many \0 characters all over the place. [*]It's nice of you to be concerned about the security implications of a distributed finger service, I've taken those into consideration and still need such a service kthx. This email sent to site_archiver@lists.apple.com
participants (1)
-
Graham J Lee