Using my c++ program how can I find out what group the current user running my program belongs to? So my program need to figure out a couple of things :
- The current username of the user
- The group the user belongs to
How can do the above 2 using c++ on a RedHat / Linux machine?
With
getuid(2)andgetgid(2). Seecredentials(7)for more information.Use
getpwuid(3)andgetgrgid(3)for the names.