1 --- libutempter-1.1.5/Makefile~ 2007-02-19 13:14:08.000000000 +0100
2 +++ libutempter-1.1.5/Makefile 2010-09-21 14:16:43.025917709 +0200
4 STATICLIB = lib$(PROJECT).a
5 MAP = lib$(PROJECT).map
7 -TARGETS = $(PROJECT) $(SHAREDLIB) $(STATICLIB)
8 +TARGETS = $(PROJECT) $(SHAREDLIB) $(STATICLIB) utmp-cleanup
13 $(INSTALL) -p -m644 $(PROJECT).h $(DESTDIR)$(includedir)/
14 $(INSTALL) -p -m755 $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SHAREDLIB).$(VERSION)
15 $(INSTALL) -p -m644 $(STATICLIB) $(DESTDIR)$(libdir)/
16 + $(INSTALL) -p -m755 utmp-cleanup $(DESTDIR)$(libexecdir)/$(PROJECT)/
17 ln -s $(SHAREDLIB).$(VERSION) $(DESTDIR)$(libdir)/$(SONAME)
18 ln -s $(SONAME) $(DESTDIR)$(libdir)/$(SHAREDLIB)
21 - $(RM) $(TARGETS) iface.o iface.os core *~
22 + $(RM) $(TARGETS) iface.o iface.os core *~ utmp-cleanup
23 diff -urN utempter-0.5.3.org/utmp-cleanup.c utempter-0.5.3/utmp-cleanup.c
24 --- utempter-0.5.3.org/utmp-cleanup.c 1970-01-01 01:00:00.000000000 +0100
25 +++ utempter-0.5.3/utmp-cleanup.c 2003-12-18 23:33:51.996966369 +0100
31 +#include <sys/stat.h>
32 +#include <sys/types.h>
35 +int check_entry(struct utmp * ut)
42 +pwd=getpwnam(ut->ut_user);
45 +snprintf(buf,100,"/proc/%d/",ut->ut_pid);
49 + if(st.st_uid!=pwd->pw_uid && st.st_uid!=0)return 3;
53 +char * msgs[]={"","Nonexistent user","Dead process","Owner mismatch"};
55 +int main(int ac, char ** av)
60 +char * file="/var/run/utmpx";
62 +fd=open(file,O_RDWR,0);
64 + fd=open(file,O_RDONLY,0);
66 + printf("Warning: opening %s read-only\n",file);
70 + perror("open"); exit(1);
75 + int r=read(fd,&ut,sizeof(ut));
76 + if(r!=sizeof(ut))break;
78 + if(ut.ut_type==USER_PROCESS){
80 + if((i=check_entry(&ut))){
82 + printf("%s: %d (%s)\n",msgs[i],ut.ut_pid,ut.ut_name);
83 + if(justcheck)continue;
84 + lseek(fd,-sizeof(ut),SEEK_CUR);
85 + bzero(&ut,sizeof(ut));
86 + ut.ut_type=DEAD_PROCESS;
87 + write(fd,&ut,sizeof(ut));
93 + if(clean)printf("%s is clean\n",file);