- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Getgid function
Operating System - HP-UX
1755140
Members
3022
Online
108830
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2002 01:06 PM
тАО04-29-2002 01:06 PM
I am using a c program to get the group id of the calling process, but the problem is I need to check for one of the secondary group ids (and not the primary gid).
Is there any function which can accomplish this ?
Thanks
Is there any function which can accomplish this ?
Thanks
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2002 01:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2002 01:53 PM
тАО04-29-2002 01:53 PM
Re: Getgid function
Actually the getgrent function alone does nothing except return the next group entry in the file. It tells you nothing about whether this user is a member of a given group. What you actually have to do is examine each gr_mem value looking for a string match on the user name.
I attached a small piece of code I yanked from one of my programs that will be fairly close; it also has a small main to illustrate it's use. It should be very easy to modify it to return the gid when a hit is found. This will search first the user's primary group and then
look through /etc/groups for a matching login.
Use it like this:
rslt = checkgrp("this_user","this_group",FALSE);
rslt will be set to 0 if "this_user" is a member of "this_group"); (FALSE says no verbose output on error).
Compile the test program like this:
cc -Ae checkgrp.c -o checkgrp after modifying it with sample values to fit your system.
I attached a small piece of code I yanked from one of my programs that will be fairly close; it also has a small main to illustrate it's use. It should be very easy to modify it to return the gid when a hit is found. This will search first the user's primary group and then
look through /etc/groups for a matching login.
Use it like this:
rslt = checkgrp("this_user","this_group",FALSE);
rslt will be set to 0 if "this_user" is a member of "this_group"); (FALSE says no verbose output on error).
Compile the test program like this:
cc -Ae checkgrp.c -o checkgrp after modifying it with sample values to fit your system.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP