1 diff -urN utempter-0.5.3.org/Makefile utempter-0.5.3/Makefile
2 --- utempter-0.5.3.org/Makefile 2003-12-18 23:33:32.081092612 +0100
3 +++ utempter-0.5.3/Makefile 2003-12-18 23:34:17.941588864 +0100
6 CFLAGS = -Wall $(RPM_OPT_FLAGS)
8 -TARGETS = $(NAME) utmp $(SHAREDLIB)
9 +TARGETS = $(NAME) utmp $(SHAREDLIB) utmp-cleanup
14 - rm -f *.so utempter utmp *.os
15 + rm -f *.so utempter utmp *.os utmp-cleanup
18 $(CC) -c $(CFLAGS) -fPIC $< -o $@
20 mkdir -p $(RPM_BUILD_ROOT)/$(LIBDIR)
21 mkdir -p $(RPM_BUILD_ROOT)/usr/include
22 install -m 4755 utempter $(RPM_BUILD_ROOT)/usr/sbin
23 + install -m 755 utmp-cleanup $(RPM_BUILD_ROOT)/usr/sbin
24 install -m 644 utempter.h $(RPM_BUILD_ROOT)/usr/include
25 install -m 644 $(SHAREDLIB) $(RPM_BUILD_ROOT)/$(LIBDIR)/$(SHAREDLIB).$(VERSION)
26 ln -sf $(SHAREDLIB).$(VERSION) $(RPM_BUILD_ROOT)/$(LIBDIR)/$(SHAREDLIB)
27 diff -urN utempter-0.5.3.org/utmp-cleanup.c utempter-0.5.3/utmp-cleanup.c
28 --- utempter-0.5.3.org/utmp-cleanup.c 1970-01-01 01:00:00.000000000 +0100
29 +++ utempter-0.5.3/utmp-cleanup.c 2003-12-18 23:33:51.996966369 +0100
35 +#include <sys/stat.h>
36 +#include <sys/types.h>
39 +int check_entry(struct utmp * ut)
46 +pwd=getpwnam(ut->ut_user);
49 +snprintf(buf,100,"/proc/%d/",ut->ut_pid);
53 + if(st.st_uid!=pwd->pw_uid && st.st_uid!=0)return 3;
57 +char * msgs[]={"","Nonexistent user","Dead process","Owner mismatch"};
59 +int main(int ac, char ** av)
64 +char * file="/var/run/utmpx";
66 +fd=open(file,O_RDWR,0);
68 + fd=open(file,O_RDONLY,0);
70 + printf("Warning: opening %s read-only\n",file);
74 + perror("open"); exit(1);
79 + int r=read(fd,&ut,sizeof(ut));
80 + if(r!=sizeof(ut))break;
82 + if(ut.ut_type==USER_PROCESS){
84 + if((i=check_entry(&ut))){
86 + printf("%s: %d (%s)\n",msgs[i],ut.ut_pid,ut.ut_name);
87 + if(justcheck)continue;
88 + lseek(fd,-sizeof(ut),SEEK_CUR);
89 + bzero(&ut,sizeof(ut));
90 + ut.ut_type=DEAD_PROCESS;
91 + write(fd,&ut,sizeof(ut));
97 + if(clean)printf("%s is clean\n",file);