Re: logout and auto-login
Re: logout and auto-login
- Subject: Re: logout and auto-login
- From: Finlay Dobbie <email@hidden>
- Date: Sun, 9 Dec 2001 12:05:04 +0000
On Sunday, December 9, 2001, at 11:51 am, Jake wrote:
It is a security application. If it detects an anomaly, it is to
terminate
the current session and logout the user "gracefully by force". It
appears
that killing either the "loginwindow" or "WindowServer" does the job.
But
I can't seem to be able to get the pid of those process from within my
program without resorting to a shell scripts: getpgrp() doesn't yet
exist
in OSX, and I can't walk the process table because of permission issues.
(ps is suid). Any suggestions?
You can walk the process table programmatically. I used this code to
check if a pid is running, you could probably adapt it (man 3 sysctl for
more info) to check for a process by name:
BOOL isPidRunning(int pid) {
int mib[4];
size_t len;
struct kinfo_proc *p;
int nentries;
BOOL isRunning;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = pid;
if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0) { NSLog(@"Error calling
sysctl"); return NO; }
p = (struct kinfo_proc *)malloc(len);
if (sysctl(mib, 4, p, &len, NULL, 0) < 0) { NSLog(@"Error calling
sysctl"); return NO; }
nentries = len / sizeof(struct kinfo_proc);
if (nentries > 0) {
isRunning = YES;
} else {
isRunning = NO;
}
free(p);
return isRunning;
}
as with autologin, the password is does NOT appear to be stored
anywhere,
no?
of course not. that would be silly, considering everybody can read the
netinfo db.
-- Finlay