Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <utmp.h>
- #include <string.h>
- #include <stdlib.h>
- #include <pwd.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <dlfcn.h>
- #include <fcntl.h>
- #include <grp.h>
- int main()
- {
- void *bibl;
- void (*LibUser)(char *);
- int error = 0;
- struct utmp a;
- bibl=dlopen("./libProg.so", RTLD_LAZY);
- if (!bibl) error = 1;
- else
- {
- LibUser = dlsym(bibl, "LibUser");
- if(!LibUser) error = 1;
- }
- int utmp = open (_PATH_UTMP, O_RDONLY);
- while(read(utmp, &a, sizeof(struct utmp))>0)
- {
- if(a.ut_type=7)
- {
- if (!error) LibUser(a.ut_user);
- else printf("%s\n", a.ut_user);
- }
- }
- close (utmp);
- if (bibl) dlclose (bibl);
- return 0;
- }
Add Comment
Please, Sign In to add comment