Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <pwd.h>
  2. #include <grp.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include <unistd.h>
  7. #include <dlfcn.h>
  8.  
  9. int main(void){
  10. void *uchwyt;
  11. char *name;
  12. uid_t user = getuid();
  13. gid_t groupid = getgid();
  14. struct passwd *userpass = getpwuid(user);
  15. //struct group *l = getgrnam("lukasz");
  16. //if (l->gr_mem[0]==NULL) printf("Dziwne\n");
  17. setgrent();
  18. struct group *aktualna;
  19. printf("ID uzytkownika: %d\n", userpass->pw_uid);
  20. printf("Uzytkownik: %s\n", userpass->pw_name);
  21. name = userpass->pw_name;
  22. uchwyt = dlopen("fun.so",RTLD_LAZY);
  23. if(!uchwyt) {
  24. fprintf(stderr, "%s\n", dlerror());
  25. exit(1);
  26. }
  27. return(0);
  28. }
  29.  
  30.  
  31. #include <pwd.h>
  32. #include <grp.h>
  33. #include <stdlib.h>
  34. #include <stdio.h>
  35. #include <sys/types.h>
  36. #include <unistd.h>
  37.  
  38. void jakieGrupy(int *name){
  39. printf("Nalezy do grup: \n");
  40. while ( (aktualna=getgrent()) != NULL){
  41. //printf("Grupa: %s\n",aktualna->gr_name);
  42. int w = 0;
  43. int g = 0;
  44. while (aktualna->gr_mem[w] != NULL){
  45. //printf("\tMember: %s\n",aktualna->gr_mem[w]);
  46. if (strcmp(name,aktualna->gr_mem[w])==0){
  47. printf("%s\n",aktualna->gr_name);
  48. }
  49. w++;
  50. }
  51. }
  52. endgrent();
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement